|
CPP-TOOLBOX
|
A wrapper around std::unordered_map that provides reactive signals for insertions and deletions. More...
#include <reactive_unordered_map.hpp>
Public Types | |
| using | key_type = Key |
| using | mapped_type = Value |
| using | value_type = std::pair<const Key, Value> |
| using | size_type = std::size_t |
| using | map_type = std::unordered_map<Key, Value, Hash, KeyEq> |
| using | iterator = typename map_type::iterator |
| using | const_iterator = typename map_type::const_iterator |
| using | map_signals = MapSignals<Key, Value> |
| using | inserted_signal = map_signals::Inserted |
| using | erased_signal = map_signals::Erased |
Public Member Functions | |
| ReactiveUnorderedMap ()=default | |
| bool | empty () const noexcept |
| size_type | size () const noexcept |
| void | reserve (size_type n) |
| iterator | begin () noexcept |
| iterator | end () noexcept |
| const_iterator | begin () const noexcept |
| const_iterator | end () const noexcept |
| iterator | find (const Key &k) |
| const_iterator | find (const Key &k) const |
| bool | contains (const Key &k) const |
| Value & | at (const Key &k) |
| const Value & | at (const Key &k) const |
| std::pair< iterator, bool > | insert_or_assign (const Key &key, Value &&value) |
| template<typename... Args> | |
| std::pair< iterator, bool > | try_emplace (const Key &key, Args &&...args) |
| template<class... Args> | |
| std::pair< iterator, bool > | emplace (Args &&...args) |
| runs the internal call and emits an inserted signal if succeeded | |
| Value & | operator[] (const Key &key) |
| size_type | erase (const Key &key) |
| runs the internal call and emits an erased signal if succeeded | |
| iterator | erase (iterator pos) |
| void | clear () noexcept |
| bool | update_if_exists (const Key &key, Value &&new_value) |
Public Attributes | |
| SignalEmitter | signal_emitter |
A wrapper around std::unordered_map that provides reactive signals for insertions and deletions.
@warn not all signals are being emitted in all functions, this is being developed on an "add as you need" basis
This class behaves like a standard unordered_map with additional capabilities:
inserted_signal: Emitted after a successful insertion (via emplace).erased_signal: Emitted after a successful erase.std::unordered_map, including:find, at, contains, operator[])begin, end)empty, size, reserve)insert_or_assign, try_emplace, emplace, erase, clear, update_if_exists)| Key | Type of the map's keys. |
| Value | Type of the map's values. |
| Hash | Hash function used for keys. Defaults to std::hash<Key>. |
| KeyEq | Key equality comparator. Defaults to std::equal_to<Key>. |
SignalEmitter. Connecting to these signals allows external code to react to map changes without directly modifying the map. | using ReactiveUnorderedMap< Key, Value, Hash, KeyEq >::const_iterator = typename map_type::const_iterator |
| using ReactiveUnorderedMap< Key, Value, Hash, KeyEq >::erased_signal = map_signals::Erased |
| using ReactiveUnorderedMap< Key, Value, Hash, KeyEq >::inserted_signal = map_signals::Inserted |
| using ReactiveUnorderedMap< Key, Value, Hash, KeyEq >::iterator = typename map_type::iterator |
| using ReactiveUnorderedMap< Key, Value, Hash, KeyEq >::key_type = Key |
| using ReactiveUnorderedMap< Key, Value, Hash, KeyEq >::map_signals = MapSignals<Key, Value> |
| using ReactiveUnorderedMap< Key, Value, Hash, KeyEq >::map_type = std::unordered_map<Key, Value, Hash, KeyEq> |
| using ReactiveUnorderedMap< Key, Value, Hash, KeyEq >::mapped_type = Value |
| using ReactiveUnorderedMap< Key, Value, Hash, KeyEq >::size_type = std::size_t |
| using ReactiveUnorderedMap< Key, Value, Hash, KeyEq >::value_type = std::pair<const Key, Value> |
|
default |
|
inline |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inline |
runs the internal call and emits an inserted signal if succeeded
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
runs the internal call and emits an erased signal if succeeded
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinenoexcept |
|
inline |
|
inline |
| SignalEmitter ReactiveUnorderedMap< Key, Value, Hash, KeyEq >::signal_emitter |