Skip to content

Commit 0771583

Browse files
committed
flat_map added
1 parent 05cc26e commit 0771583

4 files changed

Lines changed: 947 additions & 0 deletions

File tree

container/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ Defines two functions in `ContainerAlgorithms` namespace that are constructed up
66
* `void erase_all_occurrences(ContainerType& container, const ArgumentType& item)` deletes every occurrence of the `item` in `container` using the remove-erase idiom.
77
* `void void erase_if(ContainerType& container, std::function<bool(const ItemType&)>` deletes every occurrence of the `item` in `container` using the remove-erase idiom.
88

9+
### flat_map.hpp
10+
11+
Defines `flat_map` and `flat_set`, sorted associative containers backed by vectors. `flat_map` keeps keys and mapped
12+
values in separate vectors and exposes pair-like proxy iterators with `first`/`second` and `key()`/`value()` access.
13+
Both containers support ordinary insertion, merging from a sorted range, and batched unsorted appends followed
14+
by tail sorting and merging. Existing entries and the first newly inserted entry win duplicate keys. Key equality uses
15+
`operator==` when the compared types provide it, otherwise comparator equivalence; equal keys must also be equivalent
16+
under the comparator. Batch entries are added with `append_unsorted()`; ordered operations and iteration must not be
17+
used between `begin_batch()` and `end_batch()`.
18+
Map dereference returns its proxy by value, so `auto entry` and `const auto& entry` work in range loops but `auto& entry`
19+
does not. Read-only standard algorithms and construction of ordinary pair containers are supported; algorithms that
20+
reorder entries are intentionally ill-formed because keys are immutable.
21+
922
### iterator_helpers.hpp
1023

1124
Defines two classes `const_forward_iterator_wrapper` and `forward_iterator_wrapper` that encapsulate an std (or std-compatible) iterator together with a reference to the container this iterator points to. This allows using these iterators as any other normal iterator while also being able to get the parent container from them.

0 commit comments

Comments
 (0)