Data Structures & Algorithms in C++
Goodrich, Tamassia, Mount and Goldwasser
|
singly linked list, akin to std::forward_list More...
#include <singly_linked.h>
Data Structures | |
class | const_iterator |
class | iterator |
Public Member Functions | |
SinglyLinkedList () | |
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 | pop_front () |
Removes the first element of the list; behavior undefined if list is empty. | |
void | push_back (const T &elem) |
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_after (iterator it, const T &elem) |
iterator | erase_after (iterator it) |
void | clear () |
resets the list to empty | |
SinglyLinkedList (const SinglyLinkedList &other) | |
copy constructor | |
SinglyLinkedList & | operator= (const SinglyLinkedList &other) |
copy assignment | |
SinglyLinkedList (SinglyLinkedList &&other) | |
move constructor | |
SinglyLinkedList & | operator= (SinglyLinkedList &&other) |
move assignment | |
~SinglyLinkedList () | |
destructor | |
Friends | |
void | swap (SinglyLinkedList &a, SinglyLinkedList &b) |
non-member function to swap two lists | |
singly linked list, akin to std::forward_list
|
inline |
Constructs an empty list.
|
inline |
copy constructor
|
inline |
move constructor
|
inline |
destructor
|
inline |
Returns live reference to the last element of the list; behavior undefined if list is empty
|
inline |
Returns const reference to the last element of the list; behavior undefined if list is empty
|
inline |
Returns iterator for the front of the list.
|
inline |
Returns const_iterator for the front of the list.
|
inline |
resets the list to empty
|
inline |
Tests whether the list is empty.
|
inline |
Returns iterator for the end of the list.
|
inline |
Returns const_iterator for the end of the list.
|
inline |
Removes the element just after the given position
it | iterator defining position |
|
inline |
Returns live reference to the first element of the list; behavior undefined if list is empty
|
inline |
Returns const reference to the first element of the list; behavior undefined if list is empty
|
inline |
Inserts new element just after the given position
it | iterator defining position |
elem | element to insert |
|
inline |
copy assignment
|
inline |
move assignment
|
inline |
Removes the first element of the list; behavior undefined if list is empty.
|
inline |
Inserts element at the end of the list
elem | the new element |
|
inline |
Inserts element at the beginning of the list
elem | the new element |
|
inline |
Returns the number of elements stored
|
friend |
non-member function to swap two lists