|
CoreComponents 3.0.0
A Modern C++ Toolkit
|
Set data container More...
#include <cc/Set>
Public Types | |
| using | Item = T |
| Item type. | |
| using | Order = O |
| Search order. | |
Standard Iterators | |
| 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 | const_reverse_iterator = ReverseIterator<const BucketVector<Item>> |
| Readonly reverse value iterator. | |
| 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 | |
| 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 | |
Construction and Assignment | |
| Set ()=default | |
| Construct an empty set. | |
| Set (const Set &other)=default | |
| Construct a copy of other. | |
| Set (std::initializer_list< Item > items) | |
| Construct with initial items. | |
| Set (Set &&other) | |
| Take over the right-side set other. | |
| Set & | operator= (const Set &other)=default |
| Assign set other. | |
| Set & | operator= (Set &&other) |
| Take over the right-side set other. | |
| List< Item > | toList () const |
| Get corresponding list representation. | |
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 set. | |
| long | size () const |
| Get the number of items stored in the set. | |
| operator bool () const | |
| Check if this set is non-empty. | |
| long | operator+ () const |
| Get the number of items stored in the set. | |
| bool | has (long index) const |
| Check if index is valid. | |
| const Item & | at (Locator pos) const |
| Get constant reference to the item at position pos. | |
| const Item & | at (long index) const |
| Get constant references to the item at index. | |
| Item & | at (Locator pos) |
| Get to the item at position pos. | |
| Item & | at (long index) |
| Get references to the item at index. | |
| const Item & | operator[] (long index) const |
| Get constant references to the item at index. | |
| 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. | |
| const Item & | min () const |
| Get constant reference to the first item. | |
| const Item & | max () const |
| Get constant reference to the last item. | |
Set Operations | |
| template<class Pattern = Item> | |
| bool | find (const Pattern &pattern, Out< Locator > pos=None{}) const |
| Search for a matching key in the set. | |
| template<class Pattern = Item> | |
| bool | lookup (const Pattern &pattern, Out< Item > item) const |
| Search for key and return item. | |
| template<class Pattern = Item> | |
| bool | contains (const Pattern &pattern) const |
| Convenience function to check if the set contains key. | |
| template<class Pattern > | |
| Locator | lowerBound (const Pattern &pattern) const |
| Convenience function to find the start of a search range. | |
| template<class Pattern > | |
| Locator | upperBound (const Pattern &pattern) const |
| Convenience function to find the end of a search range. | |
| bool | insert (const Item &item, Out< Locator > pos=None{}) |
| Insert a new item to the set. | |
| void | establish (const Item &item) |
| Insert an item to the set replacing any pre-existing same value item. | |
| template<class Key = Item> | |
| bool | remove (const Key &key) |
| Remove an item from the set. | |
| Set & | operator<< (const Item &item) |
| Insert item to the set. | |
| Set & | operator>> (Item &item) |
| Get and remove the smallest item. | |
Positional Operations | |
| void | removeAt (Locator &pos) |
| Remove item at position pos (and advance pos to the next item) | |
| void | removeAt (long index) |
| Remove item at index. | |
Global Operations | |
| template<class F > | |
| void | forEach (F f) const |
| Call function f for each item. | |
| template<class F > | |
| void | forEachInRange (const Item &lower, const Item &upper, F f) const |
| Call function f for each item in range [lower, upper]. | |
| void | deplete () |
| Remove all items. | |
Comparism Operators | |
| template<class Other > | |
| bool | operator== (const Other &other) const |
| Equality operator. | |
Set data container
| T | Item type |
| O | Search order |
| using Item = T |
Item type.
| using Order = O |
Search order.
| 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 const_reverse_iterator = ReverseIterator<const BucketVector<Item>> |
Readonly reverse value iterator.
|
default |
Construct an empty set.
Construct a copy of other.
Construct with initial items.
Take over the right-side set other.
Assign set other.
Take over the right-side set other.
Get corresponding list representation.
| 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 set.
| long size | ( | ) | const |
Get the number of items stored in the set.
|
explicit |
Check if this set is non-empty.
| long operator+ | ( | ) | const |
Get the number of items stored in the set.
| bool has | ( | long | index | ) | const |
Check if index is valid.
Get constant reference to the item at position pos.
| const Item & at | ( | long | index | ) | const |
Get constant references to the item at index.
Get to the item at position pos.
| Item & at | ( | long | index | ) |
Get references to the item at index.
| const Item & operator[] | ( | long | index | ) | const |
Get constant references to the item at index.
| 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.
| const Item & min | ( | ) | const |
Get constant reference to the first item.
| const Item & max | ( | ) | const |
Get constant reference to the last item.
| bool find | ( | const Pattern & | pattern, |
| Out< Locator > | pos = None{} ) const |
Search for a matching key in the set.
| Pattern | Pattern type (must be comparable with Key) |
| pattern | Pattern to search for |
| pos | Returns the position of the item that was found |
| bool lookup | ( | const Pattern & | pattern, |
| Out< Item > | item ) const |
Search for key and return item.
| Pattern | Pattern type (must be comparable with Key) |
| pattern | Pattern to search for |
| item | Returns the item found (if any) |
| bool contains | ( | const Pattern & | pattern | ) | const |
Convenience function to check if the set contains key.
| Pattern | Pattern type (must be comparable with Key) |
| pattern | Pattern to search for |
| Locator lowerBound | ( | const Pattern & | pattern | ) | const |
Convenience function to find the start of a search range.
| Pattern | Pattern type (must be comparable with Key) |
| pattern | Pattern to search for |
| Locator upperBound | ( | const Pattern & | pattern | ) | const |
Convenience function to find the end of a search range.
| Pattern | Pattern type (must be comparable with Key) |
| pattern | Pattern to search for |
| bool insert | ( | const Item & | item, |
| Out< Locator > | pos = None{} ) |
Insert a new item to the set.
| item | Item to add |
| pos | Returns a locator pointing to the existing or newly inserted item |
| void establish | ( | const Item & | item | ) |
Insert an item to the set replacing any pre-existing same value item.
| item | Item to add |
| bool remove | ( | const Key & | key | ) |
Remove an item from the set.
| Key | Search pattern type |
| key | Key to search for |
Insert item to the set.
Get and remove the smallest item.
| void removeAt | ( | Locator & | pos | ) |
Remove item at position pos (and advance pos to the next item)
| void removeAt | ( | long | index | ) |
Remove item at index.
| 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 forEachInRange | ( | const Item & | lower, |
| const Item & | upper, | ||
| F | f ) const |
Call function f for each item in range [lower, upper].
| F | Function type (lambda or functor) |
| lower | Lower boundary |
| upper | Upper boundary |
| f | Unary function which gets called for each item |
| void deplete | ( | ) |
Remove all items.
| 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
| 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