List collection.
More...
#include <base/collection/List.h>
Inherits Collection.
template<class TYPE>
class List< TYPE >
List collection.
Linked list data structure. Use of List reduces copying of elements.
You can enumerate the elements of a list like this (myMember is a member function of MyClass):
while (enu.hasNext()) {
enu.next()->myMember();
}
- Examples
- testsuite/client.cpp, testsuite/echod.cpp, testsuite/ftp.cpp, testsuite/http.cpp, testsuite/List.cpp, and testsuite/server.cpp.
◆ Node
◆ Value
◆ List() [1/3]
Initializes an empty list.
◆ List() [2/3]
template<class TYPE >
List< TYPE >::List |
( |
std::initializer_list< TYPE > |
values | ) |
|
|
inline |
Initializes list from initializer list.
◆ List() [3/3]
Initializes list from other list.
◆ add() [1/2]
template<class TYPE >
void List< TYPE >::add |
( |
const TYPE & |
value | ) |
|
|
inline |
Appends the specified value to the end of this list.
- Parameters
-
value | The value to be appended to the list. |
◆ add() [2/2]
template<class TYPE >
void List< TYPE >::add |
( |
TYPE && |
value | ) |
|
|
inline |
Appends the specified value to the end of this list.
- Parameters
-
value | The value to be appended to the list. |
◆ append() [1/2]
template<class TYPE >
void List< TYPE >::append |
( |
const TYPE & |
value | ) |
|
|
inline |
Appends the specified value to the end of this list.
- Parameters
-
value | The value to be appended to the list. |
◆ append() [2/2]
template<class TYPE >
void List< TYPE >::append |
( |
TYPE && |
value | ) |
|
|
inline |
Appends the specified value to the end of this list.
- Parameters
-
value | The value to be appended to the list. |
◆ begin() [1/2]
◆ begin() [2/2]
◆ cbegin()
◆ cend()
◆ end() [1/2]
◆ end() [2/2]
◆ getEnumerator()
Returns a modifying enumerator of the list.
◆ getFirst() [1/2]
template<class TYPE >
TYPE& List< TYPE >::getFirst |
( |
| ) |
|
|
inline |
Returns the first element.
◆ getFirst() [2/2]
template<class TYPE >
const TYPE& List< TYPE >::getFirst |
( |
| ) |
const |
|
inline |
Returns the first element.
◆ getFirstNode() [1/2]
Returns the first node of the list.
◆ getFirstNode() [2/2]
template<class TYPE >
const Node* List< TYPE >::getFirstNode |
( |
| ) |
const |
|
inlineprotectednoexcept |
Returns the first node of the list.
◆ getLast() [1/2]
template<class TYPE >
TYPE& List< TYPE >::getLast |
( |
| ) |
|
|
inline |
Returns the last element.
◆ getLast() [2/2]
template<class TYPE >
const TYPE& List< TYPE >::getLast |
( |
| ) |
const |
|
inline |
Returns the last element.
◆ getLastNode() [1/2]
Returns the last node of the list.
◆ getLastNode() [2/2]
template<class TYPE >
const Node* List< TYPE >::getLastNode |
( |
| ) |
const |
|
inlineprotectednoexcept |
Returns the last node of the list.
◆ getReadEnumerator()
Returns a non-modifying enumerator of the list.
◆ getSize()
template<class TYPE >
MemorySize List< TYPE >::getSize |
( |
| ) |
const |
|
inlinenoexcept |
Returns the number of elements in the list.
◆ insert() [1/2]
template<class TYPE >
void List< TYPE >::insert |
( |
const Iterator & |
it, |
|
|
const TYPE & |
value |
|
) |
| |
|
inline |
Inserts the value before the specified position. If iterator is end iterator the value is inserted at the end.
- Parameters
-
it | Insert position. |
value | The value to be inserted. |
◆ insert() [2/2]
template<class TYPE >
void List< TYPE >::insert |
( |
const Iterator & |
it, |
|
|
TYPE && |
value |
|
) |
| |
|
inline |
Inserts the value before the specified position. If iterator is end iterator the value is inserted at the end.
- Parameters
-
it | Insert position. |
value | The value to be inserted. |
◆ isEmpty()
template<class TYPE >
bool List< TYPE >::isEmpty |
( |
| ) |
const |
|
inlinenoexcept |
Returns true if the list is empty.
◆ moveToBack()
Moves the value at the specified position to the back.
◆ moveToFront()
Moves the value at the specified position to the front.
◆ operator bool()
template<class TYPE >
List< TYPE >::operator bool |
( |
| ) |
const |
|
inlinenoexcept |
Returns true if not empty.
◆ operator!=()
template<class TYPE >
bool List< TYPE >::operator!= |
( |
const List< TYPE > & |
compare | ) |
const |
|
inline |
Returns true if not equal.
◆ operator<()
template<class TYPE >
bool List< TYPE >::operator< |
( |
const List< TYPE > & |
compare | ) |
const |
|
inline |
Returns true if less than.
◆ operator<<() [1/2]
template<class TYPE >
List& List< TYPE >::operator<< |
( |
const TYPE & |
value | ) |
|
|
inline |
◆ operator<<() [2/2]
template<class TYPE >
List& List< TYPE >::operator<< |
( |
TYPE && |
value | ) |
|
|
inline |
◆ operator=() [1/2]
Assignment of list by list.
◆ operator=() [2/2]
Assignment of list by list.
◆ operator==()
template<class TYPE >
bool List< TYPE >::operator== |
( |
const List< TYPE > & |
compare | ) |
const |
|
inline |
◆ operator>=()
template<class TYPE >
bool List< TYPE >::operator>= |
( |
const List< TYPE > & |
compare | ) |
const |
|
inline |
Returns true if greater than or equal.
◆ prepend() [1/2]
template<class TYPE >
void List< TYPE >::prepend |
( |
const TYPE & |
value | ) |
|
|
inline |
Prepends the value to the beginning of this list.
- Parameters
-
value | The value to be prepended to the list. |
◆ prepend() [2/2]
template<class TYPE >
void List< TYPE >::prepend |
( |
TYPE && |
value | ) |
|
|
inline |
Prepends the value to the beginning of this list.
- Parameters
-
value | The value to be prepended to the list. |
◆ remove()
Removes the node specified by the iterator from this list.
- Parameters
-
it | Iterator specifying the element to be removed. |
◆ removeAll()
template<class TYPE >
void List< TYPE >::removeAll |
( |
| ) |
|
|
inline |
Removes all the elements from this list.
◆ removeFirst()
template<class TYPE >
void List< TYPE >::removeFirst |
( |
| ) |
|
|
inline |
Removes this first node of this list.
◆ removeLast()
template<class TYPE >
void List< TYPE >::removeLast |
( |
| ) |
|
|
inline |
Removes the last node of this list.
◆ shuffle()
template<class TYPE >
void List< TYPE >::shuffle |
Shuffles elements. See https ://en.wikipedia.org/wiki/FisherE2%80%93Yates_shuffle::Modern_method.
Uses temporary buffer but avoid copy construction of values.
◆ sort() [1/2]
template<class TYPE >
void List< TYPE >::sort |
( |
| ) |
|
|
inline |
Sorts the elements of this list. Requires operator<= for TYPE.
◆ sort() [2/2]
template<class TYPE >
template<class PREDICATE >
void List< TYPE >::sort |
( |
PREDICATE |
predicate | ) |
|
|
inline |
◆ operator<<()
Writes a string representation of a list to a format stream.
◆ elements
The elements of the list.