list is the base class implementing a double linked list. It cannot be instantiated on it's own since it's missing the mechanism for allocating / freeing nodes. The list also maintains an internal pointer that can be used for walking through the list or removing elements.
More...
#include <ds_types_list.h>
|
| list () |
| Creates a list object and initializes it to an empty linked list.
|
|
| list (const list &rhs)=delete |
|
void | clear (void) |
| Clears all the elements of a list and frees them.
|
|
size_t | size (void) const |
| Returns the number of elements in the list.
|
|
bool | insertAtPos (const T &value, size_t pos) |
| Inserts an element at a specified position.
|
|
bool | insertFront (const T &value) |
| Inserts an element at the front of the list.
|
|
bool | append (const T &value) |
| Inserts an element at the end of the list.
|
|
bool | insertOrdered (const T &value, const lambda< bool(const T &left, const T &right)> &compare_fn) |
| Performs an ordered inserts of an element in the list.
|
|
void | removeCurrent (bool move_to_next) |
| Removes the element pointer to by the internal pointer.
|
|
void | removeAtPos (size_t pos) |
| Removes the element at the specified position.
|
|
bool | remove (const T &value) |
| Removes the first matched element.
|
|
T & | operator[] (size_t pos) |
| Access operator [].
|
|
T * | findElement (const T &value) |
| Searches for the first element matching the specified value.
|
|
int32_t | findIndex (const T &value) |
| Searches for the first element matching the specified value.
|
|
int32_t | findIndex (const lambda< bool(const T &item)> &equals) |
| Searches for the first element matching the specified value. Uses a lambda to perform the matching.
|
|
void | startFirst (void) |
| Initializes the internal element pointer to the first one in the list.
|
|
void | startLast (void) |
| Initializes the internal element pointer to the last one in the list.
|
|
void | goNext (void) |
| Advances the internal element pointer to the next one (going forward).
|
|
void | goPrevious (void) |
| Advances the internal element pointer to the previous one (going backward).
|
|
bool | valid (void) const |
| Is the internal element pointer valid?
|
|
T & | current (void) |
| Returns the element pointed by the internal pointer. If the internal pointer is not valid it will likely cause a crash.
|
|
|
virtual void | resetNodes (void)=0 |
|
virtual Node * | allocNode (void)=0 |
|
virtual void | freeNode (Node *node)=0 |
|
template<typename T>
class list< T >
list is the base class implementing a double linked list. It cannot be instantiated on it's own since it's missing the mechanism for allocating / freeing nodes. The list also maintains an internal pointer that can be used for walking through the list or removing elements.
◆ append()
template<typename T >
bool list< T >::append |
( |
const T & |
value | ) |
|
|
inline |
Inserts an element at the end of the list.
- Parameters
-
- Returns
- True if the insertion was successfull. False if there is no more memory available to allocate the new node.
◆ current()
template<typename T >
T & list< T >::current |
( |
void |
| ) |
|
|
inline |
Returns the element pointed by the internal pointer. If the internal pointer is not valid it will likely cause a crash.
- Returns
- Elemented pointed by the internal element pointer
◆ findElement()
template<typename T >
T * list< T >::findElement |
( |
const T & |
value | ) |
|
|
inline |
Searches for the first element matching the specified value.
- Parameters
-
value | Element to search for |
- Returns
- Reference T& to the element if found or reference to a nullptr if it does not exist
◆ findIndex() [1/2]
template<typename T >
int32_t list< T >::findIndex |
( |
const lambda< bool(const T &item)> & |
equals | ) |
|
|
inline |
Searches for the first element matching the specified value. Uses a lambda to perform the matching.
- Parameters
-
equals | Lambda that returns true if the element "item" is the one looking for |
- Returns
- Index of the element if found or -1 if the element was not found
◆ findIndex() [2/2]
template<typename T >
int32_t list< T >::findIndex |
( |
const T & |
value | ) |
|
|
inline |
Searches for the first element matching the specified value.
- Parameters
-
value | Element to search for |
- Returns
- Index of the element if found or -1 if the element was not found
◆ insertAtPos()
template<typename T >
bool list< T >::insertAtPos |
( |
const T & |
value, |
|
|
size_t |
pos |
|
) |
| |
|
inline |
Inserts an element at a specified position.
- Parameters
-
value | Element to insert |
pos | Position in the list |
- Returns
- True if the insertion was successfull. False if there is no more memory available to allocate the new node.
◆ insertFront()
template<typename T >
bool list< T >::insertFront |
( |
const T & |
value | ) |
|
|
inline |
Inserts an element at the front of the list.
- Parameters
-
- Returns
- True if the insertion was successfull. False if there is no more memory available to allocate the new node.
◆ insertOrdered()
template<typename T >
bool list< T >::insertOrdered |
( |
const T & |
value, |
|
|
const lambda< bool(const T &left, const T &right)> & |
compare_fn |
|
) |
| |
|
inline |
Performs an ordered inserts of an element in the list.
- Parameters
-
value | Element to insert |
compare_fn | A lambda that will return true if the elements (left, right) are in the correct order, or false if not |
- Returns
- True if the insertion was successfull. False if there is no more memory available to allocate the new node.
◆ operator[]()
template<typename T >
T & list< T >::operator[] |
( |
size_t |
pos | ) |
|
|
inline |
Access operator [].
- Parameters
-
pos | Index of the element to access |
- Returns
- Reference T& to the element at position "pos" or reference to a nullptr if the element does not exist
◆ remove()
template<typename T >
bool list< T >::remove |
( |
const T & |
value | ) |
|
|
inline |
Removes the first matched element.
The T type is required to have the operator==().
- Parameters
-
- Returns
- True if the element was found and removed, false otherwise
◆ removeAtPos()
template<typename T >
void list< T >::removeAtPos |
( |
size_t |
pos | ) |
|
|
inline |
Removes the element at the specified position.
- Parameters
-
pos | Position of the element to remove |
◆ removeCurrent()
template<typename T >
void list< T >::removeCurrent |
( |
bool |
move_to_next | ) |
|
|
inline |
Removes the element pointer to by the internal pointer.
- Parameters
-
move_to_next | True if the pointer should be moved to the next element after the removal. False if the pointer should be moved to the previous element after the removal. |
◆ size()
template<typename T >
size_t list< T >::size |
( |
void |
| ) |
const |
|
inline |
Returns the number of elements in the list.
- Returns
- Number of elements in the list
◆ valid()
template<typename T >
bool list< T >::valid |
( |
void |
| ) |
const |
|
inline |
Is the internal element pointer valid?
- Returns
- True if the internal pointer is pointing to an element in the list
The documentation for this class was generated from the following file: