|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Ordered map stored as two parallel sorted contiguous arrays. More...
#include <tpl_flat_map.H>
Classes | |
| class | basic_iterator |
Random-access proxy iterator over (key, value) entries. More... | |
Public Types | |
| using | Item_Type = std::pair< Key, T > |
| Aleph convention: element type. | |
| using | Key_Type = Key |
| Aleph convention: key type. | |
| using | key_type = Key |
| STL convention: key type. | |
| using | mapped_type = T |
| STL convention: mapped type. | |
| using | value_type = std::pair< Key, T > |
| STL convention: value type. | |
| using | key_compare = Compare |
| STL convention: comparator type. | |
| using | size_type = size_t |
| STL convention: size type. | |
| using | iterator = basic_iterator< false > |
| Mutable-value iterator. | |
| using | const_iterator = basic_iterator< true > |
| Const-value iterator. | |
Public Member Functions | |
| FlatMap (size_t cap=MemArray< Key >::Min_Dim) | |
| Construct an empty map. | |
| FlatMap (const Compare &cmp, size_t cap=MemArray< Key >::Min_Dim) | |
| Construct an empty map with a specific comparator. | |
| template<class It > requires requires(It first, It last, MemArray<Key> & ks, MemArray<T> & vs, const std::remove_reference_t<std::iter_reference_t<It>> & p) { static_cast<bool>(first != last); ++first; ks.put(p.first); vs.put(p.second); } | |
| FlatMap (It first, It last, const Compare &cmp=Compare()) | |
| Construct from an iterator range of pairs. | |
| FlatMap (std::initializer_list< std::pair< Key, T > > l, const Compare &cmp=Compare()) | |
| Construct from an initializer list of pairs. | |
| FlatMap (const FlatMap &)=default | |
Copy constructor (requires copyable Key and T). | |
| FlatMap (FlatMap &&) noexcept=default | |
| Move constructor. The source is left valid but unspecified. | |
| FlatMap & | operator= (const FlatMap &m) |
Copy assignment (requires copyable Key and T). | |
| FlatMap & | operator= (FlatMap &&) noexcept=default |
| Move assignment. The source is left valid but unspecified. | |
| ~FlatMap ()=default | |
| void | swap (FlatMap &m) noexcept(std::is_nothrow_swappable_v< Compare >) |
Swap contents with m in O(1). | |
| size_t | size () const noexcept |
| Return the number of stored entries. O(1). | |
| bool | is_empty () const noexcept |
Return true if the map holds no entries. O(1). | |
| size_t | capacity () const noexcept |
| Return the capacity of the backing key array. O(1). | |
| void | reserve (size_t cap) |
Reserve capacity for at least cap entries. | |
| void | empty () noexcept |
| Remove all entries (Aleph convention). | |
| void | clear () noexcept |
Remove all entries. Alias of empty(). Capacity is kept. | |
| iterator | find (const Key &k) |
Find the entry with key k. | |
| const_iterator | find (const Key &k) const |
See find(const Key & k). | |
| bool | contains (const Key &k) const |
Test whether key k is mapped. | |
| size_t | count (const Key &k) const |
Count entries with key k (0 or 1). | |
| iterator | lower_bound (const Key &k) |
First entry whose key is not less than k. | |
| const_iterator | lower_bound (const Key &k) const |
See lower_bound(const Key & k). | |
| iterator | upper_bound (const Key &k) |
First entry whose key is greater than k. | |
| const_iterator | upper_bound (const Key &k) const |
See upper_bound(const Key & k). | |
| std::pair< iterator, iterator > | equal_range (const Key &k) |
Range of entries with key equivalent to k. | |
| std::pair< const_iterator, const_iterator > | equal_range (const Key &k) const |
See equal_range(const Key & k). | |
| T & | at (const Key &k) |
Checked access to the value mapped to k. | |
| const T & | at (const Key &k) const |
See at(const Key & k). | |
| T & | operator[] (const Key &k) |
Access the value mapped to k, inserting a default if absent. | |
| T & | operator[] (Key &&k) |
Access the value mapped to k, inserting a default if absent. | |
| const Key & | nth_key (size_t i) const |
| Key of the i-th entry in sorted order (checked). | |
| T & | nth_value (size_t i) |
| Value of the i-th entry in sorted order (checked). | |
| const T & | nth_value (size_t i) const |
See nth_value(size_t i). | |
| std::pair< iterator, bool > | insert (const Key &k, const T &v) |
Insert (k, v) if k is not mapped. | |
| std::pair< iterator, bool > | insert (Key &&k, T &&v) |
See insert(const Key & k, const T & v); moving key and value. | |
| std::pair< iterator, bool > | insert (const std::pair< Key, T > &p) |
Insert a (key, value) pair if the key is not mapped. | |
| std::pair< iterator, bool > | insert (std::pair< Key, T > &&p) |
See insert(const std::pair<Key, T> & p); moving the pair. | |
| std::pair< iterator, bool > | insert_or_assign (const Key &k, const T &v) |
Insert (k, v) or overwrite the value if k is mapped. | |
| std::pair< iterator, bool > | insert_or_assign (Key &&k, T &&v) |
See insert_or_assign(const Key & k, const T & v); moving both. | |
| template<class... KArgs> | |
| std::pair< iterator, bool > | emplace (KArgs &&...kargs) |
Build a key from kargs and insert it with a default value. | |
| size_t | erase (const Key &k) |
Remove the entry with key k, if present. | |
| iterator | erase (const_iterator it) |
Remove the entry at iterator it. | |
| iterator | begin () noexcept |
| Iterator to the entry with the smallest key. O(1). | |
| iterator | end () noexcept |
| Iterator past the entry with the greatest key. O(1). | |
| const_iterator | begin () const noexcept |
| Const iterator to the entry with the smallest key. O(1). | |
| const_iterator | end () const noexcept |
| Const iterator past the entry with the greatest key. O(1). | |
| const_iterator | cbegin () const noexcept |
| Const iterator to the entry with the smallest key. O(1). | |
| const_iterator | cend () const noexcept |
| Const iterator past the entry with the greatest key. O(1). | |
| const Key * | keys_data () const noexcept |
| Pointer to the sorted, contiguous key storage. O(1). | |
| T * | values_data () noexcept |
| Pointer to the contiguous value storage (parallel to keys). O(1). | |
| const T * | values_data () const noexcept |
See values_data(). | |
| DynList< Key > | keys () const |
Copy all keys, in ascending order, into a DynList. | |
| DynList< T > | values () const |
Copy all values, in ascending key order, into a DynList. | |
| template<class Operation > | |
| bool | traverse (Operation operation) |
Traverse entries in key order while operation returns true. | |
| template<class Operation > | |
| bool | traverse (Operation operation) const |
Const traversal in key order while operation returns true. | |
| bool | operator== (const FlatMap &m) const |
| Equality: same size and pairwise equal keys and values. | |
| bool | operator!= (const FlatMap &m) const |
Inequality: negation of operator==. | |
Private Member Functions | |
| size_t | lower_idx (const Key &k) const |
| size_t | upper_idx (const Key &k) const |
| bool | match_at (size_t pos, const Key &k) const |
| template<class Op > | |
| void | keeping_invariants (Op &&op) |
| template<class U > | |
| void | grow_array (MemArray< U > &arr, const size_t cap) |
| void | grow_to (const size_t cap) |
| void | make_room (const size_t pos) |
| template<class K , class V > | |
| void | insert_at (const size_t pos, K &&k, V &&v) |
| void | drop_last () |
| void | remove_at (const size_t pos) |
| void | sort_and_unique () |
Static Private Member Functions | |
| template<class U > | |
| static void | relocate (MemArray< U > &arr, MemArray< U > &fresh) |
Private Attributes | |
| MemArray< Key > | keys_ |
| MemArray< T > | vals_ |
| Compare | cmp_ |
Static Private Attributes | |
| static constexpr bool | nothrow_relocation |
Ordered map stored as two parallel sorted contiguous arrays.
Keys live in a sorted MemArray<Key>; the value associated with keys[i] lives at values[i]. Lookups binary-search the key array only. Keys equivalent under Compare are unique.
| Key | Type of the keys. Must be default-constructible, move-constructible and move-assignable (from MemArray). |
| T | Type of the mapped values. Same base requirements. |
| Compare | Strict weak ordering over Key. Defaults to Aleph::less<Key>. |
*it is a lightweight object with public members first (a const Key &) and second (a T &, or const T & through const_iterator). Any insertion or removal invalidates all iterators.Array), empty() clears the container and is_empty() is the emptiness predicate.Key and T can be move-constructed and move-assigned without throwing, insert, insert_or_assign, emplace, operator[] and reserve offer the strong guarantee: the arguments are copied before the arrays change, so the only possible failure afterwards is an allocation that leaves the entries untouched. erase then always removes the entry; a failed shrinking reallocation is ignored.If moving a key or a value can throw, an exception thrown while entries are shifted or relocated would leave a moved-from or duplicated entry. The map is then emptied, which restores its invariants as std::flat_map does, and the exception is rethrown: the guarantee is basic. This applies to the operations above and to erase.
A failed allocation or a capacity out of range is not such an exception: the insertions and reserve obtain the new buffers before they move any entry, so the map keeps its contents whatever the types. This does not hold for erase when moving can throw: there a shrinking reallocation that fails cannot be told apart from a move that throws, and it empties the map as well.
Copy assignment offers the strong guarantee for every type.
m.insert(k, m.at(j)): the value it has on entry is the one stored, also when the insertion reallocates.Definition at line 150 of file tpl_flat_map.H.
| using Aleph::FlatMap< Key, T, Compare >::const_iterator = basic_iterator<true> |
Const-value iterator.
Definition at line 583 of file tpl_flat_map.H.
| using Aleph::FlatMap< Key, T, Compare >::Item_Type = std::pair<Key, T> |
Aleph convention: element type.
Definition at line 389 of file tpl_flat_map.H.
| using Aleph::FlatMap< Key, T, Compare >::iterator = basic_iterator<false> |
Mutable-value iterator.
Definition at line 582 of file tpl_flat_map.H.
| using Aleph::FlatMap< Key, T, Compare >::key_compare = Compare |
STL convention: comparator type.
Definition at line 394 of file tpl_flat_map.H.
| using Aleph::FlatMap< Key, T, Compare >::Key_Type = Key |
Aleph convention: key type.
Definition at line 390 of file tpl_flat_map.H.
| using Aleph::FlatMap< Key, T, Compare >::key_type = Key |
STL convention: key type.
Definition at line 391 of file tpl_flat_map.H.
| using Aleph::FlatMap< Key, T, Compare >::mapped_type = T |
STL convention: mapped type.
Definition at line 392 of file tpl_flat_map.H.
| using Aleph::FlatMap< Key, T, Compare >::size_type = size_t |
STL convention: size type.
Definition at line 395 of file tpl_flat_map.H.
| using Aleph::FlatMap< Key, T, Compare >::value_type = std::pair<Key, T> |
STL convention: value type.
Definition at line 393 of file tpl_flat_map.H.
|
inlineexplicit |
Construct an empty map.
| cap | Initial capacity hint (rounded up to a power of two by the backing MemArrays). |
| std::bad_alloc | if the initial buffers cannot be allocated. |
Definition at line 591 of file tpl_flat_map.H.
|
inlineexplicit |
Construct an empty map with a specific comparator.
| cmp | Comparator instance to copy. |
| cap | Initial capacity hint. |
| std::bad_alloc | if the initial buffers cannot be allocated. |
Definition at line 599 of file tpl_flat_map.H.
|
inline |
Construct from an iterator range of pairs.
Loads all entries, then sorts once by key and removes duplicate keys: O(m log m) for m input entries.
| It | Iterator whose dereferenced entry exposes first and second convertible to Key and T (a std::pair, or this map's own (key, value) proxy). |
| first | Beginning of the range. |
| last | End of the range. |
| cmp | Comparator instance (defaulted). |
| std::bad_alloc | if memory allocation fails. |
Definition at line 629 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::keys_, Aleph::MemArray< T >::put(), Aleph::FlatMap< Key, T, Compare >::sort_and_unique(), and Aleph::FlatMap< Key, T, Compare >::vals_.
|
inline |
Construct from an initializer list of pairs.
| l | Entries to load; duplicate keys are dropped (first wins). |
| cmp | Comparator instance (defaulted). |
| std::bad_alloc | if memory allocation fails. |
Definition at line 647 of file tpl_flat_map.H.
|
default |
Copy constructor (requires copyable Key and T).
|
defaultnoexcept |
Move constructor. The source is left valid but unspecified.
|
default |
|
inline |
Checked access to the value mapped to k.
| k | Key to search for. |
| std::out_of_range | if k is not mapped. |
Definition at line 835 of file tpl_flat_map.H.
References ah_out_of_range_error_if, k, Aleph::FlatMap< Key, T, Compare >::lower_idx(), Aleph::FlatMap< Key, T, Compare >::match_at(), and Aleph::FlatMap< Key, T, Compare >::vals_.
|
inline |
See at(const Key & k).
Definition at line 843 of file tpl_flat_map.H.
References ah_out_of_range_error_if, k, Aleph::FlatMap< Key, T, Compare >::lower_idx(), Aleph::FlatMap< Key, T, Compare >::match_at(), and Aleph::FlatMap< Key, T, Compare >::vals_.
|
inlinenoexcept |
Const iterator to the entry with the smallest key. O(1).
Definition at line 1057 of file tpl_flat_map.H.
References Aleph::MemArray< T >::get_ptr(), Aleph::FlatMap< Key, T, Compare >::keys_, and Aleph::FlatMap< Key, T, Compare >::vals_.
|
inlinenoexcept |
Iterator to the entry with the smallest key. O(1).
Definition at line 1045 of file tpl_flat_map.H.
References Aleph::MemArray< T >::get_ptr(), Aleph::FlatMap< Key, T, Compare >::keys_, and Aleph::FlatMap< Key, T, Compare >::vals_.
Referenced by Aleph::FlatMap< Key, T, Compare >::cbegin(), Aleph::FlatMap< Key, T, Compare >::erase(), Aleph::FlatMap< Key, T, Compare >::find(), Aleph::FlatMap< Key, T, Compare >::find(), Aleph::FlatMap< Key, T, Compare >::insert(), Aleph::FlatMap< Key, T, Compare >::insert(), Aleph::FlatMap< Key, T, Compare >::insert_or_assign(), Aleph::FlatMap< Key, T, Compare >::insert_or_assign(), Aleph::FlatMap< Key, T, Compare >::lower_bound(), Aleph::FlatMap< Key, T, Compare >::lower_bound(), TEST(), Aleph::FlatMap< Key, T, Compare >::upper_bound(), and Aleph::FlatMap< Key, T, Compare >::upper_bound().
|
inlinenoexcept |
Return the capacity of the backing key array. O(1).
Definition at line 706 of file tpl_flat_map.H.
References Aleph::MemArray< T >::capacity(), and Aleph::FlatMap< Key, T, Compare >::keys_.
|
inlinenoexcept |
Const iterator to the entry with the smallest key. O(1).
Definition at line 1069 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::begin().
|
inlinenoexcept |
Const iterator past the entry with the greatest key. O(1).
Definition at line 1075 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::end().
|
inlinenoexcept |
Remove all entries. Alias of empty(). Capacity is kept.
Definition at line 736 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::empty().
|
inline |
Test whether key k is mapped.
| k | Key to search for. |
true if an equivalent key is stored. Definition at line 766 of file tpl_flat_map.H.
References k, Aleph::FlatMap< Key, T, Compare >::lower_idx(), and Aleph::FlatMap< Key, T, Compare >::match_at().
Referenced by Aleph::FlatMap< Key, T, Compare >::count(), TEST(), and TEST().
|
inline |
Count entries with key k (0 or 1).
| k | Key to search for. |
Definition at line 776 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::contains(), and k.
|
inlineprivate |
Definition at line 310 of file tpl_flat_map.H.
References Aleph::MemArray< T >::get(), Aleph::FlatMap< Key, T, Compare >::keys_, Aleph::FlatMap< Key, T, Compare >::nothrow_relocation, and Aleph::FlatMap< Key, T, Compare >::vals_.
Referenced by Aleph::FlatMap< Key, T, Compare >::remove_at().
|
inline |
Build a key from kargs and insert it with a default value.
Convenience over insert(Key(kargs...), T()): the key is constructed once and moved into position; the value is default-constructed.
| KArgs | Argument types forwarded to Key's constructor. |
| kargs | Arguments for the key. |
| std::bad_alloc | if a growing reallocation fails. |
Definition at line 1005 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::insert().
|
inlinenoexcept |
Remove all entries (Aleph convention).
Capacity is kept.
Array::empty()), this mutates the map; use is_empty() to test for emptiness. Definition at line 729 of file tpl_flat_map.H.
References Aleph::MemArray< T >::empty(), Aleph::FlatMap< Key, T, Compare >::keys_, and Aleph::FlatMap< Key, T, Compare >::vals_.
Referenced by Aleph::FlatMap< Key, T, Compare >::clear(), and Aleph::FlatMap< Key, T, Compare >::keeping_invariants().
|
inlinenoexcept |
Const iterator past the entry with the greatest key. O(1).
Definition at line 1063 of file tpl_flat_map.H.
References Aleph::MemArray< T >::get_ptr(), Aleph::FlatMap< Key, T, Compare >::keys_, Aleph::FlatMap< Key, T, Compare >::size(), and Aleph::FlatMap< Key, T, Compare >::vals_.
|
inlinenoexcept |
Iterator past the entry with the greatest key. O(1).
Definition at line 1051 of file tpl_flat_map.H.
References Aleph::MemArray< T >::get_ptr(), Aleph::FlatMap< Key, T, Compare >::keys_, Aleph::FlatMap< Key, T, Compare >::size(), and Aleph::FlatMap< Key, T, Compare >::vals_.
Referenced by Aleph::FlatMap< Key, T, Compare >::cend(), Aleph::FlatMap< Key, T, Compare >::find(), Aleph::FlatMap< Key, T, Compare >::find(), and TEST().
|
inline |
Range of entries with key equivalent to k.
| k | Key to bound. |
{lower_bound(k), upper_bound(k)} (length 0 or 1). Definition at line 818 of file tpl_flat_map.H.
References k, Aleph::FlatMap< Key, T, Compare >::lower_bound(), and Aleph::FlatMap< Key, T, Compare >::upper_bound().
|
inline |
See equal_range(const Key & k).
Definition at line 824 of file tpl_flat_map.H.
References k, Aleph::FlatMap< Key, T, Compare >::lower_bound(), and Aleph::FlatMap< Key, T, Compare >::upper_bound().
|
inline |
Remove the entry with key k, if present.
| k | Key to remove. |
| Any | exception thrown by moving an entry; the map is then left empty (see the class notes on exception safety). |
Definition at line 1019 of file tpl_flat_map.H.
References k, Aleph::FlatMap< Key, T, Compare >::lower_idx(), Aleph::FlatMap< Key, T, Compare >::match_at(), and Aleph::FlatMap< Key, T, Compare >::remove_at().
Referenced by TEST().
|
inline |
Remove the entry at iterator it.
| it | Valid dereferenceable iterator into this map. |
| std::out_of_range | if it does not point into the map. |
Definition at line 1034 of file tpl_flat_map.H.
References ah_out_of_range_error_if, Aleph::FlatMap< Key, T, Compare >::begin(), Aleph::MemArray< T >::get_ptr(), Aleph::FlatMap< Key, T, Compare >::basic_iterator< IsConst >::key_ptr(), Aleph::FlatMap< Key, T, Compare >::keys_, Aleph::FlatMap< Key, T, Compare >::remove_at(), and Aleph::FlatMap< Key, T, Compare >::size().
|
inline |
Find the entry with key k.
| k | Key to search for. |
end() if absent. Definition at line 748 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::begin(), Aleph::FlatMap< Key, T, Compare >::end(), k, Aleph::FlatMap< Key, T, Compare >::lower_idx(), and Aleph::FlatMap< Key, T, Compare >::match_at().
|
inline |
See find(const Key & k).
Definition at line 755 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::begin(), Aleph::FlatMap< Key, T, Compare >::end(), k, Aleph::FlatMap< Key, T, Compare >::lower_idx(), and Aleph::FlatMap< Key, T, Compare >::match_at().
|
inlineprivate |
Definition at line 242 of file tpl_flat_map.H.
References Aleph::MemArray< T >::capacity(), Aleph::FlatMap< Key, T, Compare >::keeping_invariants(), Aleph::FlatMap< Key, T, Compare >::nothrow_relocation, Aleph::FlatMap< Key, T, Compare >::relocate(), and Aleph::MemArray< T >::reserve().
Referenced by Aleph::FlatMap< Key, T, Compare >::grow_to().
|
inlineprivate |
Definition at line 262 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::grow_array(), Aleph::FlatMap< Key, T, Compare >::keys_, and Aleph::FlatMap< Key, T, Compare >::vals_.
Referenced by Aleph::FlatMap< Key, T, Compare >::insert_at(), and Aleph::FlatMap< Key, T, Compare >::reserve().
|
inline |
Insert (k, v) if k is not mapped.
| k | Key to insert. |
| v | Value to associate. |
true if inserted / false if the key was already mapped — the existing value is kept). | std::bad_alloc | if a growing reallocation fails. |
| Any | exception thrown by copying k or v (the map is left untouched) or by moving an entry (see the class notes on exception safety). |
k and v may be entries of this map. Definition at line 926 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::begin(), Aleph::FlatMap< Key, T, Compare >::insert_at(), k, Aleph::FlatMap< Key, T, Compare >::lower_idx(), and Aleph::FlatMap< Key, T, Compare >::match_at().
Referenced by Aleph::FlatMap< Key, T, Compare >::emplace(), Aleph::FlatMap< Key, T, Compare >::insert(), Aleph::FlatMap< Key, T, Compare >::insert(), TEST(), and TEST().
|
inline |
Insert a (key, value) pair if the key is not mapped.
| p | Pair to insert. |
| std::bad_alloc | if a growing reallocation fails. |
Definition at line 950 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::insert().
|
inline |
See insert(const Key & k, const T & v); moving key and value.
Definition at line 936 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::begin(), Aleph::FlatMap< Key, T, Compare >::insert_at(), k, Aleph::FlatMap< Key, T, Compare >::lower_idx(), and Aleph::FlatMap< Key, T, Compare >::match_at().
|
inline |
See insert(const std::pair<Key, T> & p); moving the pair.
Definition at line 956 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::insert().
|
inlineprivate |
Definition at line 288 of file tpl_flat_map.H.
References Aleph::MemArray< T >::capacity(), Aleph::MemArray< T >::get_ptr(), Aleph::FlatMap< Key, T, Compare >::grow_to(), k, Aleph::FlatMap< Key, T, Compare >::keeping_invariants(), Aleph::FlatMap< Key, T, Compare >::keys_, Aleph::FlatMap< Key, T, Compare >::make_room(), Aleph::MemArray< T >::size(), and Aleph::FlatMap< Key, T, Compare >::vals_.
Referenced by Aleph::FlatMap< Key, T, Compare >::insert(), Aleph::FlatMap< Key, T, Compare >::insert(), Aleph::FlatMap< Key, T, Compare >::insert_or_assign(), Aleph::FlatMap< Key, T, Compare >::insert_or_assign(), Aleph::FlatMap< Key, T, Compare >::operator[](), and Aleph::FlatMap< Key, T, Compare >::operator[]().
|
inline |
Insert (k, v) or overwrite the value if k is mapped.
| k | Key to insert or update. |
| v | Value to associate. |
true if inserted / false if an existing value was overwritten). | std::bad_alloc | if a growing reallocation fails. |
Definition at line 969 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::begin(), Aleph::FlatMap< Key, T, Compare >::insert_at(), k, Aleph::FlatMap< Key, T, Compare >::lower_idx(), Aleph::FlatMap< Key, T, Compare >::match_at(), and Aleph::FlatMap< Key, T, Compare >::vals_.
|
inline |
See insert_or_assign(const Key & k, const T & v); moving both.
Definition at line 982 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::begin(), Aleph::FlatMap< Key, T, Compare >::insert_at(), k, Aleph::FlatMap< Key, T, Compare >::lower_idx(), Aleph::FlatMap< Key, T, Compare >::match_at(), and Aleph::FlatMap< Key, T, Compare >::vals_.
|
inlinenoexcept |
Return true if the map holds no entries. O(1).
Definition at line 700 of file tpl_flat_map.H.
References Aleph::MemArray< T >::is_empty(), and Aleph::FlatMap< Key, T, Compare >::keys_.
|
inlineprivate |
Definition at line 206 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::empty(), and Aleph::FlatMap< Key, T, Compare >::nothrow_relocation.
Referenced by Aleph::FlatMap< Key, T, Compare >::grow_array(), Aleph::FlatMap< Key, T, Compare >::insert_at(), and Aleph::FlatMap< Key, T, Compare >::remove_at().
|
inline |
Copy all keys, in ascending order, into a DynList.
Compare. | std::bad_alloc | if memory allocation fails. |
Definition at line 1103 of file tpl_flat_map.H.
References Aleph::DynList< T >::append(), Aleph::MemArray< T >::get_ptr(), Aleph::FlatMap< Key, T, Compare >::keys_, and Aleph::FlatMap< Key, T, Compare >::size().
|
inlinenoexcept |
Pointer to the sorted, contiguous key storage. O(1).
Definition at line 1081 of file tpl_flat_map.H.
References Aleph::MemArray< T >::get_ptr(), and Aleph::FlatMap< Key, T, Compare >::keys_.
|
inline |
First entry whose key is not less than k.
| k | Key to bound. |
end(). Definition at line 786 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::begin(), k, and Aleph::FlatMap< Key, T, Compare >::lower_idx().
Referenced by Aleph::FlatMap< Key, T, Compare >::equal_range(), and Aleph::FlatMap< Key, T, Compare >::equal_range().
|
inline |
See lower_bound(const Key & k).
Definition at line 792 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::begin(), k, and Aleph::FlatMap< Key, T, Compare >::lower_idx().
|
inlineprivate |
Definition at line 157 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::cmp_, k, Aleph::FlatMap< Key, T, Compare >::keys_, and Aleph::MemArray< T >::size().
Referenced by Aleph::FlatMap< Key, T, Compare >::at(), Aleph::FlatMap< Key, T, Compare >::at(), Aleph::FlatMap< Key, T, Compare >::contains(), Aleph::FlatMap< Key, T, Compare >::erase(), Aleph::FlatMap< Key, T, Compare >::find(), Aleph::FlatMap< Key, T, Compare >::find(), Aleph::FlatMap< Key, T, Compare >::insert(), Aleph::FlatMap< Key, T, Compare >::insert(), Aleph::FlatMap< Key, T, Compare >::insert_or_assign(), Aleph::FlatMap< Key, T, Compare >::insert_or_assign(), Aleph::FlatMap< Key, T, Compare >::lower_bound(), Aleph::FlatMap< Key, T, Compare >::lower_bound(), Aleph::FlatMap< Key, T, Compare >::operator[](), and Aleph::FlatMap< Key, T, Compare >::operator[]().
|
inlineprivate |
Definition at line 270 of file tpl_flat_map.H.
References Aleph::MemArray< T >::get_ptr(), Aleph::FlatMap< Key, T, Compare >::keys_, Aleph::MemArray< T >::putn(), Aleph::MemArray< T >::size(), and Aleph::FlatMap< Key, T, Compare >::vals_.
Referenced by Aleph::FlatMap< Key, T, Compare >::insert_at().
|
inlineprivate |
Definition at line 187 of file tpl_flat_map.H.
References Aleph::and, Aleph::FlatMap< Key, T, Compare >::cmp_, k, Aleph::FlatMap< Key, T, Compare >::keys_, and Aleph::MemArray< T >::size().
Referenced by Aleph::FlatMap< Key, T, Compare >::at(), Aleph::FlatMap< Key, T, Compare >::at(), Aleph::FlatMap< Key, T, Compare >::contains(), Aleph::FlatMap< Key, T, Compare >::erase(), Aleph::FlatMap< Key, T, Compare >::find(), Aleph::FlatMap< Key, T, Compare >::find(), Aleph::FlatMap< Key, T, Compare >::insert(), Aleph::FlatMap< Key, T, Compare >::insert(), Aleph::FlatMap< Key, T, Compare >::insert_or_assign(), Aleph::FlatMap< Key, T, Compare >::insert_or_assign(), Aleph::FlatMap< Key, T, Compare >::operator[](), and Aleph::FlatMap< Key, T, Compare >::operator[]().
|
inline |
Key of the i-th entry in sorted order (checked).
| i | Zero-based rank. |
| std::out_of_range | if i >= size(). |
Definition at line 890 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::keys_.
|
inline |
Value of the i-th entry in sorted order (checked).
| i | Zero-based rank. |
| std::out_of_range | if i >= size(). |
Definition at line 901 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::vals_.
|
inline |
See nth_value(size_t i).
Definition at line 907 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::vals_.
|
inline |
|
inline |
Copy assignment (requires copyable Key and T).
The copy is built apart and then swapped in, so a failure while copying the keys or the values leaves this map as it was.
| m | Map to copy. |
*this. | std::bad_alloc | or any exception thrown by copying an entry. |
Definition at line 666 of file tpl_flat_map.H.
References m, and Aleph::FlatMap< Key, T, Compare >::swap().
|
defaultnoexcept |
Move assignment. The source is left valid but unspecified.
|
inline |
Equality: same size and pairwise equal keys and values.
| m | Map to compare against. |
true if both maps hold equal entries in the same order. Key and T equality comparable. Definition at line 1172 of file tpl_flat_map.H.
References Aleph::and, Aleph::MemArray< T >::get_ptr(), Aleph::FlatMap< Key, T, Compare >::keys_, m, OhashCommon< HashTbl, Key >::size(), Aleph::FlatMap< Key, T, Compare >::size(), and Aleph::FlatMap< Key, T, Compare >::vals_.
|
inline |
Access the value mapped to k, inserting a default if absent.
| k | Key to search for or insert. |
| std::bad_alloc | if a growing reallocation fails. |
Definition at line 856 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::insert_at(), k, Aleph::FlatMap< Key, T, Compare >::lower_idx(), Aleph::FlatMap< Key, T, Compare >::match_at(), and Aleph::FlatMap< Key, T, Compare >::vals_.
|
inline |
Access the value mapped to k, inserting a default if absent.
Same as the const-reference overload, but moves k on insertion.
| k | Key to search for or insert (moved on insertion). |
| std::bad_alloc | if a growing reallocation fails. |
Definition at line 873 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::insert_at(), k, Aleph::FlatMap< Key, T, Compare >::lower_idx(), Aleph::FlatMap< Key, T, Compare >::match_at(), and Aleph::FlatMap< Key, T, Compare >::vals_.
|
inlinestaticprivate |
Definition at line 225 of file tpl_flat_map.H.
References Aleph::MemArray< T >::get_ptr(), Aleph::MemArray< T >::putn(), Aleph::MemArray< T >::size(), and Aleph::MemArray< T >::swap().
Referenced by Aleph::FlatMap< Key, T, Compare >::grow_array().
|
inlineprivate |
Definition at line 337 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::drop_last(), Aleph::MemArray< T >::get_ptr(), Aleph::FlatMap< Key, T, Compare >::keeping_invariants(), Aleph::FlatMap< Key, T, Compare >::keys_, Aleph::MemArray< T >::size(), and Aleph::FlatMap< Key, T, Compare >::vals_.
Referenced by Aleph::FlatMap< Key, T, Compare >::erase(), and Aleph::FlatMap< Key, T, Compare >::erase().
|
inline |
Reserve capacity for at least cap entries.
| cap | Desired capacity (rounded up to a power of two). |
| std::bad_alloc | if memory allocation fails; the map keeps its entries. |
| std::overflow_error | if cap cannot be rounded up to a power of two; the map keeps its entries. |
| Any | exception thrown by moving an entry; the map is then left empty (see the class notes on exception safety). |
Definition at line 720 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::grow_to().
|
inlinenoexcept |
Return the number of stored entries. O(1).
Definition at line 694 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::keys_, and Aleph::MemArray< T >::size().
Referenced by Aleph::FlatMap< Key, T, Compare >::end(), Aleph::FlatMap< Key, T, Compare >::end(), Aleph::FlatMap< Key, T, Compare >::erase(), Aleph::FlatMap< Key, T, Compare >::keys(), Aleph::FlatMap< Key, T, Compare >::operator==(), TEST(), TEST(), TEST(), TEST(), TEST(), Aleph::FlatMap< Key, T, Compare >::traverse(), Aleph::FlatMap< Key, T, Compare >::traverse(), and Aleph::FlatMap< Key, T, Compare >::values().
|
inlineprivate |
Definition at line 355 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::cmp_, Aleph::MemArray< T >::get(), Aleph::MemArray< T >::get_ptr(), Aleph::FlatMap< Key, T, Compare >::keys_, m, out, Aleph::MemArray< T >::put(), Aleph::MemArray< T >::size(), Aleph::timsort(), and Aleph::FlatMap< Key, T, Compare >::vals_.
Referenced by Aleph::FlatMap< Key, T, Compare >::FlatMap().
|
inlinenoexcept |
Swap contents with m in O(1).
| m | Map to swap with. |
Definition at line 684 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::cmp_, Aleph::FlatMap< Key, T, Compare >::keys_, m, Aleph::MemArray< T >::swap(), and Aleph::FlatMap< Key, T, Compare >::vals_.
Referenced by Aleph::FlatMap< Key, T, Compare >::operator=().
|
inline |
Traverse entries in key order while operation returns true.
Aleph-style bounded traversal: operation receives (const Key &, T &) in ascending key order; returning false stops the walk.
| Operation | Callable bool(const Key &, T &). |
| operation | Operation to apply. |
true if all entries were visited, false if stopped early. Definition at line 1136 of file tpl_flat_map.H.
References Aleph::MemArray< T >::get_ptr(), Aleph::FlatMap< Key, T, Compare >::keys_, m, Aleph::FlatMap< Key, T, Compare >::size(), and Aleph::FlatMap< Key, T, Compare >::vals_.
Referenced by TEST().
|
inline |
Const traversal in key order while operation returns true.
| Operation | Callable bool(const Key &, const T &). |
| operation | Operation to apply. |
true if all entries were visited, false if stopped early. Definition at line 1154 of file tpl_flat_map.H.
References Aleph::MemArray< T >::get_ptr(), Aleph::FlatMap< Key, T, Compare >::keys_, m, Aleph::FlatMap< Key, T, Compare >::size(), and Aleph::FlatMap< Key, T, Compare >::vals_.
|
inline |
First entry whose key is greater than k.
| k | Key to bound. |
end(). Definition at line 802 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::begin(), k, and Aleph::FlatMap< Key, T, Compare >::upper_idx().
Referenced by Aleph::FlatMap< Key, T, Compare >::equal_range(), and Aleph::FlatMap< Key, T, Compare >::equal_range().
|
inline |
See upper_bound(const Key & k).
Definition at line 808 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::begin(), k, and Aleph::FlatMap< Key, T, Compare >::upper_idx().
|
inlineprivate |
Definition at line 172 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::cmp_, k, Aleph::FlatMap< Key, T, Compare >::keys_, and Aleph::MemArray< T >::size().
Referenced by Aleph::FlatMap< Key, T, Compare >::upper_bound(), and Aleph::FlatMap< Key, T, Compare >::upper_bound().
|
inline |
Copy all values, in ascending key order, into a DynList.
| std::bad_alloc | if memory allocation fails. |
Definition at line 1117 of file tpl_flat_map.H.
References Aleph::DynList< T >::append(), Aleph::FlatMap< Key, T, Compare >::size(), and Aleph::FlatMap< Key, T, Compare >::vals_.
|
inlinenoexcept |
See values_data().
Definition at line 1093 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::vals_.
|
inlinenoexcept |
Pointer to the contiguous value storage (parallel to keys). O(1).
Definition at line 1087 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::vals_.
|
private |
Definition at line 154 of file tpl_flat_map.H.
Referenced by Aleph::FlatMap< Key, T, Compare >::lower_idx(), Aleph::FlatMap< Key, T, Compare >::match_at(), Aleph::FlatMap< Key, T, Compare >::sort_and_unique(), Aleph::FlatMap< Key, T, Compare >::swap(), and Aleph::FlatMap< Key, T, Compare >::upper_idx().
|
private |
Definition at line 152 of file tpl_flat_map.H.
Referenced by Aleph::FlatMap< Key, T, Compare >::FlatMap(), Aleph::FlatMap< Key, T, Compare >::begin(), Aleph::FlatMap< Key, T, Compare >::begin(), Aleph::FlatMap< Key, T, Compare >::capacity(), Aleph::FlatMap< Key, T, Compare >::drop_last(), Aleph::FlatMap< Key, T, Compare >::empty(), Aleph::FlatMap< Key, T, Compare >::end(), Aleph::FlatMap< Key, T, Compare >::end(), Aleph::FlatMap< Key, T, Compare >::erase(), Aleph::FlatMap< Key, T, Compare >::grow_to(), Aleph::FlatMap< Key, T, Compare >::insert_at(), Aleph::FlatMap< Key, T, Compare >::is_empty(), Aleph::FlatMap< Key, T, Compare >::keys(), Aleph::FlatMap< Key, T, Compare >::keys_data(), Aleph::FlatMap< Key, T, Compare >::lower_idx(), Aleph::FlatMap< Key, T, Compare >::make_room(), Aleph::FlatMap< Key, T, Compare >::match_at(), Aleph::FlatMap< Key, T, Compare >::nth_key(), Aleph::FlatMap< Key, T, Compare >::operator==(), Aleph::FlatMap< Key, T, Compare >::remove_at(), Aleph::FlatMap< Key, T, Compare >::size(), Aleph::FlatMap< Key, T, Compare >::sort_and_unique(), Aleph::FlatMap< Key, T, Compare >::swap(), Aleph::FlatMap< Key, T, Compare >::traverse(), Aleph::FlatMap< Key, T, Compare >::traverse(), and Aleph::FlatMap< Key, T, Compare >::upper_idx().
|
staticconstexprprivate |
Definition at line 195 of file tpl_flat_map.H.
Referenced by Aleph::FlatMap< Key, T, Compare >::drop_last(), Aleph::FlatMap< Key, T, Compare >::grow_array(), and Aleph::FlatMap< Key, T, Compare >::keeping_invariants().
|
private |
Definition at line 153 of file tpl_flat_map.H.
Referenced by Aleph::FlatMap< Key, T, Compare >::FlatMap(), Aleph::FlatMap< Key, T, Compare >::at(), Aleph::FlatMap< Key, T, Compare >::at(), Aleph::FlatMap< Key, T, Compare >::begin(), Aleph::FlatMap< Key, T, Compare >::begin(), Aleph::FlatMap< Key, T, Compare >::drop_last(), Aleph::FlatMap< Key, T, Compare >::empty(), Aleph::FlatMap< Key, T, Compare >::end(), Aleph::FlatMap< Key, T, Compare >::end(), Aleph::FlatMap< Key, T, Compare >::grow_to(), Aleph::FlatMap< Key, T, Compare >::insert_at(), Aleph::FlatMap< Key, T, Compare >::insert_or_assign(), Aleph::FlatMap< Key, T, Compare >::insert_or_assign(), Aleph::FlatMap< Key, T, Compare >::make_room(), Aleph::FlatMap< Key, T, Compare >::nth_value(), Aleph::FlatMap< Key, T, Compare >::nth_value(), Aleph::FlatMap< Key, T, Compare >::operator==(), Aleph::FlatMap< Key, T, Compare >::operator[](), Aleph::FlatMap< Key, T, Compare >::operator[](), Aleph::FlatMap< Key, T, Compare >::remove_at(), Aleph::FlatMap< Key, T, Compare >::sort_and_unique(), Aleph::FlatMap< Key, T, Compare >::swap(), Aleph::FlatMap< Key, T, Compare >::traverse(), Aleph::FlatMap< Key, T, Compare >::traverse(), Aleph::FlatMap< Key, T, Compare >::values(), Aleph::FlatMap< Key, T, Compare >::values_data(), and Aleph::FlatMap< Key, T, Compare >::values_data().