[associative.reqmts.general]

# 23 Containers library [[containers]](./#containers)

## 23.2 Requirements [[container.requirements]](container.requirements#associative.reqmts.general)

### 23.2.7 Associative containers [[associative.reqmts]](associative.reqmts#general)

#### 23.2.7.1 General [associative.reqmts.general]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2630)

Associative containers provide fast retrieval of data based on keys[.](#1.sentence-1)

The library provides four basic kinds of associative containers:set,multiset,map andmultimap[.](#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)[.](#1.sentence-3)

[2](#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.8 Sorting and related operations")) on
elements ofKey[.](#2.sentence-1)

In addition,map andmultimap associate an arbitrary [*mapped type*](#def:mapped_type)T with theKey[.](#2.sentence-2)

The object of typeCompare is called the[*comparison object*](#def:comparison_object) of a container[.](#2.sentence-3)

[3](#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[.](#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[.](#3.sentence-2)

[*Note [1](#note-1)*:

This is not necessarily the same as the result of k1 == k2[.](#3.sentence-3)

â *end note*]

For any two keysk1 andk2 in the same container, callingcomp(k1, k2) shall always return the same value[.](#3.sentence-4)

[4](#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[.](#4.sentence-1)

Otherwise, it supports [*equivalent keys*](#def:equivalent_keys)[.](#4.sentence-2)

The set and map classes support unique keys; the multiset and multimap classes support equivalent keys[.](#4.sentence-3)

For multiset and multimap,insert, emplace, and erase preserve the relative ordering
of equivalent elements[.](#4.sentence-4)

[5](#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[.](#5.sentence-1)

For map and multimap it is equal to pair<const Key, T>[.](#5.sentence-2)

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2702)

iterator of an associative container is of the bidirectional iterator category[.](#6.sentence-1)

For associative containers where the value type is the same as the key type, bothiterator andconst_iterator are constant iterators[.](#6.sentence-2)

It is unspecified whether or notiterator andconst_iterator are the same type[.](#6.sentence-3)

[*Note [2](#note-2)*:

iterator and const_iterator have identical semantics in this case, and iterator is convertible to const_iterator[.](#6.sentence-4)

Users can avoid violating the one-definition rule by always using const_iterator in their function parameter lists[.](#6.sentence-5)

â *end note*]

[7](#7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2718)

In this subclause,

- [(7.1)](#7.1)

X denotes an associative container class,

- [(7.2)](#7.2)

a denotes a value of type X,

- [(7.3)](#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)](#7.4)

b denotes a value of type X or const X,

- [(7.5)](#7.5)

u denotes the name of a variable being declared,

- [(7.6)](#7.6)

a_uniq denotes a value of type X when X supports unique keys,

- [(7.7)](#7.7)

a_eq denotes a value of type X when X supports equivalent keys,

- [(7.8)](#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.3 Qualified names [expr.prim.id.qual]")X​::​key_compare​::​is_transparent is valid
and denotes a type ([[temp.deduct]](temp.deduct "13.10.3 Template argument deduction")),

- [(7.9)](#7.9)

i and j meet the *Cpp17InputIterator* requirements and refer to elements
implicitly convertible tovalue_type,

- [(7.10)](#7.10)

[i, j) denotes a valid range,

- [(7.11)](#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.1 Introduction [container.intro.reqmts]")<value_type>,

- [(7.12)](#7.12)

p denotes a valid constant iterator to a,

- [(7.13)](#7.13)

q denotes a valid dereferenceable constant iterator to a,

- [(7.14)](#7.14)

r denotes a valid dereferenceable iterator to a,

- [(7.15)](#7.15)

[q1, q2) denotes a valid range of constant iterators in a,

- [(7.16)](#7.16)

il designates an object of type initializer_list<value_type>,

- [(7.17)](#7.17)

t denotes a value of type X​::​value_type,

- [(7.18)](#7.18)

k denotes a value of type X​::​key_type, and

- [(7.19)](#7.19)

c denotes a value of type X​::​key_compare or const X​::​key_compare;

- [(7.20)](#7.20)

kl is a value such that a is partitioned ([[alg.sorting]](alg.sorting "26.8 Sorting and related operations"))
with respect to c(x, kl),
with x the key value of e and e in a;

- [(7.21)](#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)](#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)](#7.23)

kx is a value such that
  * [(7.23.1)](#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)](#7.23.2)

kx is not convertible to
either iterator or const_iterator; and

- [(7.24)](#7.24)

A denotes the storage allocator used by X, if any, or allocator<X​::​value_type> otherwise,

- [(7.25)](#7.25)

m denotes an allocator of a type convertible to A,
and nh denotes a non-const rvalue of type X​::​node_type[.](#7.sentence-1)

[8](#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.1 General [associative.reqmts.general]") requirements
if X meets all the requirements of an allocator-aware
container ([[container.alloc.reqmts]](container.alloc.reqmts "23.2.2.5 Allocator-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.2 Container requirements") apply instead to key_type and mapped_type[.](#8.sentence-1)

[*Note [3](#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*[.](#8.sentence-2)

â *end note*]

[ð](#lib:key_type,ordered_associative_containers)

`typename X::key_type
`

[9](#9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2836)

*Result*: Key[.](#9.sentence-1)

[ð](#lib:mapped_type,ordered_associative_containers)

`typename X::mapped_type
`

[10](#10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2847)

*Result*: T[.](#10.sentence-1)

[11](#11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2851)

*Remarks*: For map and multimap only[.](#11.sentence-1)

[ð](#lib:value_type,ordered_associative_containers)

`typename X::value_type
`

[12](#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[.](#12.sentence-1)

[13](#13)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2867)

*Preconditions*: X​::​value_type is *Cpp17Erasable* from X[.](#13.sentence-1)

[ð](#lib:key_compare,ordered_associative_containers)

`typename X::key_compare
`

[14](#14)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2878)

*Result*: Compare[.](#14.sentence-1)

[15](#15)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2882)

*Preconditions*: key_compare is *Cpp17CopyConstructible*[.](#15.sentence-1)

[ð](#lib:value_compare,ordered_associative_containers)

`typename X::value_compare
`

[16](#16)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2893)

*Result*: A binary predicate type[.](#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[.](#16.sentence-2)

[ð](#lib:node_type,ordered_associative_containers)

`typename X::node_type
`

[17](#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.5 Node handles")),
such that the public nested types are
the same types as the corresponding types in X[.](#17.sentence-1)

[ð](#lib:set,constructor)

`X(c)
`

[18](#18)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2924)

*Effects*: Constructs an empty container[.](#18.sentence-1)

Uses a copy of c as a comparison object[.](#18.sentence-2)

[19](#19)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2929)

*Complexity*: Constant[.](#19.sentence-1)

[ð](#lib:set,constructor_)

`X u = X();
X u;
`

[20](#20)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2944)

*Preconditions*: key_compare meets the *Cpp17DefaultConstructible* requirements[.](#20.sentence-1)

[21](#21)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2948)

*Effects*: Constructs an empty container[.](#21.sentence-1)

Uses Compare() as a comparison object[.](#21.sentence-2)

[22](#22)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2953)

*Complexity*: Constant[.](#22.sentence-1)

[ð](#lib:set,constructor__)

`X(i, j, c)
`

[23](#23)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2967)

*Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from *i[.](#23.sentence-1)

[24](#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[.](#24.sentence-1)

[25](#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()[.](#25.sentence-1)

[ð](#lib:set,constructor___)

`X(i, j)
`

[26](#26)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2993)

*Preconditions*: key_compare meets the *Cpp17DefaultConstructible* requirements[.](#26.sentence-1)

value_type is*Cpp17EmplaceConstructible* into X from *i[.](#26.sentence-2)

[27](#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[.](#27.sentence-1)

[28](#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()[.](#28.sentence-1)

[ð](#lib:set,constructor____)

`X(from_range, rg, c)
`

[29](#29)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3020)

*Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from *ranges​::​begin(rg)[.](#29.sentence-1)

[30](#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[.](#30.sentence-1)

Uses c as the comparison object[.](#30.sentence-2)

[31](#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()[.](#31.sentence-1)

[ð](#lib:set,constructor_____)

`X(from_range, rg)
`

[32](#32)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3047)

*Preconditions*: key_compare meets the *Cpp17DefaultConstructible* requirements[.](#32.sentence-1)

value_type is *Cpp17EmplaceConstructible* into X from *ranges​::​begin(rg)[.](#32.sentence-2)

[33](#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[.](#33.sentence-1)

Uses Compare() as the comparison object[.](#33.sentence-2)

[34](#34)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3059)

*Complexity*: Same as X(from_range, rg, c)[.](#34.sentence-1)

[ð](#lib:set,constructor______)

`X(il, c)
`

[35](#35)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3073)

*Effects*: Equivalent to X(il.begin(), il.end(), c)[.](#35.sentence-1)

[ð](#lib:set,constructor_______)

`X(il)
`

[36](#36)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3087)

*Effects*: Equivalent to X(il.begin(), il.end())[.](#36.sentence-1)

[ð](#itemdecl:15)

`a = il
`

[37](#37)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3097)

*Result*: X&

[38](#38)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3101)

*Preconditions*: value_type is *Cpp17CopyInsertable* into X and *Cpp17CopyAssignable*[.](#38.sentence-1)

[39](#39)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3106)

*Effects*: Assigns the range [il.begin(), il.end()) into a[.](#39.sentence-1)

All existing elements of a are either assigned to or destroyed[.](#39.sentence-2)

[40](#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()[.](#40.sentence-1)

[ð](#lib:key_comp,ordered_associative_containers)

`b.key_comp()
`

[41](#41)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3123)

*Result*: X​::​key_compare

[42](#42)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3127)

*Returns*: The comparison object out of which b was constructed[.](#42.sentence-1)

[43](#43)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3131)

*Complexity*: Constant[.](#43.sentence-1)

[ð](#lib:value_comp,ordered_associative_containers)

`b.value_comp()
`

[44](#44)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3142)

*Result*: X​::​value_compare

[45](#45)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3146)

*Returns*: An object of value_compare constructed out of the comparison object[.](#45.sentence-1)

[46](#46)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3150)

*Complexity*: Constant[.](#46.sentence-1)

[ð](#lib:emplace,ordered_associative_containers)

`a_uniq.emplace(args)
`

[47](#47)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3161)

*Result*: pair<iterator, bool>

[48](#48)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3165)

*Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from args[.](#48.sentence-1)

[49](#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[.](#49.sentence-1)

[50](#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[.](#50.sentence-1)

[51](#51)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3184)

*Complexity*: Logarithmic[.](#51.sentence-1)

[ð](#lib:emplace,ordered_associative_containers_)

`a_eq.emplace(args)
`

[52](#52)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3195)

*Result*: iterator

[53](#53)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3199)

*Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from args[.](#53.sentence-1)

[54](#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)...[.](#54.sentence-1)

If a range containing elements equivalent to t exists in a_eq,t is inserted at the end of that range[.](#54.sentence-2)

[55](#55)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3211)

*Returns*: An iterator pointing to the newly inserted element[.](#55.sentence-1)

[56](#56)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3215)

*Complexity*: Logarithmic[.](#56.sentence-1)

[ð](#lib:emplace_hint,ordered_associative_containers)

`a.emplace_hint(p, args)
`

[57](#57)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3226)

*Result*: iterator

[58](#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[.](#58.sentence-1)

[59](#59)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3236)

*Returns*: The iterator returned by emplace[.](#59.sentence-1)

[60](#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[.](#60.sentence-1)

[ð](#lib:insert,ordered_associative_containers)

`a_uniq.insert(t)
`

[61](#61)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3252)

*Result*: pair<iterator, bool>

[62](#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[.](#62.sentence-1)

[63](#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[.](#63.sentence-1)

[64](#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[.](#64.sentence-1)

[65](#65)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3274)

*Complexity*: Logarithmic[.](#65.sentence-1)

[ð](#lib:insert,ordered_associative_containers_)

`a_eq.insert(t)
`

[66](#66)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3285)

*Result*: iterator

[67](#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[.](#67.sentence-1)

[68](#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[.](#68.sentence-1)

If a range containing elements equivalent to t exists in a_eq,t is inserted at the end of that range[.](#68.sentence-2)

[69](#69)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3302)

*Complexity*: Logarithmic[.](#69.sentence-1)

[ð](#lib:insert,ordered_associative_containers__)

`a.insert(p, t)
`

[70](#70)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3313)

*Result*: iterator

[71](#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[.](#71.sentence-1)

[72](#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[.](#72.sentence-1)

t is inserted as close as possible to
the position just prior to p[.](#72.sentence-2)

[73](#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[.](#73.sentence-1)

[74](#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[.](#74.sentence-1)

[ð](#lib:insert,ordered_associative_containers___)

`a.insert(i, j)
`

[75](#75)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3347)

*Result*: void

[76](#76)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3351)

*Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from *i[.](#76.sentence-1)

Neither i nor j are iterators into a[.](#76.sentence-2)

[77](#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[.](#77.sentence-1)

[78](#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)[.](#78.sentence-1)

[ð](#lib:insert,ordered_associative_containers____)

`a.insert_range(rg)
`

[79](#79)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3375)

*Result*: void

[80](#80)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3379)

*Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from *ranges​::​begin(rg)[.](#80.sentence-1)

rg and a do not overlap[.](#80.sentence-2)

[81](#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[.](#81.sentence-1)

[82](#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)[.](#82.sentence-1)

[ð](#lib:insert,ordered_associative_containers_____)

`a.insert(il)
`

[83](#83)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3405)

*Effects*: Equivalent to a.insert(il.begin(), il.end())[.](#83.sentence-1)

[ð](#lib:insert,ordered_associative_containers______)

`a_uniq.insert(nh)
`

[84](#84)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3416)

*Result*: insert_return_type

[85](#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[.](#85.sentence-1)

[86](#86)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3425)

*Effects*: If nh is empty, has no effect[.](#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()[.](#86.sentence-2)

[87](#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[.](#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()[.](#87.sentence-2)

[88](#88)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3441)

*Complexity*: Logarithmic[.](#88.sentence-1)

[ð](#lib:insert,ordered_associative_containers_______)

`a_eq.insert(nh)
`

[89](#89)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3452)

*Result*: iterator

[90](#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[.](#90.sentence-1)

[91](#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()[.](#91.sentence-1)

Otherwise, inserts the element owned by nh and
returns an iterator pointing to the newly inserted element[.](#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[.](#91.sentence-3)

[92](#92)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3470)

*Postconditions*: nh is empty[.](#92.sentence-1)

[93](#93)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3474)

*Complexity*: Logarithmic[.](#93.sentence-1)

[ð](#lib:insert,ordered_associative_containers________)

`a.insert(p, nh)
`

[94](#94)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3485)

*Result*: iterator

[95](#95)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3489)

*Preconditions*: nh is empty ora.get_allocator() == nh.get_allocator() is true[.](#95.sentence-1)

[96](#96)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3494)

*Effects*: If nh is empty, has no effect and returns a.end()[.](#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[.](#96.sentence-2)

The element is inserted as close as possible to
the position just prior to p[.](#96.sentence-3)

[97](#97)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3505)

*Postconditions*: nh is empty if insertion succeeds, unchanged if insertion fails[.](#97.sentence-1)

[98](#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()[.](#98.sentence-1)

[99](#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[.](#99.sentence-1)

[ð](#lib:extract,ordered_associative_containers)

`a.extract(k)
`

[100](#100)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3526)

*Result*: node_type

[101](#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[.](#101.sentence-1)

[102](#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[.](#102.sentence-1)

[103](#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](#104)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3550)

*Result*: node_type

[105](#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[.](#105.sentence-1)

[106](#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[.](#106.sentence-1)

[107](#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](#108)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3575)

*Result*: node_type

[109](#109)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3579)

*Effects*: Removes the element pointed to by q[.](#109.sentence-1)

[110](#110)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3583)

*Returns*: A node_type owning that element[.](#110.sentence-1)

[111](#111)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3587)

*Complexity*: Amortized constant[.](#111.sentence-1)

[ð](#lib:merge,ordered_associative_containers)

`a.merge(a2)
`

[112](#112)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3598)

*Result*: void

[113](#113)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3602)

*Preconditions*: a.get_allocator() == a2.get_allocator() is true[.](#113.sentence-1)

[114](#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[.](#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[.](#114.sentence-2)

[115](#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[.](#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[.](#115.sentence-2)

[116](#116)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3624)

*Throws*: Nothing unless the comparison object throws[.](#116.sentence-1)

[117](#117)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3628)

*Complexity*: Nlog(a.size()+N), where N has the value a2.size()[.](#117.sentence-1)

[ð](#lib:erase,ordered_associative_containers)

`a.erase(k)
`

[118](#118)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3639)

*Result*: size_type

[119](#119)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3643)

*Effects*: Erases all elements in the container with key equivalent to k[.](#119.sentence-1)

[120](#120)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3647)

*Returns*: The number of erased elements[.](#120.sentence-1)

[121](#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](#122)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3662)

*Result*: size_type

[123](#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[.](#123.sentence-1)

[124](#124)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3671)

*Returns*: The number of erased elements[.](#124.sentence-1)

[125](#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](#126)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3686)

*Result*: iterator

[127](#127)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3690)

*Effects*: Erases the element pointed to by q[.](#127.sentence-1)

[128](#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[.](#128.sentence-1)

If no such element exists, returns a.end()[.](#128.sentence-2)

[129](#129)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3700)

*Complexity*: Amortized constant[.](#129.sentence-1)

[ð](#lib:erase,ordered_associative_containers___)

`a.erase(r)
`

[130](#130)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3711)

*Result*: iterator

[131](#131)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3715)

*Effects*: Erases the element pointed to by r[.](#131.sentence-1)

[132](#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[.](#132.sentence-1)

If no such element exists, returns a.end()[.](#132.sentence-2)

[133](#133)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3725)

*Complexity*: Amortized constant[.](#133.sentence-1)

[ð](#lib:erase,ordered_associative_containers____)

`a.erase(q1, q2)
`

[134](#134)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3736)

*Result*: iterator

[135](#135)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3740)

*Effects*: Erases all the elements in the range [q1, q2)[.](#135.sentence-1)

[136](#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[.](#136.sentence-1)

If no such element exists, a.end() is returned[.](#136.sentence-2)

[137](#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)[.](#137.sentence-1)

[ð](#lib:clear,ordered_associative_containers)

`a.clear()
`

[138](#138)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3761)

*Effects*: Equivalent to a.erase(a.begin(), a.end())[.](#138.sentence-1)

[139](#139)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3765)

*Postconditions*: a.empty() is true[.](#139.sentence-1)

[140](#140)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3769)

*Complexity*: Linear in a.size()[.](#140.sentence-1)

[ð](#lib:find,ordered_associative_containers)

`b.find(k)
`

[141](#141)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3780)

*Result*: iterator; const_iterator for constant b[.](#141.sentence-1)

[142](#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[.](#142.sentence-1)

[143](#143)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3789)

*Complexity*: Logarithmic[.](#143.sentence-1)

[ð](#lib:find,ordered_associative_containers_)

`a_tran.find(ke)
`

[144](#144)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3800)

*Result*: iterator; const_iterator for constant a_tran[.](#144.sentence-1)

[145](#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[.](#145.sentence-1)

[146](#146)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3810)

*Complexity*: Logarithmic[.](#146.sentence-1)

[ð](#lib:count,ordered_associative_containers)

`b.count(k)
`

[147](#147)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3821)

*Result*: size_type

[148](#148)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3825)

*Returns*: The number of elements with key equivalent to k[.](#148.sentence-1)

[149](#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](#150)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3840)

*Result*: size_type

[151](#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)[.](#151.sentence-1)

[152](#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](#153)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3860)

*Result*: bool

[154](#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](#155)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3875)

*Result*: bool

[156](#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](#157)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3890)

*Result*: iterator; const_iterator for constant b[.](#157.sentence-1)

[158](#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[.](#158.sentence-1)

[159](#159)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3899)

*Complexity*: Logarithmic[.](#159.sentence-1)

[ð](#lib:lower_bound,ordered_associative_containers_)

`a_tran.lower_bound(kl)
`

[160](#160)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3910)

*Result*: iterator; const_iterator for constant a_tran[.](#160.sentence-1)

[161](#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[.](#161.sentence-1)

[162](#162)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3920)

*Complexity*: Logarithmic[.](#162.sentence-1)

[ð](#lib:upper_bound,ordered_associative_containers)

`b.upper_bound(k)
`

[163](#163)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3931)

*Result*: iterator; const_iterator for constant b[.](#163.sentence-1)

[164](#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[.](#164.sentence-1)

[165](#165)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3940)

*Complexity*: Logarithmic[.](#165.sentence-1)

[ð](#lib:upper_bound,ordered_associative_containers_)

`a_tran.upper_bound(ku)
`

[166](#166)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3951)

*Result*: iterator; const_iterator for constant a_tran[.](#166.sentence-1)

[167](#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[.](#167.sentence-1)

[168](#168)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3961)

*Complexity*: Logarithmic[.](#168.sentence-1)

[ð](#lib:equal_range,ordered_associative_containers)

`b.equal_range(k)
`

[169](#169)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3972)

*Result*: pair<iterator, iterator>;pair<const_iterator, const_iterator> for constant b[.](#169.sentence-1)

[170](#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](#171)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L3981)

*Complexity*: Logarithmic[.](#171.sentence-1)

[ð](#lib:equal_range,ordered_associative_containers_)

`a_tran.equal_range(ke)
`

[172](#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[.](#172.sentence-1)

[173](#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](#174)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4002)

*Complexity*: Logarithmic[.](#174.sentence-1)

[175](#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[.](#175.sentence-1)

[176](#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[.](#176.sentence-1)

However, accessing
the element through such pointers and references while the element is owned by
a node_type is undefined behavior[.](#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[.](#176.sentence-3)

[177](#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[.](#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](#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](#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[.](#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[.](#179.sentence-2)

[180](#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.3 Qualified names [expr.prim.id.qual]") Compare​::​is_transparent is valid
and denotes a type ([[temp.deduct]](temp.deduct "13.10.3 Template argument deduction"))[.](#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[.](#180.sentence-2)

[181](#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)](#181.1)

  It has an InputIterator template parameter
and a type that does not qualify as an input iterator is deduced for that parameter[.](#181.1.sentence-1)

- [(181.2)](#181.2)

  It has an Allocator template parameter
and a type that does not qualify as an allocator is deduced for that parameter[.](#181.2.sentence-1)

- [(181.3)](#181.3)

  It has a Compare template parameter
and a type that qualifies as an allocator is deduced for that parameter[.](#181.3.sentence-1)
