You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: container/README.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ Algorithms, adapters, and containers for STL-compatible code.
8
8
|---|---|
9
9
|`algorithms.hpp`|`ContainerAlgorithms::erase_if()` applies the remove/erase idiom to sequence containers. |
10
10
|`chunked_deque.hpp`|`chunked_deque` holds elements in fixed-size blocks, each with an occupancy bitmask, so an erasure anywhere in the sequence clears a bit instead of relocating anything. Push and pop at both ends, insertion anywhere, and stable references. `operator[]` is linear in the block count: uneven occupancy rules out index arithmetic. `reserve()` pre-allocates blocks and keeps them across a drain. |
11
-
|`flat_map.hpp`| Vector-backed sorted `flat_map` and `flat_set` with heterogeneous lookup, forward and reverse random-access iteration, ordinary insertion/erasure, sorted-range merging, and batched unsorted insertion. |
11
+
|`flat_map.hpp`| Vector-backed sorted `flat_map` and `flat_set` with heterogeneous lookup, forward and reverse random-access iteration, ordinary insertion/erasure, sorted-range merging, batched unsorted insertion, and whole-vector handover in and out. |
12
12
|`iterator_helpers.hpp`|`const_forward_iterator_wrapper` retains both an iterator and its parent container, so `endReached()` needs no second iterator. `isBound()` reports whether a container was supplied, not whether the iterator is still valid. Factories provide wrapped `cbegin`/`cend`. |
13
13
|`multi_index.hpp`|`MultiIndexSet` owns values uniquely by one member and maintains a non-unique secondary-member index with exact and range lookup. |
14
14
|`multimap_helpers.hpp`|`multimap_value_iterator` adapts a multimap iterator to expose only its mapped value while retaining access to the native iterator. |
@@ -24,6 +24,10 @@ Algorithms, adapters, and containers for STL-compatible code.
24
24
25
25
`keys()` returns the backing key vector as a const reference, and `flat_map::values()` the mapped vector, indexed in lockstep with it and with iteration. Both are const: a write through a mutable handle would break the sort order, or desynchronize the map's two vectors.
26
26
27
+
Whole vectors also move in and out without an element-by-element pass. `std::move(container).extract()` empties the container and returns its storage with capacity intact: a `containers` aggregate of `keys` and `values` for the map, the key vector itself for the set. `replace()` and the vector constructors take storage back. The `sorted_unique` overloads adopt it untouched and assert the caller's ordering and uniqueness; the untagged ones sort and deduplicate in place. `replace()` keeps the container's comparator, which assigning a whole new container would replace.
28
+
29
+
`merge()` folds another container of the same type in, moving its entries across in one pass and leaving it empty. Existing entries win the collisions, as they do when a batch ends, and unlike `std::map::merge` the colliding entries are dropped rather than left behind in the source.
30
+
27
31
Both flat containers support ordinary insertion, merging a sorted range, inserting a range in any order, `append_sorted_unique()`, and batched unsorted appends. Between `begin_batch()` and `end_batch()`, ordered operations and iteration are invalid. Finalization sorts only the appended tail and merges it with the existing prefix. A tail or sorted range starting past the last existing key skips the merge entirely, so growing a container by repeated appends never rebuilds it. Existing entries win conflicts with a batch, and the first batch entry wins duplicates within that batch. `insert(first, last)` and the initializer-list `insert()` sort and merge a range under those same rules, leaving the container unchanged if constructing an element throws. `insert_sorted()` is the cheaper path when the range is known to be ordered. `abort_batch()` instead discards the appended tail and restores the state from before `begin_batch()`; `clear()` ends an open batch by discarding the container. A failed `end_batch()` leaves the batch open, so `abort_batch()` remains available and lookups keep asserting until it runs.
28
32
29
33
Key equality uses `operator==` when the compared types provide it and comparator equivalence otherwise. When both are available, they must describe the same equivalence relation.
0 commit comments