|
Nui
|
This container associates items with an id and allows for individual items to be "selected", which removes them from the container and stores them in a separate container. More...
#include <selectables_registry.hpp>
Classes | |
| class | ConstIterator |
| struct | ItemWithId |
| Wrapper around items that associates them with an id. More... | |
| class | Iterator |
| class | IteratorBase |
| Iterator that ignores items that are selected. More... | |
| struct | RawRangeWrap |
| struct | SelectionResult |
Public Types | |
| using | IdType = std::size_t |
| Id type used to identify items. | |
| using | ItemContainerType = std::vector< ItemWithId > |
| Type of the container that stores the items. | |
| using | IteratorType = Iterator< typename ItemContainerType::iterator > |
| using | ConstIteratorType = ConstIterator< typename ItemContainerType::const_iterator > |
Public Member Functions | |
| SelectablesRegistry ()=default | |
| SelectablesRegistry (const SelectablesRegistry &)=default | |
| SelectablesRegistry (SelectablesRegistry &&)=default | |
| SelectablesRegistry & | operator= (const SelectablesRegistry &)=default |
| SelectablesRegistry & | operator= (SelectablesRegistry &&)=default |
| ~SelectablesRegistry ()=default | |
| IdType | append (T const &element) |
| Append an item to the container. | |
| IdType | append (T &&element) |
| Append an item to the container. | |
| template<typename... Args> | |
| IdType | emplace (Args &&... args) |
| Emplace an item to the container. | |
| IteratorType | erase (IdType id) |
| Erase/Remove an item from the container. | |
| std::optional< T > | pop (IdType id) |
| Erase/Remove an item from the container and return it. | |
| SelectionResult | select (IdType id) |
| Select an item. | |
| std::size_t | deselectAll (std::invocable< ItemWithId const & > auto const &callback) |
| Deselects all items. | |
| bool | deselect (IdType id, std::invocable< ItemWithId const & > auto const &callback) |
| Deselects item with id. | |
| void | clear () |
| IteratorType | get (IdType id) |
| Get iterator to item with id. | |
| ConstIteratorType | get (IdType id) const |
| Get iterator to item with id. | |
| auto const & | operator[] (IdType id) const |
| Returns item by id. | |
| auto & | operator[] (IdType id) |
| Returns item by id. | |
| IteratorType | begin () |
| Returns iterator to first unselected item or end. | |
| ConstIteratorType | begin () const |
| Returns iterator to first unselected item or end. | |
| ConstIteratorType | cbegin () const |
| Returns iterator to first unselected item or end. | |
| IteratorType | end () |
| Returns end iterator. | |
| ConstIteratorType | end () const |
| Returns end iterator. | |
| ConstIteratorType | cend () const |
| Returns end iterator. | |
| bool | empty () const |
| Returns whether the container is empty. | |
| std::size_t | size () const |
| Returns the amount of items in the container. | |
| ItemContainerType::iterator | rawBegin () |
| Returns an iterator to the underlying container. | |
| ItemContainerType::iterator | rawEnd () |
| Returns an iterator to the underlying container. | |
| ItemContainerType::const_iterator | rawBegin () const |
| Returns a const iterator to the underlying container. | |
| ItemContainerType::const_iterator | rawConstBegin () const |
| Returns a const iterator to the underlying container. | |
| ItemContainerType::const_iterator | rawEnd () const |
| Returns a const iterator to the underlying container. | |
| ItemContainerType::const_iterator | rawConstEnd () const |
| Returns a const iterator to the underlying container. | |
| RawRangeWrap< SelectablesRegistry< T > * > | rawRange () |
| Helper for range based for loops. | |
| RawRangeWrap< SelectablesRegistry< T > const * > | rawRange () const |
| Helper for range based for loops. | |
Static Public Attributes | |
| static constexpr auto | invalidId = std::numeric_limits<IdType>::max() |
| Invalid id value. | |
This container associates items with an id and allows for individual items to be "selected", which removes them from the container and stores them in a separate container.
This allows for efficient iteration over the selected items. Selected items can be reinserted into the container via deselect (or not when the deselect callback returns false).
| T | Type of the items to store. |
| using Nui::SelectablesRegistry< T >::ConstIteratorType = ConstIterator<typename ItemContainerType::const_iterator> |
| using Nui::SelectablesRegistry< T >::IdType = std::size_t |
Id type used to identify items.
| using Nui::SelectablesRegistry< T >::ItemContainerType = std::vector<ItemWithId> |
Type of the container that stores the items.
| using Nui::SelectablesRegistry< T >::IteratorType = Iterator<typename ItemContainerType::iterator> |
|
default |
|
default |
|
default |
|
default |
|
inline |
Append an item to the container.
| element | A new item to append. |
|
inline |
Append an item to the container.
| element | A new item to append. |
|
inline |
Returns iterator to first unselected item or end.
|
inline |
Returns iterator to first unselected item or end.
|
inline |
Returns iterator to first unselected item or end.
|
inline |
Returns end iterator.
|
inline |
|
inline |
Deselects item with id.
Will reinsert item when callback returns true.
| id | id of the item to deselect |
| callback | callback to execute on the item |
|
inline |
Deselects all items.
Will reinsert items when callback returns true.
| callback | callback to execute on each item. |
|
inline |
Emplace an item to the container.
| Args | Types of the arguments to forward to the constructor of the item. |
| args | Arguments to forward to the constructor of the item. |
|
inline |
Returns whether the container is empty.
|
inline |
Returns end iterator.
|
inline |
Returns end iterator.
|
inline |
Erase/Remove an item from the container.
| id | Id of the item to erase. |
|
inline |
Get iterator to item with id.
| id | Id of the item to get. |
|
inline |
Get iterator to item with id.
| id | Id of the item to get. |
|
default |
|
default |
|
inline |
Returns item by id.
| id | Id of the item to get. |
|
inline |
Returns item by id.
| id | Id of the item to get. |
|
inline |
Erase/Remove an item from the container and return it.
| id | Id of the item to get and erase. |
|
inline |
Returns an iterator to the underlying container.
|
inline |
Returns a const iterator to the underlying container.
|
inline |
Returns a const iterator to the underlying container.
|
inline |
Returns a const iterator to the underlying container.
|
inline |
Returns an iterator to the underlying container.
|
inline |
Returns a const iterator to the underlying container.
|
inline |
Helper for range based for loops.
|
inline |
Helper for range based for loops.
|
inline |
Select an item.
| id | The id of the item to select. |
|
inline |
Returns the amount of items in the container.
|
staticconstexpr |
Invalid id value.