|
DSA - Data Structures and Algorithms
|
Implements List using Node with pointer to adjacent elements as internal base. More...
#include <list.h>
Classes | |
| class | ListIterator |
| Implements ListIterator. More... | |
| class | Node |
| Implements Node template class with pointer to adjacent elements. More... | |
| class | NodeBase |
| Struct implements base pointer used by List. More... | |
Public Types | |
| using | value_type = T |
| Alias for data type used in class. | |
| using | pointer = T* |
| Alias for pointer to data type used in class. | |
| using | const_pointer = const T* |
| Alias for const pointer to data type used in class. | |
| using | reference = T& |
| Alias for reference to data type used in class. | |
| using | const_reference = const T& |
| Alias for const reference to data type used in class. | |
| using | const_iterator = ListIterator<true> |
| Alias for const iterator to data type used in class. | |
| using | iterator = ListIterator<false> |
| Alias for iterator to data type used in class. | |
Public Member Functions | |
| List () | |
| Construct a new List object. | |
| List (size_t count) | |
Construct a new List object of size count, using default value of type T. | |
| List (size_t count, const T &value) | |
Construct a new List object of size count, using provided value of type T. | |
| List (const std::initializer_list< T > &init_list) | |
| Construct a new List object using initializer list. | |
| List (const List< T > &other) | |
| Construct a new List object using copy constructor. | |
| auto | operator= (const List< T > &other) -> List & |
| Constructs List using copy assignment. | |
| List (List< T > &&other) noexcept | |
| Construct a new List object using move constructor. | |
| auto | operator= (List< T > &&other) noexcept -> List & |
| Assign List object using move assignment. | |
| ~List () | |
| Destroy the List object. | |
| void | assign (size_t count, const_reference value) |
| Function assign values to the List. | |
| void | assign (const std::initializer_list< T > &init_list) |
| Function assign values to the List. | |
| auto | front () -> reference |
| Function returns reference to value stored in List first Node. | |
| auto | front () const -> const_reference |
| Function returns const reference value stored in List first Node. | |
| auto | back () -> reference |
| Function returns reference to value stored in List last Node. | |
| auto | back () const -> const_reference |
| Function returns const reference value stored in List last Node. | |
| auto | begin () -> iterator |
| Function returns pointer to List first Node. | |
| auto | begin () const -> const_iterator |
| Function returns const pointer to List first Node. | |
| auto | cbegin () const -> const_iterator |
| Function returns const pointer to List first Node. | |
| auto | end () -> iterator |
| Function returns pointer to List last Node. | |
| auto | end () const -> const_iterator |
| Function returns pointer to List last Node. | |
| auto | cend () const -> const_iterator |
| Function returns pointer to List last Node. | |
| auto | empty () const -> bool |
| Function checks if container has no elements. | |
| auto | size () const -> size_t |
| Function returns List size. | |
| auto | max_size () const -> size_t |
| Function returns maximum number of elements container can hold. | |
| void | clear () |
| Function removes all elements of List. | |
| auto | insert (const const_iterator &pos, const_reference value) -> iterator |
Function inserts new Node before specified pos. | |
| auto | insert (const const_iterator &pos, size_t count, const_reference value) -> iterator |
Function inserts new Node before specified pos. | |
| auto | insert (const const_iterator &pos, std::initializer_list< T > init_list) -> iterator |
Function inserts new Node before specified pos. | |
| auto | erase (iterator pos) -> iterator |
Function erases Node object at specified pos. | |
| auto | erase (const_iterator pos) -> iterator |
Function erases Node object at specified pos. | |
| auto | erase (iterator first, iterator last) -> iterator |
| Function erases Node objects in range [first, last) | |
| auto | erase (const_iterator first, const_iterator last) -> iterator |
| Function erases Node objects in range [first, last) | |
| void | push_back (T value) |
| Function adds new Node at the end of List. | |
| void | pop_back () |
| Function removes last Node of List. | |
| void | push_front (T value) |
| Function adds new Node at the beginning of List. | |
| void | pop_front () |
| Function removes first Node of List. | |
| void | resize (size_t count) |
| Function resize List to specified number of elements. | |
| void | resize (size_t count, const_reference value) |
| Function resize List to specified number of elements. | |
| void | swap (List< T > &other) noexcept |
| Function swaps content of two List objects. | |
| void | merge (List< T > &other) |
| Function combines two sorted Lists into one sorted List. | |
| void | merge (List< T > &&other) |
| Function combines two sorted Lists into one sorted List. | |
| void | splice (const const_iterator &pos, List< T > &other) |
| Function moves elements from other List object. | |
| void | splice (const_iterator pos, List< T > &&other) |
| Function moves elements from other List object. | |
| void | splice (const const_iterator &pos, List< T > &other, const const_iterator &iter) |
| Function moves elements from other List object. | |
| void | splice (const_iterator pos, List< T > &&other, const_iterator iter) |
| Function moves elements from other List object. | |
| void | splice (const const_iterator &pos, List< T > &other, const const_iterator &first, const const_iterator &last) |
| Function moves elements in range [first, last) from other List object. | |
| void | splice (const_iterator pos, List< T > &&other, const_iterator first, const_iterator last) |
| Function moves elements in range [first, last) from other List object. | |
| void | remove (const_reference value) |
Function removes all elements equal to value. | |
| void | reverse () |
| Function reverts in place Nodes of List. | |
| void | unique () |
| Function removes consecutive duplicated elements. | |
| auto | operator+= (const List< T > &other) -> List< T > & |
| Append elements of another List to base container. | |
| auto | operator+= (const std::initializer_list< T > init_list) -> List< T > & |
| push_back elements of another List to base container | |
| auto | get (size_t index) const -> Node * |
| Function returns pointer to specific Node of List. | |
| auto | set (size_t index, T value) -> bool |
| Function sets value of specifed Node of List. | |
Friends | |
| auto | operator+ (const List< T > &list1, const List< T > &list2) -> List< T > |
| Construct new object based on two List objects. | |
Implements List using Node with pointer to adjacent elements as internal base.
add get_allocator
add rbegin
add crbegin
add rend
add crend
add emplace
add emplace_back
add emplace_front
add remove_if
add sort
add operator<=>
add non-member specialized swap function
add non-member specialized erase function
add non-member specialized erase_if function
remove public functions / operators not supported by std::forward_list
| using dsa::List< T >::const_iterator = ListIterator<true> |
| using dsa::List< T >::const_pointer = const T* |
| using dsa::List< T >::const_reference = const T& |
| using dsa::List< T >::iterator = ListIterator<false> |
| using dsa::List< T >::pointer = T* |
| using dsa::List< T >::reference = T& |
| using dsa::List< T >::value_type = T |
| dsa::List< T >::List | ( | ) |
| dsa::List< T >::List | ( | size_t | count | ) |
| dsa::List< T >::List | ( | size_t | count, |
| const T & | value ) |
Construct a new List object of size count, using provided value of type T.
| [in] | count | element count |
| [in] | value | value for all nodes |
Definition at line 1070 of file list.h.
| dsa::List< T >::List | ( | const std::initializer_list< T > & | init_list | ) |
Construct a new List object using initializer list.
| [in] | init_list | initializer list of values of type T |
Definition at line 1081 of file list.h.
Construct a new List object using copy constructor.
| [in] | other | List object of type T |
Definition at line 1090 of file list.h.
Construct a new List object using move constructor.
Content of other object will be taken by constructed object
| [in,out] | other | List object of type T |
Definition at line 1118 of file list.h.
| void dsa::List< T >::assign | ( | const std::initializer_list< T > & | init_list | ) |
| void dsa::List< T >::assign | ( | size_t | count, |
| const_reference | value ) |
Function returns reference to value stored in List last Node.
Definition at line 1183 of file list.h.
|
nodiscard |
Function returns const reference value stored in List last Node.
Definition at line 1189 of file list.h.
Function returns pointer to List first Node.
Definition at line 1195 of file list.h.
| auto dsa::List< T >::begin | ( | ) | const -> const_iterator |
Function returns const pointer to List first Node.
Definition at line 1201 of file list.h.
|
nodiscard |
Function returns const pointer to List first Node.
Definition at line 1207 of file list.h.
|
nodiscard |
| void dsa::List< T >::clear | ( | ) |
|
nodiscard |
| auto dsa::List< T >::end | ( | ) | const -> const_iterator |
Function returns pointer to List last Node.
| auto dsa::List< T >::erase | ( | const_iterator | first, |
| const_iterator | last ) -> iterator |
Function erases Node objects in range [first, last)
| [in] | first | element to erase |
| [in] | last | element after last erased element |
| iterator | to last |
| end | iterator if last was end element prior to removal |
| last | iterator if first to last is empty range |
| auto dsa::List< T >::erase | ( | const_iterator | pos | ) | -> iterator |
Function erases Node object at specified pos.
| [in] | pos | iterator to element to erase |
| iterator | to element following pos |
| begin | iterator if pos was first element prior to removal |
| end | iterator if pos was last element prior to removal |
Function erases Node objects in range [first, last)
| [in] | first | element to erase |
| [in] | last | element after last erased element |
| iterator | to last |
| end | iterator if last was end element prior to removal |
| last | iterator if first to p\ last is empty range |
Definition at line 1318 of file list.h.
Function erases Node object at specified pos.
| [in] | pos | iterator to element to erase |
| iterator | to element following pos |
| begin | iterator if pos was first element prior to removal |
| end | iterator if pos was last element prior to removal |
|
nodiscard |
Function returns const reference value stored in List first Node.
Definition at line 1177 of file list.h.
Function returns pointer to specific Node of List.
| [in] | index | index of element |
| Node* | if index is valid |
| nullptr | if invalid index |
Definition at line 1768 of file list.h.
| auto dsa::List< T >::insert | ( | const const_iterator & | pos, |
| const_reference | value ) -> iterator |
Function inserts new Node before specified pos.
| [in] | pos | const_iterator to insert element before |
| [in] | value | element of type T to be inserted before pos |
| iterator | to inserted value |
| pos | if no element was inserted |
Definition at line 1264 of file list.h.
| auto dsa::List< T >::insert | ( | const const_iterator & | pos, |
| size_t | count, | ||
| const_reference | value ) -> iterator |
Function inserts new Node before specified pos.
| [in] | pos | const_iterator to insert element before |
| [in] | count | number of elements to insert before pos |
| [in] | value | element of type T to be inserted |
| iterator | to inserted value |
| pos | if no element was inserted |
| auto dsa::List< T >::insert | ( | const const_iterator & | pos, |
| std::initializer_list< T > | init_list ) -> iterator |
Function inserts new Node before specified pos.
| [in] | pos | const_iterator to insert element before |
| [in] | init_list | initializer_list with elements to insert before pos |
| iterator | to first inserted element |
| pos | if no element was inserted |
|
nodiscard |
Function returns maximum number of elements container can hold.
Function combines two sorted Lists into one sorted List.
| [in,out] | other | container to take elements from |
Content of other object will be taken by constructed object
Definition at line 1481 of file list.h.
Function combines two sorted Lists into one sorted List.
| [in,out] | other | container to take elements from |
Content of other object will be taken by constructed object
Definition at line 1473 of file list.h.
| void dsa::List< T >::pop_back | ( | ) |
Function removes last Node of List.
Definition at line 1409 of file list.h.
| void dsa::List< T >::push_back | ( | T | value | ) |
Function adds new Node at the end of List.
| [in] | value | element of type T |
Definition at line 1385 of file list.h.
| void dsa::List< T >::push_front | ( | T | value | ) |
| void dsa::List< T >::remove | ( | const_reference | value | ) |
Function removes all elements equal to value.
| [in] | value | value of elements to remove |
Definition at line 1661 of file list.h.
| void dsa::List< T >::resize | ( | size_t | count | ) |
Function resize List to specified number of elements.
| [in] | count | new size of container |
Definition at line 1432 of file list.h.
| void dsa::List< T >::resize | ( | size_t | count, |
| const_reference | value ) |
Function resize List to specified number of elements.
| [in] | count | count new size of container |
| [in] | value | value to initialize new elements |
Definition at line 1438 of file list.h.
| void dsa::List< T >::reverse | ( | ) |
| auto dsa::List< T >::set | ( | size_t | index, |
| T | value ) -> bool |
|
nodiscard |
| void dsa::List< T >::splice | ( | const const_iterator & | pos, |
| List< T > & | other ) |
Function moves elements from other List object.
| [in] | pos | const_iterator before which content of other container will be inserted |
| [in,out] | other | container to take elements from |
Content of other object will be taken by constructed object
| void dsa::List< T >::splice | ( | const const_iterator & | pos, |
| List< T > & | other, | ||
| const const_iterator & | first, | ||
| const const_iterator & | last ) |
Function moves elements in range [first, last) from other List object.
| [in] | pos | const_iterator before which content of other container will be inserted |
| [in,out] | other | container to take elements from |
| [in] | first | const_iterator pointing to first element to move |
| [in] | last | const_iterator pointing to element after last taken element |
Content of other object will be taken by constructed object
| void dsa::List< T >::splice | ( | const const_iterator & | pos, |
| List< T > & | other, | ||
| const const_iterator & | iter ) |
Function moves elements from other List object.
| [in] | pos | const_iterator before which content of other container will be inserted |
| [in,out] | other | container to take elements from |
| [in] | iter | const_iterator pointing to element to move |
Content of other object will be taken by constructed object
| void dsa::List< T >::splice | ( | const_iterator | pos, |
| List< T > && | other ) |
Function moves elements from other List object.
| [in] | pos | const_iterator before which content of other container will be inserted |
| [in,out] | other | container to take elements from |
Content of other object will be taken by constructed object
| void dsa::List< T >::splice | ( | const_iterator | pos, |
| List< T > && | other, | ||
| const_iterator | first, | ||
| const_iterator | last ) |
Function moves elements in range [first, last) from other List object.
| [in] | pos | const_iterator before which content of other container will be inserted |
| [in,out] | other | container to take elements from |
| [in] | first | const_iterator pointing to first element to move |
| [in] | last | const_iterator pointing to element after last taken element |
Content of other object will be taken by constructed object
| void dsa::List< T >::splice | ( | const_iterator | pos, |
| List< T > && | other, | ||
| const_iterator | iter ) |
Function moves elements from other List object.
| [in] | pos | const_iterator before which content of other container will be inserted |
| [in,out] | other | container to take elements from |
| [in] | iter | const_iterator pointing to element to move |
Content of other object will be taken by constructed object
| void dsa::List< T >::unique | ( | ) |
Function removes consecutive duplicated elements.
Only the first occurrence of given element in each group is preserved
Definition at line 1724 of file list.h.
|
friend |