Data Structures & Algorithms in C++
Goodrich, Tamassia, Mount and Goldwasser
Loading...
Searching...
No Matches
Data Structures | Public Member Functions | Friends
dsac::list::DoublyLinkedList< T > Class Template Reference

doubly linked list, akin to std::list More...

#include <doubly_linked.h>

Collaboration diagram for dsac::list::DoublyLinkedList< T >:
Collaboration graph

Data Structures

class  const_iterator
 
class  iterator
 

Public Member Functions

 DoublyLinkedList ()
 Constructs an empty list.
 
int size () const
 
bool empty () const
 
T & front ()
 
const T & front () const
 
T & back ()
 
const T & back () const
 
void push_front (const T &elem)
 
void push_back (const T &elem)
 
void pop_front ()
 Removes the first element of the list.
 
void pop_back ()
 Removes the last element of the list.
 
iterator begin ()
 Returns iterator for the front of the list.
 
const_iterator begin () const
 Returns const_iterator for the front of the list.
 
iterator end ()
 Returns iterator for the end of the list.
 
const_iterator end () const
 Returns const_iterator for the end of the list.
 
iterator insert (iterator it, const T &elem)
 
iterator erase (iterator it)
 
void clear ()
 resets the list to empty
 
 DoublyLinkedList (const DoublyLinkedList &other)
 copy constructor
 
DoublyLinkedListoperator= (const DoublyLinkedList &other)
 copy assignment
 
 DoublyLinkedList (DoublyLinkedList &&other)
 move constructor
 
DoublyLinkedListoperator= (DoublyLinkedList &&other)
 move assignment
 
 ~DoublyLinkedList ()
 default destructor
 

Friends

void swap (DoublyLinkedList &a, DoublyLinkedList &b)
 non-member function to swap two lists
 

Detailed Description

template<typename T>
class dsac::list::DoublyLinkedList< T >

doubly linked list, akin to std::list

Constructor & Destructor Documentation

◆ DoublyLinkedList() [1/3]

template<typename T >
dsac::list::DoublyLinkedList< T >::DoublyLinkedList ( )
inline

Constructs an empty list.

◆ DoublyLinkedList() [2/3]

template<typename T >
dsac::list::DoublyLinkedList< T >::DoublyLinkedList ( const DoublyLinkedList< T > &  other)
inline

copy constructor

◆ DoublyLinkedList() [3/3]

template<typename T >
dsac::list::DoublyLinkedList< T >::DoublyLinkedList ( DoublyLinkedList< T > &&  other)
inline

move constructor

◆ ~DoublyLinkedList()

template<typename T >
dsac::list::DoublyLinkedList< T >::~DoublyLinkedList ( )
inline

default destructor

Here is the call graph for this function:

Member Function Documentation

◆ back() [1/2]

template<typename T >
T & dsac::list::DoublyLinkedList< T >::back ( )
inline

Returns live reference to the last element of the list; behavior undefined if list is empty

Returns
reference to last element of the list

◆ back() [2/2]

template<typename T >
const T & dsac::list::DoublyLinkedList< T >::back ( ) const
inline

Returns const reference to the last element of the list; behavior undefined if list is empty

Returns
reference to last element of the list

◆ begin() [1/2]

template<typename T >
iterator dsac::list::DoublyLinkedList< T >::begin ( )
inline

Returns iterator for the front of the list.

◆ begin() [2/2]

template<typename T >
const_iterator dsac::list::DoublyLinkedList< T >::begin ( ) const
inline

Returns const_iterator for the front of the list.

◆ clear()

template<typename T >
void dsac::list::DoublyLinkedList< T >::clear ( )
inline

resets the list to empty

Here is the call graph for this function:

◆ empty()

template<typename T >
bool dsac::list::DoublyLinkedList< T >::empty ( ) const
inline

Tests whether the list is empty.

Returns
true if the list is empty, false otherwise

◆ end() [1/2]

template<typename T >
iterator dsac::list::DoublyLinkedList< T >::end ( )
inline

Returns iterator for the end of the list.

◆ end() [2/2]

template<typename T >
const_iterator dsac::list::DoublyLinkedList< T >::end ( ) const
inline

Returns const_iterator for the end of the list.

◆ erase()

template<typename T >
iterator dsac::list::DoublyLinkedList< T >::erase ( iterator  it)
inline

Removes the element at the given position

Parameters
ititerator defining position
Returns
iterator of position just beyond the removed element

◆ front() [1/2]

template<typename T >
T & dsac::list::DoublyLinkedList< T >::front ( )
inline

Returns live reference to the first element of the list; behavior undefined if list is empty

Returns
reference to first element of the list

◆ front() [2/2]

template<typename T >
const T & dsac::list::DoublyLinkedList< T >::front ( ) const
inline

Returns const reference to the first element of the list; behavior undefined if list is empty

Returns
reference to first element of the list

◆ insert()

template<typename T >
iterator dsac::list::DoublyLinkedList< T >::insert ( iterator  it,
const T &  elem 
)
inline

Inserts new element immediately before the given position and returns iterator to new element

Parameters
ititerator defining position
elemelement to insert
Returns
iterator of newly inserted element

◆ operator=() [1/2]

template<typename T >
DoublyLinkedList & dsac::list::DoublyLinkedList< T >::operator= ( const DoublyLinkedList< T > &  other)
inline

copy assignment

Here is the call graph for this function:

◆ operator=() [2/2]

template<typename T >
DoublyLinkedList & dsac::list::DoublyLinkedList< T >::operator= ( DoublyLinkedList< T > &&  other)
inline

move assignment

◆ pop_back()

template<typename T >
void dsac::list::DoublyLinkedList< T >::pop_back ( )
inline

Removes the last element of the list.

◆ pop_front()

template<typename T >
void dsac::list::DoublyLinkedList< T >::pop_front ( )
inline

Removes the first element of the list.

◆ push_back()

template<typename T >
void dsac::list::DoublyLinkedList< T >::push_back ( const T &  elem)
inline

Inserts element at the end of the list

Parameters
elemthe new element

◆ push_front()

template<typename T >
void dsac::list::DoublyLinkedList< T >::push_front ( const T &  elem)
inline

Inserts element at the beginning of the list

Parameters
elemthe new element

◆ size()

template<typename T >
int dsac::list::DoublyLinkedList< T >::size ( ) const
inline

Returns the number of elements stored

Returns
the number of elements stored

Friends And Related Symbol Documentation

◆ swap

template<typename T >
void swap ( DoublyLinkedList< T > &  a,
DoublyLinkedList< T > &  b 
)
friend

non-member function to swap two lists


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