Containers
Atoms provide the following containers:
atoms::HandledSet
- container for storing a elements with automatically assigned identifier.
Classes reference
-
template<typename T>
class HandleSet std::vector-based set representation providing reusable integer handles for the inserted elements.
You are supposed to insert elements via HandleSet::insert(), which returns unique element handle. Then you can acces this element using HandleSet::operator[]() or erase it using HandleSet::erase(). The insertion is performed in amortized constant time, deletion and element access is performed in constant time.
Otherwise this container behaves the same as containers from the standard library.
Public Types
-
enum class handle_type : typename Container::size_type
Values:
-
using size_type = typename Container::size_type
-
using difference_type = typename Container::difference_type
-
using iterator = Iterator<false>
-
using const_iterator = Iterator<true>
Public Functions
-
inline bool empty() const
Check if the container has no elements.
-
inline void shrink_to_fit()
Request the removal of unused capacity.
-
inline void reserve(size_type newCapacity)
Increase capacity so it’s greater or equal to
newCapacity
-
inline void clear()
Erase all elements from the container.
-
template<typename ...Args>
inline handle_type emplace(Args&&... args) Emplace new element and get its handle.
-
inline handle_type insert(const T &value)
Insert new element and get its handle.
-
inline handle_type insert(T &&value)
Insert new element and get its handle.
-
inline void erase(handle_type handle)
Erase element based on its handle.
-
inline const_iterator begin() const noexcept
Return an iterator to the first element.
-
inline const_iterator cbegin() const noexcept
Return an iterator to the first element.
-
inline const_iterator end() const noexcept
Return the past-the-end iterator.
-
inline const_iterator cend() const noexcept
Return the past-the-end iterator.
-
inline const_reference operator[](handle_type handle) const
Access element based on its handle.
-
inline reference operator[](handle_type handle)
Access element based on its handle.
-
inline bool contains(handle_type handle) const
Check if the container contains element based on its handle.
-
inline iterator find(handle_type handle)
Return iterator to element based on its handle Returns past-the-end iterator if no such element exists.
-
inline const_iterator find(handle_type handle) const
Return iterator to element based on its handle Returns past-the-end iterator if no such element exists.
-
enum class handle_type : typename Container::size_type