|
Aleph-w 3.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 &)=default |
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 |
| 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 |
| iterator | upper_bound (const Key &k) |
First entry whose key is greater than k. | |
| const_iterator | upper_bound (const Key &k) const |
| 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 |
| T & | at (const Key &k) |
Checked access to the value mapped to k. | |
| const T & | at (const Key &k) const |
| 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 |
| 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) |
| 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) |
| 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) |
| 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 |
| 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 |
| void | make_room (const size_t pos) |
| void | remove_at (const size_t pos) |
| void | sort_and_unique () |
Private Attributes | |
| MemArray< Key > | keys_ |
| MemArray< T > | vals_ |
| Compare | cmp_ |
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.insert and operator[] offer the strong guarantee up to the element shift; if a key/value assignment throws mid-shift the guarantee degrades to basic (the map remains valid). erase always removes the entry; a failed shrinking reallocation is ignored.Definition at line 127 of file tpl_flat_map.H.
| using Aleph::FlatMap< Key, T, Compare >::const_iterator = basic_iterator<true> |
Const-value iterator.
Definition at line 447 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 253 of file tpl_flat_map.H.
| using Aleph::FlatMap< Key, T, Compare >::iterator = basic_iterator<false> |
Mutable-value iterator.
Definition at line 446 of file tpl_flat_map.H.
| using Aleph::FlatMap< Key, T, Compare >::key_compare = Compare |
STL convention: comparator type.
Definition at line 258 of file tpl_flat_map.H.
| using Aleph::FlatMap< Key, T, Compare >::Key_Type = Key |
Aleph convention: key type.
Definition at line 254 of file tpl_flat_map.H.
| using Aleph::FlatMap< Key, T, Compare >::key_type = Key |
STL convention: key type.
Definition at line 255 of file tpl_flat_map.H.
| using Aleph::FlatMap< Key, T, Compare >::mapped_type = T |
STL convention: mapped type.
Definition at line 256 of file tpl_flat_map.H.
| using Aleph::FlatMap< Key, T, Compare >::size_type = size_t |
STL convention: size type.
Definition at line 259 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 257 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 455 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 463 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 493 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 511 of file tpl_flat_map.H.
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. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 679 of file tpl_flat_map.H.
References ah_out_of_range_error_if, Aleph::blossom_maximum_cardinality_matching(), k, Aleph::FlatMap< Key, T, Compare >::lower_idx(), Aleph::FlatMap< Key, T, Compare >::match_at(), and Aleph::FlatMap< Key, T, Compare >::vals_.
|
inline |
Definition at line 687 of file tpl_flat_map.H.
References ah_out_of_range_error_if, Aleph::blossom_maximum_cardinality_matching(), 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 906 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 894 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 554 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 918 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 924 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 580 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 610 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().
|
inline |
Count entries with key k (0 or 1).
| k | Key to search for. |
Definition at line 620 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::contains(), and k.
|
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 857 of file tpl_flat_map.H.
References Aleph::blossom_maximum_cardinality_matching(), and 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 573 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().
|
inlinenoexcept |
Const iterator past the entry with the greatest key. O(1).
Definition at line 912 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 900 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). This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 662 of file tpl_flat_map.H.
References k, Aleph::FlatMap< Key, T, Compare >::lower_bound(), and Aleph::FlatMap< Key, T, Compare >::upper_bound().
|
inline |
Definition at line 668 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. |
Definition at line 868 of file tpl_flat_map.H.
References Aleph::blossom_maximum_cardinality_matching(), k, Aleph::FlatMap< Key, T, Compare >::lower_idx(), Aleph::FlatMap< Key, T, Compare >::match_at(), and Aleph::FlatMap< Key, T, Compare >::remove_at().
|
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 883 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. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 592 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 |
Definition at line 599 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 |
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. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 770 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::begin(), Aleph::MemArray< T >::get_ptr(), k, Aleph::FlatMap< Key, T, Compare >::keys_, Aleph::FlatMap< Key, T, Compare >::lower_idx(), Aleph::FlatMap< Key, T, Compare >::make_room(), Aleph::FlatMap< Key, T, Compare >::match_at(), and Aleph::FlatMap< Key, T, Compare >::vals_.
Referenced by Aleph::FlatMap< Key, T, Compare >::emplace(), Aleph::FlatMap< Key, T, Compare >::insert(), and Aleph::FlatMap< Key, T, Compare >::insert().
|
inline |
Insert a (key, value) pair if the key is not mapped.
| p | Pair to insert. |
| std::bad_alloc | if a growing reallocation fails. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 798 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::insert().
|
inline |
Definition at line 782 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::begin(), Aleph::MemArray< T >::get_ptr(), k, Aleph::FlatMap< Key, T, Compare >::keys_, Aleph::FlatMap< Key, T, Compare >::lower_idx(), Aleph::FlatMap< Key, T, Compare >::make_room(), Aleph::FlatMap< Key, T, Compare >::match_at(), and Aleph::FlatMap< Key, T, Compare >::vals_.
|
inline |
Definition at line 804 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::insert().
|
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. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 817 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::begin(), Aleph::MemArray< T >::get_ptr(), k, Aleph::FlatMap< Key, T, Compare >::keys_, Aleph::FlatMap< Key, T, Compare >::lower_idx(), Aleph::FlatMap< Key, T, Compare >::make_room(), Aleph::FlatMap< Key, T, Compare >::match_at(), and Aleph::FlatMap< Key, T, Compare >::vals_.
|
inline |
Definition at line 832 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::begin(), Aleph::MemArray< T >::get_ptr(), k, Aleph::FlatMap< Key, T, Compare >::keys_, Aleph::FlatMap< Key, T, Compare >::lower_idx(), Aleph::FlatMap< Key, T, Compare >::make_room(), 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 548 of file tpl_flat_map.H.
References Aleph::MemArray< T >::is_empty(), and Aleph::FlatMap< Key, T, Compare >::keys_.
|
inline |
Copy all keys, in ascending order, into a DynList.
Compare. | std::bad_alloc | if memory allocation fails. |
Definition at line 952 of file tpl_flat_map.H.
References Aleph::blossom_maximum_cardinality_matching(), 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 930 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(). This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 630 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 |
Definition at line 636 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 134 of file tpl_flat_map.H.
References Aleph::blossom_maximum_cardinality_matching(), 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 172 of file tpl_flat_map.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::MemArray< T >::capacity(), Aleph::MemArray< T >::get_ptr(), Aleph::FlatMap< Key, T, Compare >::keys_, Aleph::MemArray< T >::putn(), Aleph::MemArray< T >::reserve(), 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[]().
|
inlineprivate |
Definition at line 164 of file tpl_flat_map.H.
References Aleph::and, Aleph::blossom_maximum_cardinality_matching(), 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 738 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(). |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 749 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::vals_.
|
inline |
Definition at line 755 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::vals_.
|
inline |
Inequality: negation of operator==.
Definition at line 1029 of file tpl_flat_map.H.
References Aleph::blossom_maximum_cardinality_matching(), and m.
|
default |
Copy assignment (requires copyable Key and T).
|
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 1021 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 700 of file tpl_flat_map.H.
References Aleph::MemArray< T >::get_ptr(), k, Aleph::FlatMap< Key, T, Compare >::keys_, Aleph::FlatMap< Key, T, Compare >::lower_idx(), Aleph::FlatMap< Key, T, Compare >::make_room(), 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 719 of file tpl_flat_map.H.
References Aleph::MemArray< T >::get_ptr(), k, Aleph::FlatMap< Key, T, Compare >::keys_, Aleph::FlatMap< Key, T, Compare >::lower_idx(), Aleph::FlatMap< Key, T, Compare >::make_room(), Aleph::FlatMap< Key, T, Compare >::match_at(), and Aleph::FlatMap< Key, T, Compare >::vals_.
|
inlineprivate |
Definition at line 191 of file tpl_flat_map.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::MemArray< T >::get(), Aleph::MemArray< T >::get_ptr(), 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. |
Definition at line 563 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::keys_, Aleph::MemArray< T >::reserve(), and Aleph::FlatMap< Key, T, Compare >::vals_.
|
inlinenoexcept |
Return the number of stored entries. O(1).
Definition at line 542 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==(), Aleph::FlatMap< Key, T, Compare >::traverse(), Aleph::FlatMap< Key, T, Compare >::traverse(), and Aleph::FlatMap< Key, T, Compare >::values().
|
inlineprivate |
Definition at line 219 of file tpl_flat_map.H.
References Aleph::blossom_maximum_cardinality_matching(), 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 >::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 532 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_.
|
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 985 of file tpl_flat_map.H.
References Aleph::blossom_maximum_cardinality_matching(), 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 |
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 1003 of file tpl_flat_map.H.
References Aleph::blossom_maximum_cardinality_matching(), 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(). This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 646 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 |
Definition at line 652 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 149 of file tpl_flat_map.H.
References Aleph::blossom_maximum_cardinality_matching(), 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 966 of file tpl_flat_map.H.
References Aleph::DynList< T >::append(), Aleph::blossom_maximum_cardinality_matching(), Aleph::FlatMap< Key, T, Compare >::size(), and Aleph::FlatMap< Key, T, Compare >::vals_.
|
inlinenoexcept |
Definition at line 942 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).
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 936 of file tpl_flat_map.H.
References Aleph::FlatMap< Key, T, Compare >::vals_.
|
private |
Definition at line 131 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 129 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 >::empty(), Aleph::FlatMap< Key, T, Compare >::end(), Aleph::FlatMap< Key, T, Compare >::end(), Aleph::FlatMap< Key, T, Compare >::erase(), 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 >::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 >::operator[](), Aleph::FlatMap< Key, T, Compare >::operator[](), Aleph::FlatMap< Key, T, Compare >::remove_at(), Aleph::FlatMap< Key, T, Compare >::reserve(), 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().
|
private |
Definition at line 130 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 >::empty(), Aleph::FlatMap< Key, T, Compare >::end(), Aleph::FlatMap< Key, T, Compare >::end(), 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 >::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 >::reserve(), 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().