Files
cppdraft_translate/cppdraft/associative/reqmts.md
2025-10-25 03:02:53 +03:00

1707 lines
55 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[associative.reqmts]
# 23 Containers library [[containers]](./#containers)
## 23.2 Requirements [[container.requirements]](container.requirements#associative.reqmts)
### 23.2.7 Associative containers [associative.reqmts]
#### [23.2.7.1](#general) General [[associative.reqmts.general]](associative.reqmts.general)
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2630)
Associative containers provide fast retrieval of data based on keys[.](#general-1.sentence-1)
The library provides four basic kinds of associative containers:set,multiset,map andmultimap[.](#general-1.sentence-2)
The library also provides container adaptors
that make it easy to construct abstract data types,
such as flat_maps, flat_multimaps,flat_sets, or flat_multisets,
out of the basic sequence container kinds
(or out of other program-defined sequence containers)[.](#general-1.sentence-3)
[2](#general-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2645)
Each associative container is parameterized onKey and an ordering relationCompare that induces a strict weak ordering ([[alg.sorting]](alg.sorting "26.8Sorting and related operations")) on
elements ofKey[.](#general-2.sentence-1)
In addition,map andmultimap associate an arbitrary [*mapped type*](#def:mapped_type)T with theKey[.](#general-2.sentence-2)
The object of typeCompare is called the[*comparison object*](#def:comparison_object) of a container[.](#general-2.sentence-3)
[3](#general-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2667)
The phrase “equivalence of keys” means the equivalence relation imposed by the
comparison object[.](#general-3.sentence-1)
That is, two keysk1 andk2 are considered to be equivalent if for the
comparison objectcomp,comp(k1, k2) == false && comp(k2, k1) == false[.](#general-3.sentence-2)
[*Note [1](#general-note-1)*:
This is not necessarily the same as the result of k1 == k2[.](#general-3.sentence-3)
— *end note*]
For any two keysk1 andk2 in the same container, callingcomp(k1, k2) shall always return the same value[.](#general-3.sentence-4)
[4](#general-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2689)
An associative container supports [*unique keys*](#def:unique_keys) if it may contain at
most one element for each key[.](#general-4.sentence-1)
Otherwise, it supports [*equivalent keys*](#def:equivalent_keys)[.](#general-4.sentence-2)
The set and map classes support unique keys; the multiset and multimap classes support equivalent keys[.](#general-4.sentence-3)
For multiset and multimap,insert, emplace, and erase preserve the relative ordering
of equivalent elements[.](#general-4.sentence-4)
[5](#general-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2698)
For set and multiset the value type is the same as the key type[.](#general-5.sentence-1)
For map and multimap it is equal to pair<const Key, T>[.](#general-5.sentence-2)
[6](#general-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2702)
iterator of an associative container is of the bidirectional iterator category[.](#general-6.sentence-1)
For associative containers where the value type is the same as the key type, bothiterator andconst_iterator are constant iterators[.](#general-6.sentence-2)
It is unspecified whether or notiterator andconst_iterator are the same type[.](#general-6.sentence-3)
[*Note [2](#general-note-2)*:
iterator and const_iterator have identical semantics in this case, and iterator is convertible to const_iterator[.](#general-6.sentence-4)
Users can avoid violating the one-definition rule by always using const_iterator in their function parameter lists[.](#general-6.sentence-5)
— *end note*]
[7](#general-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2718)
In this subclause,
- [(7.1)](#general-7.1)
X denotes an associative container class,
- [(7.2)](#general-7.2)
a denotes a value of type X,
- [(7.3)](#general-7.3)
a2 denotes a value of a type with nodes compatible with typeX (Table [75](container.node.overview#tab:container.node.compat "Table 75: Container types with compatible nodes")),
- [(7.4)](#general-7.4)
b denotes a value of type X or const X,
- [(7.5)](#general-7.5)
u denotes the name of a variable being declared,
- [(7.6)](#general-7.6)
a_uniq denotes a value of type X when X supports unique keys,
- [(7.7)](#general-7.7)
a_eq denotes a value of type X when X supports equivalent keys,
- [(7.8)](#general-7.8)
a_tran denotes a value of type X or const X when the [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3Qualified names[expr.prim.id.qual]")X::key_compare::is_transparent is valid
and denotes a type ([[temp.deduct]](temp.deduct "13.10.3Template argument deduction")),
- [(7.9)](#general-7.9)
i and j meet the *Cpp17InputIterator* requirements and refer to elements
implicitly convertible tovalue_type,
- [(7.10)](#general-7.10)
[i, j) denotes a valid range,
- [(7.11)](#general-7.11)
rg denotes a value of a type R that models [*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1Introduction[container.intro.reqmts]")<value_type>,
- [(7.12)](#general-7.12)
p denotes a valid constant iterator to a,
- [(7.13)](#general-7.13)
q denotes a valid dereferenceable constant iterator to a,
- [(7.14)](#general-7.14)
r denotes a valid dereferenceable iterator to a,
- [(7.15)](#general-7.15)
[q1, q2) denotes a valid range of constant iterators in a,
- [(7.16)](#general-7.16)
il designates an object of type initializer_list<value_type>,
- [(7.17)](#general-7.17)
t denotes a value of type X::value_type,
- [(7.18)](#general-7.18)
k denotes a value of type X::key_type, and
- [(7.19)](#general-7.19)
c denotes a value of type X::key_compare or const X::key_compare;
- [(7.20)](#general-7.20)
kl is a value such that a is partitioned ([[alg.sorting]](alg.sorting "26.8Sorting and related operations"))
with respect to c(x, kl),
with x the key value of e and e in a;
- [(7.21)](#general-7.21)
ku is a value such that a is partitioned with respect to!c(ku, x),
with x the key value of e and e in a;
- [(7.22)](#general-7.22)
ke is a value such that a is partitioned with respect toc(x, ke) and !c(ke, x), with c(x, ke) implying!c(ke, x) and
with x the key value of e and e in a;
- [(7.23)](#general-7.23)
kx is a value such that
* [(7.23.1)](#general-7.23.1)
a is partitioned with respect to c(x, kx) and !c(kx, x),
with c(x, kx) implying !c(kx, x) and
with x the key value of e and e in a, and
* [(7.23.2)](#general-7.23.2)
kx is not convertible to
either iterator or const_iterator; and
- [(7.24)](#general-7.24)
A denotes the storage allocator used by X, if any, or allocator<X::value_type> otherwise,
- [(7.25)](#general-7.25)
m denotes an allocator of a type convertible to A,
and nh denotes a non-const rvalue of type X::node_type[.](#general-7.sentence-1)
[8](#general-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2800)
A type X meets the [*associative container*](#def:container,associative "23.2.7.1General[associative.reqmts.general]") requirements
if X meets all the requirements of an allocator-aware
container ([[container.alloc.reqmts]](container.alloc.reqmts "23.2.2.5Allocator-aware containers")) and
the following types, statements, and expressions are well-formed and
have the specified semantics,
except that formap and multimap, the requirements placed on value_type in [[container.reqmts]](container.reqmts "23.2.2.2Container requirements") apply instead to key_type and mapped_type[.](#general-8.sentence-1)
[*Note [3](#general-note-3)*:
For example, in some cases key_type and mapped_type need to be *Cpp17CopyAssignable* even though the associatedvalue_type, pair<const key_type, mapped_type>, is not*Cpp17CopyAssignable*[.](#general-8.sentence-2)
— *end note*]
[🔗](#lib:key_type,ordered_associative_containers)
`typename X::key_type
`
[9](#general-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2836)
*Result*: Key[.](#general-9.sentence-1)
[🔗](#lib:mapped_type,ordered_associative_containers)
`typename X::mapped_type
`
[10](#general-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2847)
*Result*: T[.](#general-10.sentence-1)
[11](#general-11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2851)
*Remarks*: For map and multimap only[.](#general-11.sentence-1)
[🔗](#lib:value_type,ordered_associative_containers)
`typename X::value_type
`
[12](#general-12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2862)
*Result*: Key for set and multiset only;pair<const Key, T> for map and multimap only[.](#general-12.sentence-1)
[13](#general-13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2867)
*Preconditions*: X::value_type is *Cpp17Erasable* from X[.](#general-13.sentence-1)
[🔗](#lib:key_compare,ordered_associative_containers)
`typename X::key_compare
`
[14](#general-14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2878)
*Result*: Compare[.](#general-14.sentence-1)
[15](#general-15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2882)
*Preconditions*: key_compare is *Cpp17CopyConstructible*[.](#general-15.sentence-1)
[🔗](#lib:value_compare,ordered_associative_containers)
`typename X::value_compare
`
[16](#general-16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2893)
*Result*: A binary predicate type[.](#general-16.sentence-1)
It is the same as key_compare for set andmultiset; is an ordering relation on pairs induced by the
first component (i.e., Key) for map and multimap[.](#general-16.sentence-2)
[🔗](#lib:node_type,ordered_associative_containers)
`typename X::node_type
`
[17](#general-17)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2907)
*Result*: A specialization of
the *node-handle* class template ([[container.node]](container.node "23.2.5Node handles")),
such that the public nested types are
the same types as the corresponding types in X[.](#general-17.sentence-1)
[🔗](#lib:set,constructor)
`X(c)
`
[18](#general-18)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2924)
*Effects*: Constructs an empty container[.](#general-18.sentence-1)
Uses a copy of c as a comparison object[.](#general-18.sentence-2)
[19](#general-19)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2929)
*Complexity*: Constant[.](#general-19.sentence-1)
[🔗](#lib:set,constructor_)
`X u = X();
X u;
`
[20](#general-20)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2944)
*Preconditions*: key_compare meets the *Cpp17DefaultConstructible* requirements[.](#general-20.sentence-1)
[21](#general-21)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2948)
*Effects*: Constructs an empty container[.](#general-21.sentence-1)
Uses Compare() as a comparison object[.](#general-21.sentence-2)
[22](#general-22)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2953)
*Complexity*: Constant[.](#general-22.sentence-1)
[🔗](#lib:set,constructor__)
`X(i, j, c)
`
[23](#general-23)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2967)
*Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from *i[.](#general-23.sentence-1)
[24](#general-24)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2972)
*Effects*: Constructs an empty container and
inserts elements from the range [i, j) into it;
uses c as a comparison object[.](#general-24.sentence-1)
[25](#general-25)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2978)
*Complexity*: NlogN in general, where N has the value distance(i, j);
linear if [i, j) is sorted with respect to value_comp()[.](#general-25.sentence-1)
[🔗](#lib:set,constructor___)
`X(i, j)
`
[26](#general-26)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2993)
*Preconditions*: key_compare meets the *Cpp17DefaultConstructible* requirements[.](#general-26.sentence-1)
value_type is*Cpp17EmplaceConstructible* into X from *i[.](#general-26.sentence-2)
[27](#general-27)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2999)
*Effects*: Constructs an empty container and
inserts elements from the range [i, j) into it;
uses Compare() as a comparison object[.](#general-27.sentence-1)
[28](#general-28)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3005)
*Complexity*: NlogN in general, where N has the value distance(i, j);
linear if [i, j) is sorted with respect to value_comp()[.](#general-28.sentence-1)
[🔗](#lib:set,constructor____)
`X(from_range, rg, c)
`
[29](#general-29)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3020)
*Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from *ranges::begin(rg)[.](#general-29.sentence-1)
[30](#general-30)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3026)
*Effects*: Constructs an empty container and
inserts each element from rg into it[.](#general-30.sentence-1)
Uses c as the comparison object[.](#general-30.sentence-2)
[31](#general-31)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3032)
*Complexity*: NlogN in general, where N has the value ranges::distance(rg);
linear if rg is sorted with respect to value_comp()[.](#general-31.sentence-1)
[🔗](#lib:set,constructor_____)
`X(from_range, rg)
`
[32](#general-32)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3047)
*Preconditions*: key_compare meets the *Cpp17DefaultConstructible* requirements[.](#general-32.sentence-1)
value_type is *Cpp17EmplaceConstructible* into X from *ranges::begin(rg)[.](#general-32.sentence-2)
[33](#general-33)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3053)
*Effects*: Constructs an empty container and
inserts each element from rg into it[.](#general-33.sentence-1)
Uses Compare() as the comparison object[.](#general-33.sentence-2)
[34](#general-34)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3059)
*Complexity*: Same as X(from_range, rg, c)[.](#general-34.sentence-1)
[🔗](#lib:set,constructor______)
`X(il, c)
`
[35](#general-35)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3073)
*Effects*: Equivalent to X(il.begin(), il.end(), c)[.](#general-35.sentence-1)
[🔗](#lib:set,constructor_______)
`X(il)
`
[36](#general-36)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3087)
*Effects*: Equivalent to X(il.begin(), il.end())[.](#general-36.sentence-1)
[🔗](#general-itemdecl:15)
`a = il
`
[37](#general-37)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3097)
*Result*: X&
[38](#general-38)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3101)
*Preconditions*: value_type is *Cpp17CopyInsertable* into X and *Cpp17CopyAssignable*[.](#general-38.sentence-1)
[39](#general-39)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3106)
*Effects*: Assigns the range [il.begin(), il.end()) into a[.](#general-39.sentence-1)
All existing elements of a are either assigned to or destroyed[.](#general-39.sentence-2)
[40](#general-40)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3111)
*Complexity*: NlogN in general, where N has the value il.size() + a.size();
linear if [il.begin(), il.end()) is sorted with respect to value_comp()[.](#general-40.sentence-1)
[🔗](#lib:key_comp,ordered_associative_containers)
`b.key_comp()
`
[41](#general-41)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3123)
*Result*: X::key_compare
[42](#general-42)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3127)
*Returns*: The comparison object out of which b was constructed[.](#general-42.sentence-1)
[43](#general-43)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3131)
*Complexity*: Constant[.](#general-43.sentence-1)
[🔗](#lib:value_comp,ordered_associative_containers)
`b.value_comp()
`
[44](#general-44)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3142)
*Result*: X::value_compare
[45](#general-45)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3146)
*Returns*: An object of value_compare constructed out of the comparison object[.](#general-45.sentence-1)
[46](#general-46)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3150)
*Complexity*: Constant[.](#general-46.sentence-1)
[🔗](#lib:emplace,ordered_associative_containers)
`a_uniq.emplace(args)
`
[47](#general-47)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3161)
*Result*: pair<iterator, bool>
[48](#general-48)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3165)
*Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from args[.](#general-48.sentence-1)
[49](#general-49)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3170)
*Effects*: Inserts a value_type object t constructed with std::forward<Args>(args)... if and only if there is no element in the container
with key equivalent to the key of t[.](#general-49.sentence-1)
[50](#general-50)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3177)
*Returns*: The bool component of the returned pair is true if and only if the insertion takes place, and
the iterator component of the pair points to
the element with key equivalent to the key of t[.](#general-50.sentence-1)
[51](#general-51)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3184)
*Complexity*: Logarithmic[.](#general-51.sentence-1)
[🔗](#lib:emplace,ordered_associative_containers_)
`a_eq.emplace(args)
`
[52](#general-52)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3195)
*Result*: iterator
[53](#general-53)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3199)
*Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from args[.](#general-53.sentence-1)
[54](#general-54)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3204)
*Effects*: Inserts a value_type object t constructed with std::forward<Args>(args)...[.](#general-54.sentence-1)
If a range containing elements equivalent to t exists in a_eq,t is inserted at the end of that range[.](#general-54.sentence-2)
[55](#general-55)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3211)
*Returns*: An iterator pointing to the newly inserted element[.](#general-55.sentence-1)
[56](#general-56)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3215)
*Complexity*: Logarithmic[.](#general-56.sentence-1)
[🔗](#lib:emplace_hint,ordered_associative_containers)
`a.emplace_hint(p, args)
`
[57](#general-57)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3226)
*Result*: iterator
[58](#general-58)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3230)
*Effects*: Equivalent to a.emplace(std::forward<Args>(args)...),
except that the element is inserted as close as possible to
the position just prior to p[.](#general-58.sentence-1)
[59](#general-59)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3236)
*Returns*: The iterator returned by emplace[.](#general-59.sentence-1)
[60](#general-60)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3240)
*Complexity*: Logarithmic in general, but
amortized constant if the element is inserted right before p[.](#general-60.sentence-1)
[🔗](#lib:insert,ordered_associative_containers)
`a_uniq.insert(t)
`
[61](#general-61)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3252)
*Result*: pair<iterator, bool>
[62](#general-62)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3256)
*Preconditions*: If t is a non-const rvalue,value_type is *Cpp17MoveInsertable* into X;
otherwise, value_type is *Cpp17CopyInsertable* into X[.](#general-62.sentence-1)
[63](#general-63)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3262)
*Effects*: Inserts t if and only if there is no element in the container
with key equivalent to the key of t[.](#general-63.sentence-1)
[64](#general-64)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3267)
*Returns*: The bool component of the returned pair is true if and only if the insertion takes place, and
the iterator component of the pair points to
the element with key equivalent to the key of t[.](#general-64.sentence-1)
[65](#general-65)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3274)
*Complexity*: Logarithmic[.](#general-65.sentence-1)
[🔗](#lib:insert,ordered_associative_containers_)
`a_eq.insert(t)
`
[66](#general-66)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3285)
*Result*: iterator
[67](#general-67)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3289)
*Preconditions*: If t is a non-const rvalue,value_type is *Cpp17MoveInsertable* into X;
otherwise, value_type is *Cpp17CopyInsertable* into X[.](#general-67.sentence-1)
[68](#general-68)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3295)
*Effects*: Inserts t and returns the iterator pointing to
the newly inserted element[.](#general-68.sentence-1)
If a range containing elements equivalent to t exists in a_eq,t is inserted at the end of that range[.](#general-68.sentence-2)
[69](#general-69)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3302)
*Complexity*: Logarithmic[.](#general-69.sentence-1)
[🔗](#lib:insert,ordered_associative_containers__)
`a.insert(p, t)
`
[70](#general-70)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3313)
*Result*: iterator
[71](#general-71)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3317)
*Preconditions*: If t is a non-const rvalue,value_type is *Cpp17MoveInsertable* into X;
otherwise, value_type is *Cpp17CopyInsertable* into X[.](#general-71.sentence-1)
[72](#general-72)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3323)
*Effects*: Inserts t if and only if there is no element
with key equivalent to the key of t in containers with unique keys;
always inserts t in containers with equivalent keys[.](#general-72.sentence-1)
t is inserted as close as possible to
the position just prior to p[.](#general-72.sentence-2)
[73](#general-73)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3331)
*Returns*: An iterator pointing to the element with key equivalent to the key of t[.](#general-73.sentence-1)
[74](#general-74)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3335)
*Complexity*: Logarithmic in general, but
amortized constant if t is inserted right before p[.](#general-74.sentence-1)
[🔗](#lib:insert,ordered_associative_containers___)
`a.insert(i, j)
`
[75](#general-75)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3347)
*Result*: void
[76](#general-76)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3351)
*Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from *i[.](#general-76.sentence-1)
Neither i nor j are iterators into a[.](#general-76.sentence-2)
[77](#general-77)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3357)
*Effects*: Inserts each element from the range [i, j)
if and only if there is no element
with key equivalent to the key of that element in containers with unique keys;
always inserts that element in containers with equivalent keys[.](#general-77.sentence-1)
[78](#general-78)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3364)
*Complexity*: Nlog(a.size()+N), where N has the value distance(i, j)[.](#general-78.sentence-1)
[🔗](#lib:insert,ordered_associative_containers____)
`a.insert_range(rg)
`
[79](#general-79)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3375)
*Result*: void
[80](#general-80)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3379)
*Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from *ranges::begin(rg)[.](#general-80.sentence-1)
rg and a do not overlap[.](#general-80.sentence-2)
[81](#general-81)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3386)
*Effects*: Inserts each element from rg if and only if
there is no element with key equivalent to the key of that element
in containers with unique keys;
always inserts that element in containers with equivalent keys[.](#general-81.sentence-1)
[82](#general-82)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3393)
*Complexity*: Nlog(a.size()+N),
where N has the value ranges::distance(rg)[.](#general-82.sentence-1)
[🔗](#lib:insert,ordered_associative_containers_____)
`a.insert(il)
`
[83](#general-83)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3405)
*Effects*: Equivalent to a.insert(il.begin(), il.end())[.](#general-83.sentence-1)
[🔗](#lib:insert,ordered_associative_containers______)
`a_uniq.insert(nh)
`
[84](#general-84)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3416)
*Result*: insert_return_type
[85](#general-85)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3420)
*Preconditions*: nh is empty ora_uniq.get_allocator() == nh.get_allocator() is true[.](#general-85.sentence-1)
[86](#general-86)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3425)
*Effects*: If nh is empty, has no effect[.](#general-86.sentence-1)
Otherwise, inserts the element owned by nh if and only if
there is no element in the container with a key equivalent to nh.key()[.](#general-86.sentence-2)
[87](#general-87)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3431)
*Returns*: If nh is empty, inserted is false,position is end(), and node is empty[.](#general-87.sentence-1)
Otherwise if the insertion took place, inserted is true,position points to the inserted element, and node is empty;
if the insertion failed, inserted is false,node has the previous value of nh, andposition points to an element with a key equivalent to nh.key()[.](#general-87.sentence-2)
[88](#general-88)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3441)
*Complexity*: Logarithmic[.](#general-88.sentence-1)
[🔗](#lib:insert,ordered_associative_containers_______)
`a_eq.insert(nh)
`
[89](#general-89)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3452)
*Result*: iterator
[90](#general-90)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3456)
*Preconditions*: nh is empty ora_eq.get_allocator() == nh.get_allocator() is true[.](#general-90.sentence-1)
[91](#general-91)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3461)
*Effects*: If nh is empty, has no effect and returns a_eq.end()[.](#general-91.sentence-1)
Otherwise, inserts the element owned by nh and
returns an iterator pointing to the newly inserted element[.](#general-91.sentence-2)
If a range containing elements with keys equivalent to nh.key() exists in a_eq,
the element is inserted at the end of that range[.](#general-91.sentence-3)
[92](#general-92)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3470)
*Postconditions*: nh is empty[.](#general-92.sentence-1)
[93](#general-93)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3474)
*Complexity*: Logarithmic[.](#general-93.sentence-1)
[🔗](#lib:insert,ordered_associative_containers________)
`a.insert(p, nh)
`
[94](#general-94)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3485)
*Result*: iterator
[95](#general-95)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3489)
*Preconditions*: nh is empty ora.get_allocator() == nh.get_allocator() is true[.](#general-95.sentence-1)
[96](#general-96)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3494)
*Effects*: If nh is empty, has no effect and returns a.end()[.](#general-96.sentence-1)
Otherwise, inserts the element owned by nh if and only if
there is no element with key equivalent to nh.key() in containers with unique keys;
always inserts the element owned by nh in containers with equivalent keys[.](#general-96.sentence-2)
The element is inserted as close as possible to
the position just prior to p[.](#general-96.sentence-3)
[97](#general-97)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3505)
*Postconditions*: nh is empty if insertion succeeds, unchanged if insertion fails[.](#general-97.sentence-1)
[98](#general-98)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3509)
*Returns*: An iterator pointing to the element with key equivalent to nh.key()[.](#general-98.sentence-1)
[99](#general-99)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3513)
*Complexity*: Logarithmic in general, but
amortized constant if the element is inserted right before p[.](#general-99.sentence-1)
[🔗](#lib:extract,ordered_associative_containers)
`a.extract(k)
`
[100](#general-100)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3526)
*Result*: node_type
[101](#general-101)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3530)
*Effects*: Removes the first element in the container with key equivalent to k[.](#general-101.sentence-1)
[102](#general-102)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3534)
*Returns*: A node_type owning the element if found,
otherwise an empty node_type[.](#general-102.sentence-1)
[103](#general-103)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3539)
*Complexity*: log(a.size())
[🔗](#lib:extract,ordered_associative_containers_)
`a_tran.extract(kx)
`
[104](#general-104)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3550)
*Result*: node_type
[105](#general-105)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3554)
*Effects*: Removes the first element in the container with key r such that !c(r, kx) && !c(kx, r) is true[.](#general-105.sentence-1)
[106](#general-106)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3559)
*Returns*: A node_type owning the element if found,
otherwise an empty node_type[.](#general-106.sentence-1)
[107](#general-107)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3564)
*Complexity*: log(a_tran.size())
[🔗](#lib:extract,ordered_associative_containers__)
`a.extract(q)
`
[108](#general-108)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3575)
*Result*: node_type
[109](#general-109)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3579)
*Effects*: Removes the element pointed to by q[.](#general-109.sentence-1)
[110](#general-110)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3583)
*Returns*: A node_type owning that element[.](#general-110.sentence-1)
[111](#general-111)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3587)
*Complexity*: Amortized constant[.](#general-111.sentence-1)
[🔗](#lib:merge,ordered_associative_containers)
`a.merge(a2)
`
[112](#general-112)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3598)
*Result*: void
[113](#general-113)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3602)
*Preconditions*: a.get_allocator() == a2.get_allocator() is true[.](#general-113.sentence-1)
[114](#general-114)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3606)
*Effects*: Attempts to extract each element in a2 and insert it into a using the comparison object of a[.](#general-114.sentence-1)
In containers with unique keys,
if there is an element in a with key equivalent to
the key of an element from a2,
then that element is not extracted from a2[.](#general-114.sentence-2)
[115](#general-115)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3615)
*Postconditions*: Pointers and references to the transferred elements of a2 refer to those same elements but as members of a[.](#general-115.sentence-1)
If a.begin() and a2.begin() have the same type,
iterators referring to the transferred elements
will continue to refer to their elements,
but they now behave as iterators into a, not into a2[.](#general-115.sentence-2)
[116](#general-116)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3624)
*Throws*: Nothing unless the comparison object throws[.](#general-116.sentence-1)
[117](#general-117)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3628)
*Complexity*: Nlog(a.size()+N), where N has the value a2.size()[.](#general-117.sentence-1)
[🔗](#lib:erase,ordered_associative_containers)
`a.erase(k)
`
[118](#general-118)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3639)
*Result*: size_type
[119](#general-119)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3643)
*Effects*: Erases all elements in the container with key equivalent to k[.](#general-119.sentence-1)
[120](#general-120)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3647)
*Returns*: The number of erased elements[.](#general-120.sentence-1)
[121](#general-121)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3651)
*Complexity*: log(a.size())+a.count(k)
[🔗](#lib:erase,ordered_associative_containers_)
`a_tran.erase(kx)
`
[122](#general-122)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3662)
*Result*: size_type
[123](#general-123)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3666)
*Effects*: Erases all elements in the container with key r such that !c(r, kx) && !c(kx, r) is true[.](#general-123.sentence-1)
[124](#general-124)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3671)
*Returns*: The number of erased elements[.](#general-124.sentence-1)
[125](#general-125)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3675)
*Complexity*: log(a_tran.size())+a_tran.count(kx)
[🔗](#lib:erase,ordered_associative_containers__)
`a.erase(q)
`
[126](#general-126)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3686)
*Result*: iterator
[127](#general-127)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3690)
*Effects*: Erases the element pointed to by q[.](#general-127.sentence-1)
[128](#general-128)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3694)
*Returns*: An iterator pointing to the element immediately following q prior to the element being erased[.](#general-128.sentence-1)
If no such element exists, returns a.end()[.](#general-128.sentence-2)
[129](#general-129)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3700)
*Complexity*: Amortized constant[.](#general-129.sentence-1)
[🔗](#lib:erase,ordered_associative_containers___)
`a.erase(r)
`
[130](#general-130)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3711)
*Result*: iterator
[131](#general-131)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3715)
*Effects*: Erases the element pointed to by r[.](#general-131.sentence-1)
[132](#general-132)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3719)
*Returns*: An iterator pointing to the element immediately following r prior to the element being erased[.](#general-132.sentence-1)
If no such element exists, returns a.end()[.](#general-132.sentence-2)
[133](#general-133)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3725)
*Complexity*: Amortized constant[.](#general-133.sentence-1)
[🔗](#lib:erase,ordered_associative_containers____)
`a.erase(q1, q2)
`
[134](#general-134)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3736)
*Result*: iterator
[135](#general-135)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3740)
*Effects*: Erases all the elements in the range [q1, q2)[.](#general-135.sentence-1)
[136](#general-136)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3744)
*Returns*: An iterator pointing to the element pointed to by q2 prior to any elements being erased[.](#general-136.sentence-1)
If no such element exists, a.end() is returned[.](#general-136.sentence-2)
[137](#general-137)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3750)
*Complexity*: log(a.size())+N, where N has the value distance(q1, q2)[.](#general-137.sentence-1)
[🔗](#lib:clear,ordered_associative_containers)
`a.clear()
`
[138](#general-138)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3761)
*Effects*: Equivalent to a.erase(a.begin(), a.end())[.](#general-138.sentence-1)
[139](#general-139)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3765)
*Postconditions*: a.empty() is true[.](#general-139.sentence-1)
[140](#general-140)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3769)
*Complexity*: Linear in a.size()[.](#general-140.sentence-1)
[🔗](#lib:find,ordered_associative_containers)
`b.find(k)
`
[141](#general-141)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3780)
*Result*: iterator; const_iterator for constant b[.](#general-141.sentence-1)
[142](#general-142)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3784)
*Returns*: An iterator pointing to an element with the key equivalent to k, orb.end() if such an element is not found[.](#general-142.sentence-1)
[143](#general-143)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3789)
*Complexity*: Logarithmic[.](#general-143.sentence-1)
[🔗](#lib:find,ordered_associative_containers_)
`a_tran.find(ke)
`
[144](#general-144)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3800)
*Result*: iterator; const_iterator for constant a_tran[.](#general-144.sentence-1)
[145](#general-145)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3804)
*Returns*: An iterator pointing to an element with key r such that !c(r, ke) && !c(ke, r) is true, ora_tran.end() if such an element is not found[.](#general-145.sentence-1)
[146](#general-146)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3810)
*Complexity*: Logarithmic[.](#general-146.sentence-1)
[🔗](#lib:count,ordered_associative_containers)
`b.count(k)
`
[147](#general-147)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3821)
*Result*: size_type
[148](#general-148)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3825)
*Returns*: The number of elements with key equivalent to k[.](#general-148.sentence-1)
[149](#general-149)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3829)
*Complexity*: log(b.size())+b.count(k)
[🔗](#lib:count,ordered_associative_containers_)
`a_tran.count(ke)
`
[150](#general-150)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3840)
*Result*: size_type
[151](#general-151)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3844)
*Returns*: The number of elements with key r such that !c(r, ke) && !c(ke, r)[.](#general-151.sentence-1)
[152](#general-152)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3849)
*Complexity*: log(a_tran.size())+a_tran.count(ke)
[🔗](#lib:contains,ordered_associative_containers)
`b.contains(k)
`
[153](#general-153)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3860)
*Result*: bool
[154](#general-154)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3864)
*Effects*: Equivalent to: return b.find(k) != b.end();
[🔗](#lib:contains,ordered_associative_containers_)
`a_tran.contains(ke)
`
[155](#general-155)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3875)
*Result*: bool
[156](#general-156)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3879)
*Effects*: Equivalent to: return a_tran.find(ke) != a_tran.end();
[🔗](#lib:lower_bound,ordered_associative_containers)
`b.lower_bound(k)
`
[157](#general-157)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3890)
*Result*: iterator; const_iterator for constant b[.](#general-157.sentence-1)
[158](#general-158)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3894)
*Returns*: An iterator pointing to the first element with key not less than k,
or b.end() if such an element is not found[.](#general-158.sentence-1)
[159](#general-159)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3899)
*Complexity*: Logarithmic[.](#general-159.sentence-1)
[🔗](#lib:lower_bound,ordered_associative_containers_)
`a_tran.lower_bound(kl)
`
[160](#general-160)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3910)
*Result*: iterator; const_iterator for constant a_tran[.](#general-160.sentence-1)
[161](#general-161)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3914)
*Returns*: An iterator pointing to the first element with key r such that !c(r, kl),
or a_tran.end() if such an element is not found[.](#general-161.sentence-1)
[162](#general-162)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3920)
*Complexity*: Logarithmic[.](#general-162.sentence-1)
[🔗](#lib:upper_bound,ordered_associative_containers)
`b.upper_bound(k)
`
[163](#general-163)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3931)
*Result*: iterator; const_iterator for constant b[.](#general-163.sentence-1)
[164](#general-164)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3935)
*Returns*: An iterator pointing to the first element with key greater than k,
or b.end() if such an element is not found[.](#general-164.sentence-1)
[165](#general-165)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3940)
*Complexity*: Logarithmic[.](#general-165.sentence-1)
[🔗](#lib:upper_bound,ordered_associative_containers_)
`a_tran.upper_bound(ku)
`
[166](#general-166)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3951)
*Result*: iterator; const_iterator for constant a_tran[.](#general-166.sentence-1)
[167](#general-167)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3955)
*Returns*: An iterator pointing to the first element with key r such that c(ku, r),
or a_tran.end() if such an element is not found[.](#general-167.sentence-1)
[168](#general-168)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3961)
*Complexity*: Logarithmic[.](#general-168.sentence-1)
[🔗](#lib:equal_range,ordered_associative_containers)
`b.equal_range(k)
`
[169](#general-169)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3972)
*Result*: pair<iterator, iterator>;pair<const_iterator, const_iterator> for constant b[.](#general-169.sentence-1)
[170](#general-170)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3977)
*Effects*: Equivalent to: return make_pair(b.lower_bound(k), b.upper_bound(k));
[171](#general-171)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3981)
*Complexity*: Logarithmic[.](#general-171.sentence-1)
[🔗](#lib:equal_range,ordered_associative_containers_)
`a_tran.equal_range(ke)
`
[172](#general-172)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3992)
*Result*: pair<iterator, iterator>;pair<const_iterator, const_iterator> for constant a_tran[.](#general-172.sentence-1)
[173](#general-173)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3997)
*Effects*: Equivalent to:return make_pair(a_tran.lower_bound(ke), a_tran.upper_bound(ke));
[174](#general-174)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4002)
*Complexity*: Logarithmic[.](#general-174.sentence-1)
[175](#general-175)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4007)
The insert, insert_range, and emplace members
shall not affect the validity of
iterators and references to the container,
and the erase members shall invalidate only iterators and
references to the erased elements[.](#general-175.sentence-1)
[176](#general-176)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4014)
The extract members invalidate only iterators to the removed element;
pointers and references to the removed element remain valid[.](#general-176.sentence-1)
However, accessing
the element through such pointers and references while the element is owned by
a node_type is undefined behavior[.](#general-176.sentence-2)
References and pointers to an element
obtained while it is owned by a node_type are invalidated if the element
is successfully inserted[.](#general-176.sentence-3)
[177](#general-177)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4022)
The fundamental property of iterators of associative containers is that they iterate through the containers
in the non-descending order of keys where non-descending is defined by the comparison that was used to
construct them[.](#general-177.sentence-1)
For any two dereferenceable iteratorsi andj such that distance fromi toj is positive, the following condition holds:value_comp(*j, *i) == false
[178](#general-178)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4039)
For associative containers with unique keys the stronger condition holds:value_comp(*i, *j) != false
[179](#general-179)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4045)
When an associative container is constructed by passing a comparison object the
container shall not store a pointer or reference to the passed object,
even if that object is passed by reference[.](#general-179.sentence-1)
When an associative container is copied, through either a copy constructor
or an assignment operator,
the target container shall then use the comparison object from the container
being copied,
as if that comparison object had been passed to the target container in
its constructor[.](#general-179.sentence-2)
[180](#general-180)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4056)
The member function templatesfind, count, contains,lower_bound, upper_bound, equal_range,erase, and extract shall not participate in overload resolution unless
the [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3Qualified names[expr.prim.id.qual]") Compare::is_transparent is valid
and denotes a type ([[temp.deduct]](temp.deduct "13.10.3Template argument deduction"))[.](#general-180.sentence-1)
Additionally, the member function templates extract and erase shall not participate in overload resolution ifis_convertible_v<K&&, iterator> || is_convertible_v<K&&, const_iterator> is true,
where K is the type substituted as the first template argument[.](#general-180.sentence-2)
[181](#general-181)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4070)
A deduction guide for an associative container shall not participate in overload resolution
if any of the following are true:
- [(181.1)](#general-181.1)
It has an InputIterator template parameter
and a type that does not qualify as an input iterator is deduced for that parameter[.](#general-181.1.sentence-1)
- [(181.2)](#general-181.2)
It has an Allocator template parameter
and a type that does not qualify as an allocator is deduced for that parameter[.](#general-181.2.sentence-1)
- [(181.3)](#general-181.3)
It has a Compare template parameter
and a type that qualifies as an allocator is deduced for that parameter[.](#general-181.3.sentence-1)
#### [23.2.7.2](#except) Exception safety guarantees [[associative.reqmts.except]](associative.reqmts.except)
[1](#except-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4088)
For associative containers, no clear() function throws an exception[.](#except-1.sentence-1)
erase(k) does not throw an exception unless that exception is thrown
by the container's Compare object (if any)[.](#except-1.sentence-2)
[2](#except-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4093)
For associative containers, if an exception is thrown by any operation from
within an insert or emplace function inserting a single element, the
insertion has no effect[.](#except-2.sentence-1)
[3](#except-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4098)
For associative containers, no swap function throws an exception unless
that exception is thrown by the
swap of the container's Compare object (if any)[.](#except-3.sentence-1)