Indexed list container. More...
#include <kanzi/core/cpp/indexed_list.hpp>
Classes | |
| class | const_iterator |
| Const iterator over the values. More... | |
| class | element_type |
| Value type for internal container. More... | |
| class | iterator |
| Iterator over the values. More... | |
| class | IteratorBase |
| Base class for iterator and const_iterator. More... | |
| class | sorting_type |
| Sorting value type. More... | |
Public Member Functions | |
| T & | back () |
| Gets the last element. | |
| const T & | back () const |
| Gets the last element. | |
| iterator | begin () |
| Gets an iterator to the beginning. | |
| const_iterator | begin () const |
| Gets a const iterator to the beginning. | |
| const_iterator | cbegin () const |
| Gets a const iterator to the beginning. | |
| const_iterator | cend () const |
| Gets a const iterator to the end. | |
| void | clear () |
| Clear the list. | |
| bool | empty () const |
| Indicates whether or not the indexed list is empty. | |
| iterator | end () |
| Gets an iterator to the end. | |
| const_iterator | end () const |
| Gets a const iterator to the end. | |
| iterator | erase (const const_iterator &beginIt, const const_iterator &endIt) |
| Erases from a location to another location. | |
| iterator | erase (const const_iterator &it) |
| Erases an element at given location. | |
| T & | front () |
| Gets the first element. | |
| const T & | front () const |
| Gets the first element. | |
| vector< size_t > | getLocationInSortedOrder () const |
| Gets the locations in sorted order list. | |
| vector< size_t > | getSortedOrder () const |
| Gets the sorted order list. | |
| indexed_list ()=default | |
| Default constructor. | |
| indexed_list (const indexed_list &other) | |
| Copy constructor. | |
| indexed_list (indexed_list &&other) | |
| Move constructor. | |
| iterator | insert (const iterator &it, const T &value) |
| Inserts an element into an iterator. | |
| iterator | insert (const iterator &it, T &&value) |
| Inserts an element into an iterator. | |
| indexed_list & | operator= (const indexed_list &other) |
| Copy operator. | |
| indexed_list & | operator= (indexed_list &&other) |
| Move operator. | |
| element_type & | operator[] (size_t index) |
| Access operator. | |
| const element_type & | operator[] (size_t index) const |
| Access operator (const). | |
| void | push_back (const T &value) |
| Pushes an element to the end of the list. | |
| void | push_back (T &&value) |
| Pushes an element to the end of the list. | |
| void | resetSortedOrder () |
| Reset the sorting order to input order. | |
| size_t | size () const |
| Gets the number of elements. | |
| vector< sorting_type >::iterator | sortingBegin () |
| Gets an iterator to the beginning of the sorting order. | |
| vector< sorting_type >::iterator | sortingEnd () |
| Gets an iterator to the end of the sorting order. | |
| ~indexed_list ()=default | |
| Destructor. | |
Static Public Attributes | |
| static const size_t | InvalidIndex |
| Invalid index to be used across the class. | |
Protected Member Functions | |
| void | addNewSortedOrderIndex (size_t newIndex) |
| Function ran when new index is added to the sorted order. | |
| void | fixSortedOrderHostReferences () |
| Fix host pointers in sorted order. | |
| void | maintainListOrderOnElementErased (size_t index) |
| Maintain list order when given element is erased. | |
| void | maintainListOrderOnNewIndex (element_type &element, size_t oldIndex, size_t newIndex) |
| Maintain list order when given element gets a new index. | |
| void | onNewElementInsertedToBack (size_t newIndex) |
| Function ran when new element was inserted to the back of the list. | |
| void | removeElement (size_t index) |
| Function ran when a given element is erased, and the last element needs swapping in. | |
| void | removeLastElement () |
| Function ran when the last element in the element array is removed. | |
| void | removeSortedOrderIndex (size_t index) |
| Maintain sorted order on given index getting erased. | |
Protected Attributes | |
| vector< element_type > | m_elements |
| Container for actual values. | |
| size_t | m_first |
| Index of the first allocated element. | |
| size_t | m_last |
| Index of the last allocated element. | |
| vector< sorting_type > | m_sortedOrder |
| Sorted order (indices). | |
Indexed list container.
indexed_list provides access to a container where elements can be accessed using an index, but element order is arbitrary.
The container provides:
|
explicitdefault |
Default constructor.
|
default |
Destructor.
|
inline |
Copy constructor.
| other | Other object. |
|
inline |
Move constructor.
| other | Other object. |
|
inline |
Copy operator.
| other | Other object. |
|
inline |
Move operator.
| other | Other object. |
|
inline |
Gets an iterator to the beginning.
|
inline |
Gets a const iterator to the beginning.
|
inline |
Gets a const iterator to the beginning.
|
inline |
Gets an iterator to the end.
|
inline |
Gets a const iterator to the end.
|
inline |
Gets a const iterator to the end.
|
inline |
Gets an iterator to the beginning of the sorting order.
|
inline |
Gets an iterator to the end of the sorting order.
|
inline |
Gets the first element.
Gets the first element.
|
inline |
Gets the last element.
Gets the last element.
|
inline |
Clear the list.
Inserts an element into an iterator.
| it | Iterator location. |
| value | Value to insert. |
Inserts an element into an iterator.
| it | Iterator location. |
| value | Value to insert. |
|
inline |
Erases an element at given location.
| it | Iterator location. |
|
inline |
Erases from a location to another location.
| beginIt | Beginning iterator to start removal from. |
| endIt | Iterator to stop removal at (not erased). |
Pushes an element to the end of the list.
| value | Value to push. |
Pushes an element to the end of the list.
| value | Value to push. |
|
inline |
Indicates whether or not the indexed list is empty.
|
inline |
Gets the number of elements.
|
inline |
Gets the sorted order list.
This function is intended for tests.
|
inline |
Gets the locations in sorted order list.
This function is intended for tests.
|
inline |
Reset the sorting order to input order.
|
inlineprotected |
Fix host pointers in sorted order.
|
inlineprotected |
Function ran when new element was inserted to the back of the list.
| newIndex | New index added to the sorted order. |
|
inlineprotected |
Function ran when new index is added to the sorted order.
| newIndex | New index to add to the sorted order. |
|
inlineprotected |
Maintain list order when given element is erased.
| index | List element about to get erased. |
|
inlineprotected |
Maintain list order when given element gets a new index.
| element | Element to modify. |
| oldIndex | Old index the element previously was in. |
| newIndex | New index the element was swapped in to. |
|
inlineprotected |
Maintain sorted order on given index getting erased.
| index | Index getting removed. |
|
inlineprotected |
Function ran when the last element in the element array is removed.
|
inlineprotected |
Function ran when a given element is erased, and the last element needs swapping in.
| index | Index to remove. |
|
inline |
Access operator.
| index | Index to access. |
|
inline |
Access operator (const).
| index | Index to access. |
|
static |
Invalid index to be used across the class.
|
protected |
Container for actual values.
|
protected |
Index of the first allocated element.
|
protected |
Index of the last allocated element.
|
protected |
Sorted order (indices).