template<typename Key, typename Value>
class pw::DynamicMap< Key, Value >
Dynamic ordered map, similar to std::map, but optimized for embedded.
Key features of pw::DynamicMap.
- Uses a
pw::Allocator for memory operations for each node.
- Provides a
std::map-like API, but adds try_* versions of operations that return std::nullopt on allocation failure.
- Never allocates in the constructor.
constexpr constructible.
- Leverages
pw::IntrusiveMap internally to manage the balanced tree structure without additional per-node overhead beyond the user data and tree pointers.
|
| constexpr | DynamicMap (Allocator &allocator) noexcept |
| |
| | DynamicMap (const DynamicMap &)=delete |
| |
|
DynamicMap & | operator= (const DynamicMap &)=delete |
| |
| | DynamicMap (DynamicMap &&other) noexcept |
| |
| DynamicMap & | operator= (DynamicMap &&other) noexcept |
| |
|
constexpr allocator_type & | get_allocator () const |
| | Returns the allocator used by this map.
|
| |
|
iterator | begin () noexcept |
| |
|
const_iterator | begin () const noexcept |
| |
|
const_iterator | cbegin () const noexcept |
| |
|
iterator | end () noexcept |
| |
|
const_iterator | end () const noexcept |
| |
|
const_iterator | cend () const noexcept |
| |
|
reverse_iterator | rbegin () noexcept |
| |
|
const_reverse_iterator | rbegin () const noexcept |
| |
|
const_reverse_iterator | crbegin () const noexcept |
| |
|
reverse_iterator | rend () noexcept |
| |
|
const_reverse_iterator | rend () const noexcept |
| |
|
const_reverse_iterator | crend () const noexcept |
| |
| mapped_type & | at (const key_type &key) |
| |
|
const mapped_type & | at (const key_type &key) const |
| |
| template<typename U = mapped_type, typename = std::enable_if_t<std::is_default_constructible_v<U>>> |
| mapped_type & | operator[] (const key_type &key) |
| |
|
bool | empty () const |
| |
|
size_type | size () const |
| |
|
constexpr size_type | max_size () const noexcept |
| |
|
void | clear () |
| | Removes all elements from the map and deallocates each node.
|
| |
| std::optional< std::pair< iterator, bool > > | try_insert (const value_type &value) |
| |
|
std::optional< std::pair< iterator, bool > > | try_insert (value_type &&)=delete |
| |
|
std::pair< iterator, bool > | insert (const value_type &value) |
| | Inserts a value into the map. Crashes on allocation failure.
|
| |
|
std::pair< iterator, bool > | insert (value_type &&value) |
| |
|
template<typename InputIt , typename = containers::internal::EnableIfInputIterator<InputIt>> |
| void | insert (InputIt first, InputIt last) |
| | Inserts a range of elements. Crashes on allocation failure.
|
| |
|
void | insert (std::initializer_list< value_type > ilist) |
| |
| insert_return_type | insert (UniquePtr< node_type > &&node) |
| |
| template<typename K , typename... Args> |
| std::optional< std::pair< iterator, bool > > | try_emplace (K &&key, Args &&... args) |
| |
|
template<typename K , typename... Args> |
| std::pair< iterator, bool > | emplace (K &&key, Args &&... args) |
| | Constructs an element in-place. Crashes on allocation failure.
|
| |
|
iterator | erase (iterator pos) |
| | Removes the element at pos and deallocates the node.
|
| |
|
iterator | erase (const_iterator pos) |
| |
|
iterator | erase (iterator first, iterator last) |
| | Removes elements in the range [first, last).
|
| |
| template<typename K > |
| size_type | erase (K &&key) |
| |
|
UniquePtr< node_type > | take (iterator pos) |
| | Removes the element at pos and returns it as a UniquePtr.
|
| |
|
UniquePtr< node_type > | take (const_iterator pos) |
| |
|
template<typename K > |
| UniquePtr< node_type > | take (K &&key) |
| | Removes the element with matching key and returns it as a UniquePtr.
|
| |
|
void | swap (DynamicMap &other) |
| | Swaps the contents and allocators of two maps. No allocations occur.
|
| |
| void | merge (DynamicMap &other) |
| |
|
void | merge (DynamicMap &&other) |
| |
|
size_type | count (const key_type &key) |
| |
|
iterator | find (const key_type &key) |
| |
|
const_iterator | find (const key_type &key) const |
| |
|
bool | contains (const key_type &key) const |
| |
|
std::pair< iterator, iterator > | equal_range (const key_type &key) |
| |
|
std::pair< const_iterator, const_iterator > | equal_range (const key_type &key) const |
| |
|
iterator | lower_bound (const key_type &key) |
| |
|
const_iterator | lower_bound (const key_type &key) const |
| |
|
iterator | upper_bound (const key_type &key) |
| |
|
const_iterator | upper_bound (const key_type &key) const |
| |