AlgoPlus v0.1.0
Loading...
Searching...
No Matches
linked_list< T >::Iterator Class Reference

Iterator class. More...

#include <linked_list.h>

Public Member Functions

 Iterator (const std::shared_ptr< node > &l) noexcept
 Construct a new Iterator object.
 
Iteratoroperator= (std::shared_ptr< node > current)
 = operator for Iterator type
 
Iteratoroperator++ ()
 operator ++ for type Iterator
 
Iterator operator++ (int)
 operator ++ for type Iterator
 
bool operator!= (const Iterator &it)
 operator != for type Iterator
 
operator* ()
 operator * for type Iterator
 
 linked_list (std::vector< T > _elements={}) noexcept
 linked_list class constructor
 
 linked_list (const linked_list &l)
 copy constructor for the linked_list class
 
linked_listoperator= (const linked_list &l)
 operator = for linked list class
 
bool empty ()
 empty function. Returns true if the list is empty.
 
size_t size ()
 size function. Returns the size of the list.
 
Iterator begin ()
 pointer that points to begin
 
Iterator end ()
 pointer that points to end
 
void push_back (T key)
 push_back function.
 
void push_front (T key)
 push_front function.
 
void erase (T key)
 erase function.
 
bool search (T key)
 search function.
 
std::vector< T > elements ()
 elements function.
 
void reverse ()
 reverse function.
 
void visualize ()
 visualize function returns a .dot file that can be previewd with graphviz plugin in vscode
 

Friends

std::ostream & operator<< (std::ostream &out, linked_list< T > &l1)
 << operator for the linked_list class.
 

Detailed Description

template<typename T>
class linked_list< T >::Iterator

Iterator class.

Constructor & Destructor Documentation

◆ Iterator()

template<typename T>
linked_list< T >::Iterator::Iterator ( const std::shared_ptr< node > & l)
inlineexplicitnoexcept

Construct a new Iterator object.

Parameters
llinked list type

Member Function Documentation

◆ begin()

Iterator linked_list< T >::begin ( )
inline

pointer that points to begin

Returns
Iterator

◆ elements()

std::vector< T > linked_list< T >::elements ( )
inline

elements function.

Returns
vector<T>: the elements of the list.

◆ end()

Iterator linked_list< T >::end ( )
inline

pointer that points to end

Returns
Iterator

◆ erase()

void linked_list< T >::erase ( T key)
inline

erase function.

Parameters
keythe key to be erased.

◆ linked_list() [1/2]

linked_list< T >::linked_list ( const linked_list & l)
inlineexplicit

copy constructor for the linked_list class

Parameters
lthe list we want to copy

◆ linked_list() [2/2]

linked_list< T >::linked_list ( std::vector< T > _elements = {})
inlineexplicitnoexcept

linked_list class constructor

Parameters
__elementsyou can provide the constructor with a vector of elements so you dont have to do multiple push backs yourself.

◆ operator!=()

template<typename T>
bool linked_list< T >::Iterator::operator!= ( const Iterator & it)
inline

operator != for type Iterator

Parameters
itconst Iterator
Returns
true if curr_root == it.curr_root
false otherwise

◆ operator*()

template<typename T>
T linked_list< T >::Iterator::operator* ( )
inline

operator * for type Iterator

Returns
T the value of the node

◆ operator++() [1/2]

template<typename T>
Iterator & linked_list< T >::Iterator::operator++ ( )
inline

operator ++ for type Iterator

Returns
Iterator&

◆ operator++() [2/2]

template<typename T>
Iterator linked_list< T >::Iterator::operator++ ( int )
inline

operator ++ for type Iterator

Returns
Iterator

◆ operator=() [1/2]

linked_list & linked_list< T >::operator= ( const linked_list & l)
inline

operator = for linked list class

Parameters
lthe list we want to copy
Returns
linked_list&

◆ operator=() [2/2]

template<typename T>
Iterator & linked_list< T >::Iterator::operator= ( std::shared_ptr< node > current)
inline

= operator for Iterator type

Parameters
currentsmart pointer of type node
Returns
Iterator&

◆ push_back()

void linked_list< T >::push_back ( T key)
inline

push_back function.

Parameters
keythe key to be pushed back.

◆ push_front()

void linked_list< T >::push_front ( T key)
inline

push_front function.

Parameters
keythe key to be pushed in front.

◆ search()

bool linked_list< T >::search ( T key)
inline

search function.

Parameters
keythe key to be searched.
Returns
true if key exists in the list.

The documentation for this class was generated from the following file: