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

single linked list class More...

#include <linked_list.h>

Classes

class  Iterator
 Iterator class. More...
 

Public Member Functions

 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 >

single linked list class

Constructor & Destructor Documentation

◆ linked_list() [1/2]

template<typename T >
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.

◆ linked_list() [2/2]

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

copy constructor for the linked_list class

Parameters
lthe list we want to copy

Member Function Documentation

◆ begin()

template<typename T >
Iterator linked_list< T >::begin ( )
inline

pointer that points to begin

Returns
Iterator

◆ elements()

template<typename T >
std::vector< T > linked_list< T >::elements ( )

elements function.

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

◆ end()

template<typename T >
Iterator linked_list< T >::end ( )
inline

pointer that points to end

Returns
Iterator

◆ erase()

template<typename T >
void linked_list< T >::erase ( T key)

erase function.

Parameters
keythe key to be erased.

◆ operator=()

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

operator = for linked list class

Parameters
lthe list we want to copy
Returns
linked_list&

◆ push_back()

template<typename T >
void linked_list< T >::push_back ( T key)

push_back function.

Parameters
keythe key to be pushed back.

◆ push_front()

template<typename T >
void linked_list< T >::push_front ( T key)

push_front function.

Parameters
keythe key to be pushed in front.

◆ search()

template<typename T >
bool linked_list< T >::search ( T key)

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: