|
CoreComponents 3.0.0
A Modern C++ Toolkit
|
List data container More...
#include <cc/List>
Public Types | |
| using | Item = T |
| Item type. | |
Standard Iterators | |
| using | value_type = Item |
| Item value type. | |
| using | size_type = long |
| Type of the container capacity. | |
| using | iterator = Iterator<BucketVector<Item>> |
| Value iterator. | |
| using | const_iterator = Iterator<const BucketVector<Item>> |
| Readonly value iterator. | |
| using | reverse_iterator = ReverseIterator<BucketVector<Item>> |
| Reverse value iterator. | |
| using | const_reverse_iterator = ReverseIterator<const BucketVector<Item>> |
| Readonly reverse value iterator. | |
| iterator | begin () |
| Return iterator pointing to the first item (if any) | |
| iterator | end () |
| Return iterator pointing behind the last item | |
| const_iterator | begin () const |
| Return readonly iterator pointing to the first item (if any) | |
| const_iterator | cbegin () const |
| Return readonly iterator pointing to the first item (if any) | |
| const_iterator | end () const |
| Return readonly iterator pointing behind the last item | |
| const_iterator | cend () const |
| Return readonly iterator pointing behind the last item | |
| reverse_iterator | rbegin () |
| Return reverse iterator pointing to the last item (if any) | |
| reverse_iterator | rend () |
| Return reverse iterator pointing before the first item | |
| const_reverse_iterator | rbegin () const |
| Return readonly reverse iterator pointing to the last item (if any) | |
| const_reverse_iterator | crbegin () const |
| Return readonly reverse iterator pointing to the last item (if any) | |
| const_reverse_iterator | rend () const |
| Return reverse iterator pointing before the first item | |
| const_reverse_iterator | crend () const |
| Return reverse iterator pointing before the first item | |
| using | Tree = BucketVector<Item> |
| const Tree & | tree () const |
Construction and Assignment | |
| List ()=default | |
| Construct an empty list. | |
| List (const List &other)=default | |
| Construct a copy of other. | |
| List (std::initializer_list< Item > items) | |
| Construct with initial items. | |
| List (std::initializer_list< List > lists) | |
| Initialize by joining initial lists. | |
| List (List &&other) | |
| Take over the right-side list other. | |
| List & | operator= (const List &other)=default |
| Assign list other. | |
| List & | operator= (List &&other) |
| Assign right-side list other. | |
Item Access | |
| Locator | head () const |
| Get a locator pointing to the first item. | |
| Locator | tail () const |
| Get a locator pointing to the last item. | |
| Locator | from (long index) const |
| Get a locator pointing to the item at index. | |
| long | count () const |
| Get the number of items stored in the list. | |
| long | size () const |
| Get the number of items stored in the list. | |
| bool | has (long i) const |
| Check if i is a valid index. | |
| operator bool () const | |
| Check if this list is non-empty. | |
| long | operator+ () const |
| Get the number of items stored in the list. | |
| const Item & | at (Locator pos) const |
| Get constant reference to the item at position pos. | |
| const Item & | at (long index) const |
| Get constant reference to the item at index. | |
| Item & | mutableAt (Locator pos) |
| Get reference to the item at position pos. | |
| Item & | mutableAt (long index) |
| Get reference to the item at index. | |
| const Item & | operator[] (long index) const |
| Get constant reference to the item at index. | |
| Item & | operator[] (long index) |
| Get reference to the item at index. | |
| Item | operator() (long index) const |
| Get value at index if 0 <= index && index < count(), otherwise return fallback. | |
| List & | operator() (long index, const T &value) |
| Set value at index if 0 <= i && i < count(), otherwise do nothing. | |
| const Item & | first () const |
| Get constant reference to first item. | |
| const Item & | last () const |
| Get constant reference to last item. | |
| bool | firstIs (const Item &item) const |
| Tell if item is the first item. | |
| bool | lastIs (const Item &item) const |
| Tell if item is the last item. | |
| Item & | touchFirst () |
| Get reference to first item. | |
| Item & | touchLast () |
| Get reference to last item. | |
Front and Back Operations | |
| void | append (const Item &item) |
| Insert item at the end of the list. | |
| void | prepend (const Item &item) |
| Insert item at the beginning of the list. | |
| template<class Item > | |
| void | appendList (const List< Item > &other) |
| Append a copy of list other. | |
| template<class Item > | |
| void | prependList (const List< Item > &other) |
| Prepend a copy of list other. | |
| void | pushBack (const Item &item) |
| Insert item as a new last item. | |
| void | pushFront (const Item &item) |
| Insert item as a new first item. | |
| void | popBack () |
| Remove the last item. | |
| void | popFront () |
| Remove the first item. | |
| template<class... Args> | |
| void | emplaceBack (Args... args) |
| Insert a new last item. | |
| template<class... Args> | |
| void | emplaceFront (Args... args) |
| Emplace a new first item. | |
| List & | operator<< (const Item &item) |
| Append item. | |
| List & | operator>> (Item &item) |
| Remove and return the first item. | |
Positional Operations | |
| void | insertAt (Locator &pos, const Item &item) |
| Insert item at position pos. | |
| void | insertAt (long index, const Item &item) |
| Insert item at index. | |
| void | removeAt (Locator &pos) |
| Remove item at position pos (and advance pos to the next item) | |
| void | removeAt (long index) |
| Remove item at index. | |
| template<class... Args> | |
| void | emplaceAt (Locator &pos, Args... args) |
| Create a new item at position pos (initialized with args) | |
| template<class... Args> | |
| void | emplaceAt (long index, Args... args) |
| Create a new item at index (initialized with args) | |
Global Operations | |
| template<class Pattern > | |
| bool | find (const Pattern &pattern, InOut< Locator > pos=None{}) const |
| Find item b. | |
| template<class Pattern > | |
| bool | contains (const Pattern &pattern) const |
| Convenience method. | |
| template<class Pattern > | |
| void | replace (const Pattern &pattern, const Item &substitute) |
| Replace all occurences of pattern by substitute. | |
| template<class Order = DefaultOrder> | |
| void | sort () |
| Sort the list in-situ. | |
| template<class Order = DefaultOrder> | |
| void | sortUnique () |
| Sorts the list and removes all doubles. | |
| List | sorted () const |
| Return a sorted copy of this list | |
| List | sortedUnique () const |
| Return a sorted copy of this list which does not contain repeated items | |
| void | reverse () |
| Reverse the order of items in the list | |
| List | reversed () const |
| Return a copy of the list in which the order of items is reversed | |
| template<class F > | |
| void | forEach (F f) const |
| Call function f for each item | |
| template<class F > | |
| void | forEach (F f) |
| Call function f for each item | |
| void | deplete () |
| Remove all items. | |
| template<class R = T, class S = T> | |
| R | join (S sep) const |
| Merge into a single item interspersed by sep. | |
| template<class R = T> | |
| R | join () const |
| Merge into a single item. | |
Comparism Operators | |
| template<class Other > | |
| bool | operator== (const Other &other) const |
| Equality operator. | |
| template<class Other > | |
| std::strong_ordering | operator<=> (const Other &other) const |
| Ordering operator. | |
List data container
| T | Item type |
| using Item = T |
Item type.
| using value_type = Item |
Item value type.
| using size_type = long |
Type of the container capacity.
| using const_iterator = Iterator<const BucketVector<Item>> |
Readonly value iterator.
| using reverse_iterator = ReverseIterator<BucketVector<Item>> |
Reverse value iterator.
| using const_reverse_iterator = ReverseIterator<const BucketVector<Item>> |
Readonly reverse value iterator.
|
default |
Construct an empty list.
Initialize by joining initial lists.
| Locator head | ( | ) | const |
Get a locator pointing to the first item.
| Locator tail | ( | ) | const |
Get a locator pointing to the last item.
| Locator from | ( | long | index | ) | const |
Get a locator pointing to the item at index.
| long count | ( | ) | const |
Get the number of items stored in the list.
| long size | ( | ) | const |
Get the number of items stored in the list.
| bool has | ( | long | i | ) | const |
Check if i is a valid index.
|
explicit |
Check if this list is non-empty.
| long operator+ | ( | ) | const |
Get the number of items stored in the list.
Get constant reference to the item at position pos.
| const Item & at | ( | long | index | ) | const |
Get constant reference to the item at index.
| Item & mutableAt | ( | long | index | ) |
Get reference to the item at index.
| const Item & operator[] | ( | long | index | ) | const |
Get constant reference to the item at index.
| Item & operator[] | ( | long | index | ) |
Get reference to the item at index.
| Item operator() | ( | long | index | ) | const |
Get value at index if 0 <= index && index < count(), otherwise return fallback.
| List & operator() | ( | long | index, |
| const T & | value ) |
| const Item & first | ( | ) | const |
Get constant reference to first item.
| const Item & last | ( | ) | const |
Get constant reference to last item.
| bool firstIs | ( | const Item & | item | ) | const |
Tell if item is the first item.
| bool lastIs | ( | const Item & | item | ) | const |
Tell if item is the last item.
| Item & touchFirst | ( | ) |
Get reference to first item.
| Item & touchLast | ( | ) |
Get reference to last item.
| void append | ( | const Item & | item | ) |
Insert item at the end of the list.
| void prepend | ( | const Item & | item | ) |
Insert item at the beginning of the list.
Append a copy of list other.
Prepend a copy of list other.
| void pushBack | ( | const Item & | item | ) |
Insert item as a new last item.
| void pushFront | ( | const Item & | item | ) |
Insert item as a new first item.
| void popBack | ( | ) |
Remove the last item.
| void popFront | ( | ) |
Remove the first item.
| void emplaceBack | ( | Args... | args | ) |
Insert a new last item.
| args | construction arguments |
| void emplaceFront | ( | Args... | args | ) |
Emplace a new first item.
| args | construction arguments |
| void insertAt | ( | long | index, |
| const Item & | item ) |
Insert item at index.
| void removeAt | ( | Locator & | pos | ) |
Remove item at position pos (and advance pos to the next item)
| void removeAt | ( | long | index | ) |
Remove item at index.
Create a new item at position pos (initialized with args)
| void emplaceAt | ( | long | index, |
| Args... | args ) |
Create a new item at index (initialized with args)
| void replace | ( | const Pattern & | pattern, |
| const Item & | substitute ) |
Replace all occurences of pattern by substitute.
| void sort | ( | ) |
Sort the list in-situ.
| Order | Sort ordering |
Sorts the list according the given sort ordering. The order of equal elements is preserved.
| void sortUnique | ( | ) |
Sorts the list and removes all doubles.
| Order | Sorting order |
Sorts the list of items according the given sorting order and removes all doubles thereafter.
| List sorted | ( | ) | const |
Return a sorted copy of this list
The order of equal elements is preserved.
| List sortedUnique | ( | ) | const |
Return a sorted copy of this list which does not contain repeated items
For repeated items only the first occurance is added to the sorted list.
| void reverse | ( | ) |
Reverse the order of items in the list
| List reversed | ( | ) | const |
Return a copy of the list in which the order of items is reversed
| void forEach | ( | F | f | ) | const |
Call function f for each item
| F | Function type (lambda or functor) |
| f | Unary function which gets called for each item |
| void forEach | ( | F | f | ) |
Call function f for each item
| F | Function type (lambda or functor) |
| f | Unary function which gets called for each item |
| void deplete | ( | ) |
Remove all items.
| R join | ( | S | sep | ) | const |
Merge into a single item interspersed by sep.
| R join | ( | ) | const |
Merge into a single item.
| iterator begin | ( | ) |
Return iterator pointing to the first item (if any)
| iterator end | ( | ) |
Return iterator pointing behind the last item
| const_iterator begin | ( | ) | const |
Return readonly iterator pointing to the first item (if any)
| const_iterator cbegin | ( | ) | const |
Return readonly iterator pointing to the first item (if any)
| const_iterator end | ( | ) | const |
Return readonly iterator pointing behind the last item
| const_iterator cend | ( | ) | const |
Return readonly iterator pointing behind the last item
| reverse_iterator rbegin | ( | ) |
Return reverse iterator pointing to the last item (if any)
| reverse_iterator rend | ( | ) |
Return reverse iterator pointing before the first item
| const_reverse_iterator rbegin | ( | ) | const |
Return readonly reverse iterator pointing to the last item (if any)
| const_reverse_iterator crbegin | ( | ) | const |
Return readonly reverse iterator pointing to the last item (if any)
| const_reverse_iterator rend | ( | ) | const |
Return reverse iterator pointing before the first item
| const_reverse_iterator crend | ( | ) | const |
Return reverse iterator pointing before the first item
Equality operator.