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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### Class template `flat_set` <a id="flat.set">[[flat.set]]</a>
|
| 2 |
+
|
| 3 |
+
#### Overview <a id="flat.set.overview">[[flat.set.overview]]</a>
|
| 4 |
+
|
| 5 |
+
A `flat_set` is a container adaptor that provides an associative
|
| 6 |
+
container interface that supports unique keys (i.e., contains at most
|
| 7 |
+
one of each key value) and provides for fast retrieval of the keys
|
| 8 |
+
themselves. `flat_set` supports iterators that model the
|
| 9 |
+
`random_access_iterator` concept [[iterator.concept.random.access]].
|
| 10 |
+
|
| 11 |
+
A `flat_set` meets all of the requirements for a container
|
| 12 |
+
[[container.reqmts]] and for a reversible container
|
| 13 |
+
[[container.rev.reqmts]], plus the optional container requirements
|
| 14 |
+
[[container.opt.reqmts]]. `flat_set` meets the requirements of an
|
| 15 |
+
associative container [[associative.reqmts]], except that:
|
| 16 |
+
|
| 17 |
+
- it does not meet the requirements related to node handles
|
| 18 |
+
[[container.node.overview]],
|
| 19 |
+
- it does not meet the requirements related to iterator invalidation,
|
| 20 |
+
and
|
| 21 |
+
- the time complexity of the operations that insert or erase a single
|
| 22 |
+
element from the set is linear, including the ones that take an
|
| 23 |
+
insertion position iterator.
|
| 24 |
+
|
| 25 |
+
[*Note 1*: A `flat_set` does not meet the additional requirements of an
|
| 26 |
+
allocator-aware container, as described in
|
| 27 |
+
[[container.alloc.reqmts]]. — *end note*]
|
| 28 |
+
|
| 29 |
+
A `flat_set` also provides most operations described in
|
| 30 |
+
[[associative.reqmts]] for unique keys. This means that a `flat_set`
|
| 31 |
+
supports the `a_uniq` operations in [[associative.reqmts]] but not the
|
| 32 |
+
`a_eq` operations. For a `flat_set<Key>`, both the `key_type` and
|
| 33 |
+
`value_type` are `Key`.
|
| 34 |
+
|
| 35 |
+
Descriptions are provided here only for operations on `flat_set` that
|
| 36 |
+
are not described in one of those sets of requirements or for operations
|
| 37 |
+
where there is additional semantic information.
|
| 38 |
+
|
| 39 |
+
A `flat_set` maintains the invariant that the keys are sorted with
|
| 40 |
+
respect to the comparison object.
|
| 41 |
+
|
| 42 |
+
If any member function in [[flat.set.defn]] exits via an exception, the
|
| 43 |
+
invariant is restored.
|
| 44 |
+
|
| 45 |
+
[*Note 2*: This can result in the `flat_set`’s being
|
| 46 |
+
emptied. — *end note*]
|
| 47 |
+
|
| 48 |
+
Any sequence container [[sequence.reqmts]] supporting
|
| 49 |
+
*Cpp17RandomAccessIterator* can be used to instantiate `flat_set`. In
|
| 50 |
+
particular, `vector` [[vector]] and `deque` [[deque]] can be used.
|
| 51 |
+
|
| 52 |
+
[*Note 3*: `vector<bool>` is not a sequence container. — *end note*]
|
| 53 |
+
|
| 54 |
+
The program is ill-formed if `Key` is not the same type as
|
| 55 |
+
`KeyContainer::value_type`.
|
| 56 |
+
|
| 57 |
+
The effect of calling a constructor or member function that takes a
|
| 58 |
+
`sorted_unique_t` argument with a range that is not sorted with respect
|
| 59 |
+
to `key_comp()`, or that contains equal elements, is undefined.
|
| 60 |
+
|
| 61 |
+
#### Definition <a id="flat.set.defn">[[flat.set.defn]]</a>
|
| 62 |
+
|
| 63 |
+
``` cpp
|
| 64 |
+
namespace std {
|
| 65 |
+
template<class Key, class Compare = less<Key>, class KeyContainer = vector<Key>>
|
| 66 |
+
class flat_set {
|
| 67 |
+
public:
|
| 68 |
+
// types
|
| 69 |
+
using key_type = Key;
|
| 70 |
+
using value_type = Key;
|
| 71 |
+
using key_compare = Compare;
|
| 72 |
+
using value_compare = Compare;
|
| 73 |
+
using reference = value_type&;
|
| 74 |
+
using const_reference = const value_type&;
|
| 75 |
+
using size_type = typename KeyContainer::size_type;
|
| 76 |
+
using difference_type = typename KeyContainer::difference_type;
|
| 77 |
+
using iterator = implementation-defined // type of flat_set::iterator; // see [container.requirements]
|
| 78 |
+
using const_iterator = implementation-defined // type of flat_set::const_iterator; // see [container.requirements]
|
| 79 |
+
using reverse_iterator = std::reverse_iterator<iterator>;
|
| 80 |
+
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
| 81 |
+
using container_type = KeyContainer;
|
| 82 |
+
|
| 83 |
+
// [flat.set.cons], constructors
|
| 84 |
+
flat_set() : flat_set(key_compare()) { }
|
| 85 |
+
|
| 86 |
+
explicit flat_set(container_type cont, const key_compare& comp = key_compare());
|
| 87 |
+
template<class Allocator>
|
| 88 |
+
flat_set(const container_type& cont, const Allocator& a);
|
| 89 |
+
template<class Allocator>
|
| 90 |
+
flat_set(const container_type& cont, const key_compare& comp, const Allocator& a);
|
| 91 |
+
|
| 92 |
+
flat_set(sorted_unique_t, container_type cont, const key_compare& comp = key_compare())
|
| 93 |
+
: c(std::move(cont)), compare(comp) { }
|
| 94 |
+
template<class Allocator>
|
| 95 |
+
flat_set(sorted_unique_t, const container_type& cont, const Allocator& a);
|
| 96 |
+
template<class Allocator>
|
| 97 |
+
flat_set(sorted_unique_t, const container_type& cont,
|
| 98 |
+
const key_compare& comp, const Allocator& a);
|
| 99 |
+
|
| 100 |
+
explicit flat_set(const key_compare& comp)
|
| 101 |
+
: c(), compare(comp) { }
|
| 102 |
+
template<class Allocator>
|
| 103 |
+
flat_set(const key_compare& comp, const Allocator& a);
|
| 104 |
+
template<class Allocator>
|
| 105 |
+
explicit flat_set(const Allocator& a);
|
| 106 |
+
|
| 107 |
+
template<class InputIterator>
|
| 108 |
+
flat_set(InputIterator first, InputIterator last, const key_compare& comp = key_compare())
|
| 109 |
+
: c(), compare(comp)
|
| 110 |
+
{ insert(first, last); }
|
| 111 |
+
template<class InputIterator, class Allocator>
|
| 112 |
+
flat_set(InputIterator first, InputIterator last,
|
| 113 |
+
const key_compare& comp, const Allocator& a);
|
| 114 |
+
template<class InputIterator, class Allocator>
|
| 115 |
+
flat_set(InputIterator first, InputIterator last, const Allocator& a);
|
| 116 |
+
|
| 117 |
+
template<container-compatible-range<value_type> R>
|
| 118 |
+
flat_set(from_range_t fr, R&& rg)
|
| 119 |
+
: flat_set(fr, std::forward<R>(rg), key_compare()) { }
|
| 120 |
+
template<container-compatible-range<value_type> R, class Allocator>
|
| 121 |
+
flat_set(from_range_t, R&& rg, const Allocator& a);
|
| 122 |
+
template<container-compatible-range<value_type> R>
|
| 123 |
+
flat_set(from_range_t, R&& rg, const key_compare& comp)
|
| 124 |
+
: flat_set(comp)
|
| 125 |
+
{ insert_range(std::forward<R>(rg)); }
|
| 126 |
+
template<container-compatible-range<value_type> R, class Allocator>
|
| 127 |
+
flat_set(from_range_t, R&& rg, const key_compare& comp, const Allocator& a);
|
| 128 |
+
|
| 129 |
+
template<class InputIterator>
|
| 130 |
+
flat_set(sorted_unique_t, InputIterator first, InputIterator last,
|
| 131 |
+
const key_compare& comp = key_compare())
|
| 132 |
+
: c(first, last), compare(comp) { }
|
| 133 |
+
template<class InputIterator, class Allocator>
|
| 134 |
+
flat_set(sorted_unique_t, InputIterator first, InputIterator last,
|
| 135 |
+
const key_compare& comp, const Allocator& a);
|
| 136 |
+
template<class InputIterator, class Allocator>
|
| 137 |
+
flat_set(sorted_unique_t, InputIterator first, InputIterator last, const Allocator& a);
|
| 138 |
+
|
| 139 |
+
flat_set(initializer_list<value_type> il, const key_compare& comp = key_compare())
|
| 140 |
+
: flat_set(il.begin(), il.end(), comp) { }
|
| 141 |
+
template<class Allocator>
|
| 142 |
+
flat_set(initializer_list<value_type> il, const key_compare& comp, const Allocator& a);
|
| 143 |
+
template<class Allocator>
|
| 144 |
+
flat_set(initializer_list<value_type> il, const Allocator& a);
|
| 145 |
+
|
| 146 |
+
flat_set(sorted_unique_t s, initializer_list<value_type> il,
|
| 147 |
+
const key_compare& comp = key_compare())
|
| 148 |
+
: flat_set(s, il.begin(), il.end(), comp) { }
|
| 149 |
+
template<class Allocator>
|
| 150 |
+
flat_set(sorted_unique_t, initializer_list<value_type> il,
|
| 151 |
+
const key_compare& comp, const Allocator& a);
|
| 152 |
+
template<class Allocator>
|
| 153 |
+
flat_set(sorted_unique_t, initializer_list<value_type> il, const Allocator& a);
|
| 154 |
+
|
| 155 |
+
flat_set& operator=(initializer_list<value_type>);
|
| 156 |
+
|
| 157 |
+
// iterators
|
| 158 |
+
iterator begin() noexcept;
|
| 159 |
+
const_iterator begin() const noexcept;
|
| 160 |
+
iterator end() noexcept;
|
| 161 |
+
const_iterator end() const noexcept;
|
| 162 |
+
|
| 163 |
+
reverse_iterator rbegin() noexcept;
|
| 164 |
+
const_reverse_iterator rbegin() const noexcept;
|
| 165 |
+
reverse_iterator rend() noexcept;
|
| 166 |
+
const_reverse_iterator rend() const noexcept;
|
| 167 |
+
|
| 168 |
+
const_iterator cbegin() const noexcept;
|
| 169 |
+
const_iterator cend() const noexcept;
|
| 170 |
+
const_reverse_iterator crbegin() const noexcept;
|
| 171 |
+
const_reverse_iterator crend() const noexcept;
|
| 172 |
+
|
| 173 |
+
// capacity
|
| 174 |
+
[[nodiscard]] bool empty() const noexcept;
|
| 175 |
+
size_type size() const noexcept;
|
| 176 |
+
size_type max_size() const noexcept;
|
| 177 |
+
|
| 178 |
+
// [flat.set.modifiers], modifiers
|
| 179 |
+
template<class... Args> pair<iterator, bool> emplace(Args&&... args);
|
| 180 |
+
template<class... Args>
|
| 181 |
+
iterator emplace_hint(const_iterator position, Args&&... args);
|
| 182 |
+
|
| 183 |
+
pair<iterator, bool> insert(const value_type& x)
|
| 184 |
+
{ return emplace(x); }
|
| 185 |
+
pair<iterator, bool> insert(value_type&& x)
|
| 186 |
+
{ return emplace(std::move(x)); }
|
| 187 |
+
template<class K> pair<iterator, bool> insert(K&& x);
|
| 188 |
+
iterator insert(const_iterator position, const value_type& x)
|
| 189 |
+
{ return emplace_hint(position, x); }
|
| 190 |
+
iterator insert(const_iterator position, value_type&& x)
|
| 191 |
+
{ return emplace_hint(position, std::move(x)); }
|
| 192 |
+
template<class K> iterator insert(const_iterator hint, K&& x);
|
| 193 |
+
|
| 194 |
+
template<class InputIterator>
|
| 195 |
+
void insert(InputIterator first, InputIterator last);
|
| 196 |
+
template<class InputIterator>
|
| 197 |
+
void insert(sorted_unique_t, InputIterator first, InputIterator last);
|
| 198 |
+
template<container-compatible-range<value_type> R>
|
| 199 |
+
void insert_range(R&& rg);
|
| 200 |
+
|
| 201 |
+
void insert(initializer_list<value_type> il)
|
| 202 |
+
{ insert(il.begin(), il.end()); }
|
| 203 |
+
void insert(sorted_unique_t s, initializer_list<value_type> il)
|
| 204 |
+
{ insert(s, il.begin(), il.end()); }
|
| 205 |
+
|
| 206 |
+
container_type extract() &&;
|
| 207 |
+
void replace(container_type&&);
|
| 208 |
+
|
| 209 |
+
iterator erase(iterator position);
|
| 210 |
+
iterator erase(const_iterator position);
|
| 211 |
+
size_type erase(const key_type& x);
|
| 212 |
+
template<class K> size_type erase(K&& x);
|
| 213 |
+
iterator erase(const_iterator first, const_iterator last);
|
| 214 |
+
|
| 215 |
+
void swap(flat_set& y) noexcept;
|
| 216 |
+
void clear() noexcept;
|
| 217 |
+
|
| 218 |
+
// observers
|
| 219 |
+
key_compare key_comp() const;
|
| 220 |
+
value_compare value_comp() const;
|
| 221 |
+
|
| 222 |
+
// set operations
|
| 223 |
+
iterator find(const key_type& x);
|
| 224 |
+
const_iterator find(const key_type& x) const;
|
| 225 |
+
template<class K> iterator find(const K& x);
|
| 226 |
+
template<class K> const_iterator find(const K& x) const;
|
| 227 |
+
|
| 228 |
+
size_type count(const key_type& x) const;
|
| 229 |
+
template<class K> size_type count(const K& x) const;
|
| 230 |
+
|
| 231 |
+
bool contains(const key_type& x) const;
|
| 232 |
+
template<class K> bool contains(const K& x) const;
|
| 233 |
+
|
| 234 |
+
iterator lower_bound(const key_type& x);
|
| 235 |
+
const_iterator lower_bound(const key_type& x) const;
|
| 236 |
+
template<class K> iterator lower_bound(const K& x);
|
| 237 |
+
template<class K> const_iterator lower_bound(const K& x) const;
|
| 238 |
+
|
| 239 |
+
iterator upper_bound(const key_type& x);
|
| 240 |
+
const_iterator upper_bound(const key_type& x) const;
|
| 241 |
+
template<class K> iterator upper_bound(const K& x);
|
| 242 |
+
template<class K> const_iterator upper_bound(const K& x) const;
|
| 243 |
+
|
| 244 |
+
pair<iterator, iterator> equal_range(const key_type& x);
|
| 245 |
+
pair<const_iterator, const_iterator> equal_range(const key_type& x) const;
|
| 246 |
+
template<class K>
|
| 247 |
+
pair<iterator, iterator> equal_range(const K& x);
|
| 248 |
+
template<class K>
|
| 249 |
+
pair<const_iterator, const_iterator> equal_range(const K& x) const;
|
| 250 |
+
|
| 251 |
+
friend bool operator==(const flat_set& x, const flat_set& y);
|
| 252 |
+
|
| 253 |
+
friend synth-three-way-result<value_type>
|
| 254 |
+
operator<=>(const flat_set& x, const flat_set& y);
|
| 255 |
+
|
| 256 |
+
friend void swap(flat_set& x, flat_set& y) noexcept { x.swap(y); }
|
| 257 |
+
|
| 258 |
+
private:
|
| 259 |
+
container_type c; // exposition only
|
| 260 |
+
key_compare compare; // exposition only
|
| 261 |
+
};
|
| 262 |
+
|
| 263 |
+
template<class KeyContainer, class Compare = less<typename KeyContainer::value_type>>
|
| 264 |
+
flat_set(KeyContainer, Compare = Compare())
|
| 265 |
+
-> flat_set<typename KeyContainer::value_type, Compare, KeyContainer>;
|
| 266 |
+
template<class KeyContainer, class Allocator>
|
| 267 |
+
flat_set(KeyContainer, Allocator)
|
| 268 |
+
-> flat_set<typename KeyContainer::value_type,
|
| 269 |
+
less<typename KeyContainer::value_type>, KeyContainer>;
|
| 270 |
+
template<class KeyContainer, class Compare, class Allocator>
|
| 271 |
+
flat_set(KeyContainer, Compare, Allocator)
|
| 272 |
+
-> flat_set<typename KeyContainer::value_type, Compare, KeyContainer>;
|
| 273 |
+
|
| 274 |
+
template<class KeyContainer, class Compare = less<typename KeyContainer::value_type>>
|
| 275 |
+
flat_set(sorted_unique_t, KeyContainer, Compare = Compare())
|
| 276 |
+
-> flat_set<typename KeyContainer::value_type, Compare, KeyContainer>;
|
| 277 |
+
template<class KeyContainer, class Allocator>
|
| 278 |
+
flat_set(sorted_unique_t, KeyContainer, Allocator)
|
| 279 |
+
-> flat_set<typename KeyContainer::value_type,
|
| 280 |
+
less<typename KeyContainer::value_type>, KeyContainer>;
|
| 281 |
+
template<class KeyContainer, class Compare, class Allocator>
|
| 282 |
+
flat_set(sorted_unique_t, KeyContainer, Compare, Allocator)
|
| 283 |
+
-> flat_set<typename KeyContainer::value_type, Compare, KeyContainer>;
|
| 284 |
+
|
| 285 |
+
template<class InputIterator, class Compare = less<iter-value-type<InputIterator>>>
|
| 286 |
+
flat_set(InputIterator, InputIterator, Compare = Compare())
|
| 287 |
+
-> flat_set<iter-value-type<InputIterator>, Compare>;
|
| 288 |
+
|
| 289 |
+
template<class InputIterator, class Compare = less<iter-value-type<InputIterator>>>
|
| 290 |
+
flat_set(sorted_unique_t, InputIterator, InputIterator, Compare = Compare())
|
| 291 |
+
-> flat_set<iter-value-type<InputIterator>, Compare>;
|
| 292 |
+
|
| 293 |
+
template<ranges::input_range R, class Compare = less<ranges::range_value_t<R>>,
|
| 294 |
+
class Allocator = allocator<ranges::range_value_t<R>>>
|
| 295 |
+
flat_set(from_range_t, R&&, Compare = Compare(), Allocator = Allocator())
|
| 296 |
+
-> flat_set<ranges::range_value_t<R>, Compare,
|
| 297 |
+
vector<ranges::range_value_t<R>,
|
| 298 |
+
alloc-rebind<Allocator, ranges::range_value_t<R>>>>;
|
| 299 |
+
|
| 300 |
+
template<ranges::input_range R, class Allocator>
|
| 301 |
+
flat_set(from_range_t, R&&, Allocator)
|
| 302 |
+
-> flat_set<ranges::range_value_t<R>, less<ranges::range_value_t<R>>,
|
| 303 |
+
vector<ranges::range_value_t<R>,
|
| 304 |
+
alloc-rebind<Allocator, ranges::range_value_t<R>>>>;
|
| 305 |
+
|
| 306 |
+
template<class Key, class Compare = less<Key>>
|
| 307 |
+
flat_set(initializer_list<Key>, Compare = Compare())
|
| 308 |
+
-> flat_set<Key, Compare>;
|
| 309 |
+
|
| 310 |
+
template<class Key, class Compare = less<Key>>
|
| 311 |
+
flat_set(sorted_unique_t, initializer_list<Key>, Compare = Compare())
|
| 312 |
+
-> flat_set<Key, Compare>;
|
| 313 |
+
|
| 314 |
+
template<class Key, class Compare, class KeyContainer, class Allocator>
|
| 315 |
+
struct uses_allocator<flat_set<Key, Compare, KeyContainer>, Allocator>
|
| 316 |
+
: bool_constant<uses_allocator_v<KeyContainer, Allocator>> { };
|
| 317 |
+
}
|
| 318 |
+
```
|
| 319 |
+
|
| 320 |
+
#### Constructors <a id="flat.set.cons">[[flat.set.cons]]</a>
|
| 321 |
+
|
| 322 |
+
``` cpp
|
| 323 |
+
explicit flat_set(container_type cont, const key_compare& comp = key_compare());
|
| 324 |
+
```
|
| 325 |
+
|
| 326 |
+
*Effects:* Initializes *c* with `std::move(cont)` and *compare* with
|
| 327 |
+
`comp`, sorts the range \[`begin()`, `end()`) with respect to *compare*,
|
| 328 |
+
and finally erases all but the first element from each group of
|
| 329 |
+
consecutive equivalent elements.
|
| 330 |
+
|
| 331 |
+
*Complexity:* Linear in N if `cont` is sorted with respect to *compare*
|
| 332 |
+
and otherwise N log N, where N is the value of `cont.size()` before this
|
| 333 |
+
call.
|
| 334 |
+
|
| 335 |
+
``` cpp
|
| 336 |
+
template<class Allocator>
|
| 337 |
+
flat_set(const container_type& cont, const Allocator& a);
|
| 338 |
+
template<class Allocator>
|
| 339 |
+
flat_set(const container_type& cont, const key_compare& comp, const Allocator& a);
|
| 340 |
+
```
|
| 341 |
+
|
| 342 |
+
*Constraints:* `uses_allocator_v<container_type, Allocator>` is `true`.
|
| 343 |
+
|
| 344 |
+
*Effects:* Equivalent to `flat_set(cont)` and `flat_set(cont, comp)`,
|
| 345 |
+
respectively, except that *c* is constructed with uses-allocator
|
| 346 |
+
construction [[allocator.uses.construction]].
|
| 347 |
+
|
| 348 |
+
*Complexity:* Same as `flat_set(cont)` and `flat_set(cont, comp)`,
|
| 349 |
+
respectively.
|
| 350 |
+
|
| 351 |
+
``` cpp
|
| 352 |
+
template<class Allocator>
|
| 353 |
+
flat_set(sorted_unique_t s, const container_type& cont, const Allocator& a);
|
| 354 |
+
template<class Allocator>
|
| 355 |
+
flat_set(sorted_unique_t s, const container_type& cont,
|
| 356 |
+
const key_compare& comp, const Allocator& a);
|
| 357 |
+
```
|
| 358 |
+
|
| 359 |
+
*Constraints:* `uses_allocator_v<container_type, Allocator>` is `true`.
|
| 360 |
+
|
| 361 |
+
*Effects:* Equivalent to `flat_set(s, cont)` and
|
| 362 |
+
`flat_set(s, cont, comp)`, respectively, except that *c* is constructed
|
| 363 |
+
with uses-allocator construction [[allocator.uses.construction]].
|
| 364 |
+
|
| 365 |
+
*Complexity:* Linear.
|
| 366 |
+
|
| 367 |
+
``` cpp
|
| 368 |
+
template<class Allocator>
|
| 369 |
+
flat_set(const key_compare& comp, const Allocator& a);
|
| 370 |
+
template<class Allocator>
|
| 371 |
+
explicit flat_set(const Allocator& a);
|
| 372 |
+
template<class InputIterator, class Allocator>
|
| 373 |
+
flat_set(InputIterator first, InputIterator last, const key_compare& comp, const Allocator& a);
|
| 374 |
+
template<class InputIterator, class Allocator>
|
| 375 |
+
flat_set(InputIterator first, InputIterator last, const Allocator& a);
|
| 376 |
+
template<container-compatible-range<value_type> R, class Allocator>
|
| 377 |
+
flat_set(from_range_t, R&& rg, const Allocator& a);
|
| 378 |
+
template<container-compatible-range<value_type> R, class Allocator>
|
| 379 |
+
flat_set(from_range_t, R&& rg, const key_compare& comp, const Allocator& a);
|
| 380 |
+
template<class InputIterator, class Allocator>
|
| 381 |
+
flat_set(sorted_unique_t, InputIterator first, InputIterator last,
|
| 382 |
+
const key_compare& comp, const Allocator& a);
|
| 383 |
+
template<class InputIterator, class Allocator>
|
| 384 |
+
flat_set(sorted_unique_t, InputIterator first, InputIterator last, const Allocator& a);
|
| 385 |
+
template<class Allocator>
|
| 386 |
+
flat_set(initializer_list<value_type> il, const key_compare& comp, const Allocator& a);
|
| 387 |
+
template<class Allocator>
|
| 388 |
+
flat_set(initializer_list<value_type> il, const Allocator& a);
|
| 389 |
+
template<class Allocator>
|
| 390 |
+
flat_set(sorted_unique_t, initializer_list<value_type> il,
|
| 391 |
+
const key_compare& comp, const Allocator& a);
|
| 392 |
+
template<class Allocator>
|
| 393 |
+
flat_set(sorted_unique_t, initializer_list<value_type> il, const Allocator& a);
|
| 394 |
+
```
|
| 395 |
+
|
| 396 |
+
*Constraints:* `uses_allocator_v<container_type, Allocator>` is `true`.
|
| 397 |
+
|
| 398 |
+
*Effects:* Equivalent to the corresponding non-allocator constructors
|
| 399 |
+
except that *c* is constructed with uses-allocator
|
| 400 |
+
construction [[allocator.uses.construction]].
|
| 401 |
+
|
| 402 |
+
#### Modifiers <a id="flat.set.modifiers">[[flat.set.modifiers]]</a>
|
| 403 |
+
|
| 404 |
+
``` cpp
|
| 405 |
+
template<class K> pair<iterator, bool> insert(K&& x);
|
| 406 |
+
template<class K> iterator insert(const_iterator hint, K&& x);
|
| 407 |
+
```
|
| 408 |
+
|
| 409 |
+
*Constraints:* The *qualified-id* `Compare::is_transparent` is valid and
|
| 410 |
+
denotes a type. `is_constructible_v<value_type, K>` is `true`.
|
| 411 |
+
|
| 412 |
+
*Preconditions:* The conversion from `x` into `value_type` constructs an
|
| 413 |
+
object `u`, for which `find(x) == find(u)` is true.
|
| 414 |
+
|
| 415 |
+
*Effects:* If the set already contains an element equivalent to `x`,
|
| 416 |
+
`*this` and `x` are unchanged. Otherwise, inserts a new element as if by
|
| 417 |
+
`emplace(std::forward<K>(x))`.
|
| 418 |
+
|
| 419 |
+
*Returns:* In the first overload, the `bool` component of the returned
|
| 420 |
+
pair is `true` if and only if the insertion took place. The returned
|
| 421 |
+
iterator points to the element whose key is equivalent to `x`.
|
| 422 |
+
|
| 423 |
+
``` cpp
|
| 424 |
+
template<class InputIterator>
|
| 425 |
+
void insert(InputIterator first, InputIterator last);
|
| 426 |
+
```
|
| 427 |
+
|
| 428 |
+
*Effects:* Adds elements to *c* as if by:
|
| 429 |
+
|
| 430 |
+
``` cpp
|
| 431 |
+
c.insert(c.end(), first, last);
|
| 432 |
+
```
|
| 433 |
+
|
| 434 |
+
Then, sorts the range of newly inserted elements with respect to
|
| 435 |
+
*compare*; merges the resulting sorted range and the sorted range of
|
| 436 |
+
pre-existing elements into a single sorted range; and finally erases all
|
| 437 |
+
but the first element from each group of consecutive equivalent
|
| 438 |
+
elements.
|
| 439 |
+
|
| 440 |
+
*Complexity:* N + M log M, where N is `size()` before the operation and
|
| 441 |
+
M is `distance(first, last)`.
|
| 442 |
+
|
| 443 |
+
*Remarks:* Since this operation performs an in-place merge, it may
|
| 444 |
+
allocate memory.
|
| 445 |
+
|
| 446 |
+
``` cpp
|
| 447 |
+
template<class InputIterator>
|
| 448 |
+
void insert(sorted_unique_t, InputIterator first, InputIterator last);
|
| 449 |
+
```
|
| 450 |
+
|
| 451 |
+
*Effects:* Equivalent to `insert(first, last)`.
|
| 452 |
+
|
| 453 |
+
*Complexity:* Linear.
|
| 454 |
+
|
| 455 |
+
``` cpp
|
| 456 |
+
template<container-compatible-range<value_type> R>
|
| 457 |
+
void insert_range(R&& rg);
|
| 458 |
+
```
|
| 459 |
+
|
| 460 |
+
*Effects:* Adds elements to *c* as if by:
|
| 461 |
+
|
| 462 |
+
``` cpp
|
| 463 |
+
for (const auto& e : rg) {
|
| 464 |
+
c.insert(c.end(), e);
|
| 465 |
+
}
|
| 466 |
+
```
|
| 467 |
+
|
| 468 |
+
Then, sorts the range of newly inserted elements with respect to
|
| 469 |
+
*compare*; merges the resulting sorted range and the sorted range of
|
| 470 |
+
pre-existing elements into a single sorted range; and finally erases all
|
| 471 |
+
but the first element from each group of consecutive equivalent
|
| 472 |
+
elements.
|
| 473 |
+
|
| 474 |
+
*Complexity:* N + M log M, where N is `size()` before the operation and
|
| 475 |
+
M is `ranges::distance(rg)`.
|
| 476 |
+
|
| 477 |
+
*Remarks:* Since this operation performs an in-place merge, it may
|
| 478 |
+
allocate memory.
|
| 479 |
+
|
| 480 |
+
``` cpp
|
| 481 |
+
void swap(flat_set& y) noexcept;
|
| 482 |
+
```
|
| 483 |
+
|
| 484 |
+
*Effects:* Equivalent to:
|
| 485 |
+
|
| 486 |
+
``` cpp
|
| 487 |
+
ranges::swap(compare, y.compare);
|
| 488 |
+
ranges::swap(c, y.c);
|
| 489 |
+
```
|
| 490 |
+
|
| 491 |
+
``` cpp
|
| 492 |
+
container_type extract() &&;
|
| 493 |
+
```
|
| 494 |
+
|
| 495 |
+
*Ensures:* `*this` is emptied, even if the function exits via an
|
| 496 |
+
exception.
|
| 497 |
+
|
| 498 |
+
*Returns:* `std::move(`*`c`*`)`.
|
| 499 |
+
|
| 500 |
+
``` cpp
|
| 501 |
+
void replace(container_type&& cont);
|
| 502 |
+
```
|
| 503 |
+
|
| 504 |
+
*Preconditions:* The elements of `cont` are sorted with respect to
|
| 505 |
+
*compare*, and `cont` contains no equal elements.
|
| 506 |
+
|
| 507 |
+
*Effects:* Equivalent to: *`c`*` = std::move(cont);`
|
| 508 |
+
|
| 509 |
+
#### Erasure <a id="flat.set.erasure">[[flat.set.erasure]]</a>
|
| 510 |
+
|
| 511 |
+
``` cpp
|
| 512 |
+
template<class Key, class Compare, class KeyContainer, class Predicate>
|
| 513 |
+
typename flat_set<Key, Compare, KeyContainer>::size_type
|
| 514 |
+
erase_if(flat_set<Key, Compare, KeyContainer>& c, Predicate pred);
|
| 515 |
+
```
|
| 516 |
+
|
| 517 |
+
*Preconditions:* `Key` meets the *Cpp17MoveAssignable* requirements.
|
| 518 |
+
|
| 519 |
+
*Effects:* Let E be `bool(pred(as_const(e)))`. Erases all elements `e`
|
| 520 |
+
in `c` for which E holds.
|
| 521 |
+
|
| 522 |
+
*Returns:* The number of elements erased.
|
| 523 |
+
|
| 524 |
+
*Complexity:* Exactly `c.size()` applications of the predicate.
|
| 525 |
+
|
| 526 |
+
*Remarks:* Stable [[algorithm.stable]]. If an invocation of `erase_if`
|
| 527 |
+
exits via an exception, `c` is in a valid but unspecified
|
| 528 |
+
state [[defns.valid]].
|
| 529 |
+
|
| 530 |
+
[*Note 1*: `c` still meets its invariants, but can be
|
| 531 |
+
empty. — *end note*]
|
| 532 |
+
|