Hash map with the QHash-style API the CDT kernel uses, over std::unordered_map<K, V, Hash<K>>.
More...
#include <meshkit/detail/storage.hpp>
Classes | |
| class | Iterator |
| Forward iterator over a Map whose dereference yields the mapped value. More... | |
Public Types | |
| using | ConstIterator = Iterator<true> |
Read-only iterator; value() is const V &. | |
| using | MutableIterator = Iterator<false> |
Iterator whose value() is a modifiable V &. | |
Public Member Functions | |
| void | clear () |
| Remove all entries. | |
| void | reserve (std::size_t n) |
Prepare buckets for at least n entries (std::unordered_map::reserve). | |
| bool | isEmpty () const |
| True when the map has no entries. | |
| std::ptrdiff_t | size () const |
| Number of entries, as a signed count. | |
| bool | contains (const K &k) const |
| Key lookup. | |
| MutableIterator | insert (const K &k, const V &v) |
Store v under k, overwriting any existing value (insert_or_assign). | |
| bool | remove (const K &k) |
Erase the entry for k. | |
| V & | operator[] (const K &k) |
Modifiable value for k, inserting a value-initialized V{} first when absent. | |
| V | value (const K &k, const V &fallback=V{}) const |
Copy of the value for k, without inserting. | |
| MutableIterator | find (const K &k) |
Mutable iterator to the entry for k. | |
| MutableIterator | begin () |
| Mutable iterator to the first entry (order unspecified). | |
| ConstIterator | begin () const |
| Read-only iterator to the first entry; same as cbegin(). | |
| MutableIterator | end () |
| Mutable past-the-end iterator. | |
| ConstIterator | end () const |
| Read-only past-the-end iterator; same as cend(). | |
| ConstIterator | constFind (const K &k) const |
Read-only iterator to the entry for k. | |
| ConstIterator | constEnd () const |
| Read-only past-the-end iterator, to compare with constFind() results. | |
| ConstIterator | cbegin () const |
| Read-only iterator to the first entry (order unspecified). | |
| ConstIterator | cend () const |
| Read-only past-the-end iterator. | |
Hash map with the QHash-style API the CDT kernel uses, over std::unordered_map<K, V, Hash<K>>.
Unlike std::unordered_map, its iterators dereference to the mapped value, not to a key/value pair (Iterator::key() gives the key), so a range-for visits values. Iteration order is unspecified. Invalidation follows std::unordered_map: an insertion may rehash and invalidate iterators but not references to values, and remove() invalidates only the removed entry. No internal synchronization.
| K | Key type, hashed by Hash<K> and compared with operator==. |
| V | Mapped type. |
| using meshkit::detail::Map< K, V >::ConstIterator = Iterator<true> |
Read-only iterator; value() is const V &.
| using meshkit::detail::Map< K, V >::MutableIterator = Iterator<false> |
|
inline |
Mutable iterator to the first entry (order unspecified).
|
inline |
Read-only iterator to the first entry; same as cbegin().
|
inline |
Read-only iterator to the first entry (order unspecified).
|
inline |
Read-only past-the-end iterator.
|
inline |
Remove all entries.
|
inline |
Read-only past-the-end iterator, to compare with constFind() results.
|
inline |
Read-only iterator to the entry for k.
| [in] | k | Key. |
k is absent.
|
inline |
Key lookup.
| [in] | k | Key to look for. |
k has an entry.
|
inline |
Mutable past-the-end iterator.
|
inline |
Read-only past-the-end iterator; same as cend().
|
inline |
|
inline |
Store v under k, overwriting any existing value (insert_or_assign).
| [in] | k | Key. |
| [in] | v | Value to copy. |
|
inline |
True when the map has no entries.
|
inline |
Modifiable value for k, inserting a value-initialized V{} first when absent.
| [in] | k | Key. |
|
inline |
Erase the entry for k.
| [in] | k | Key. |
k was absent.
|
inline |
Prepare buckets for at least n entries (std::unordered_map::reserve).
| [in] | n | Expected number of entries. |
|
inline |
Number of entries, as a signed count.
|
inline |
Copy of the value for k, without inserting.
| [in] | k | Key. |
| [in] | fallback | Returned when k is absent; defaults to V{}. |
fallback.