2347 lines
76 KiB
Markdown
2347 lines
76 KiB
Markdown
[unord.req]
|
||
|
||
# 23 Containers library [[containers]](./#containers)
|
||
|
||
## 23.2 Requirements [[container.requirements]](container.requirements#unord.req)
|
||
|
||
### 23.2.8 Unordered associative containers [unord.req]
|
||
|
||
#### [23.2.8.1](#general) General [[unord.req.general]](unord.req.general)
|
||
|
||
[1](#general-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4109)
|
||
|
||
Unordered associative containers provide an ability for fast retrieval
|
||
of data based on keys[.](#general-1.sentence-1)
|
||
|
||
The worst-case complexity for most operations
|
||
is linear, but the average case is much faster[.](#general-1.sentence-2)
|
||
|
||
The library provides
|
||
four unordered associative containers: unordered_set,unordered_map, unordered_multiset, andunordered_multimap[.](#general-1.sentence-3)
|
||
|
||
[2](#general-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4118)
|
||
|
||
Unordered associative containers conform to the requirements for
|
||
Containers ([[container.requirements]](container.requirements "23.2 Requirements")), except that
|
||
the expressionsa == b and a != b have different semantics than for the other
|
||
container types[.](#general-2.sentence-1)
|
||
|
||
[3](#general-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4128)
|
||
|
||
Each unordered associative container is parameterized by Key,
|
||
by a function object type Hash that meets the *Cpp17Hash* requirements ([[hash.requirements]](hash.requirements "16.4.4.5 Cpp17Hash requirements")) and acts as a hash function for
|
||
argument values of type Key, and by a binary predicate Pred that induces an equivalence relation on values of type Key[.](#general-3.sentence-1)
|
||
|
||
Additionally, unordered_map and unordered_multimap associate
|
||
an arbitrary *mapped type* T with the Key[.](#general-3.sentence-2)
|
||
|
||
[4](#general-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4137)
|
||
|
||
The container's object of type Hash â denoted byhash â is called the [*hash function*](#def:hash_function) of the
|
||
container[.](#general-4.sentence-1)
|
||
|
||
The container's object of type Pred â
|
||
denoted by pred â is called the[*key equality predicate*](#def:key_equality_predicate) of the container[.](#general-4.sentence-2)
|
||
|
||
[5](#general-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4146)
|
||
|
||
Two values k1 and k2 are
|
||
considered equivalent if the container's
|
||
key equality predicatepred(k1, k2) is valid and returnstrue when passed those values[.](#general-5.sentence-1)
|
||
|
||
If k1 andk2 are equivalent, the container's hash function shall
|
||
return the same value for both[.](#general-5.sentence-2)
|
||
|
||
[*Note [1](#general-note-1)*:
|
||
|
||
Thus, when an unordered associative container is instantiated with
|
||
a non-default Pred parameter it usually needs a non-default Hash parameter as well[.](#general-5.sentence-3)
|
||
|
||
â *end note*]
|
||
|
||
For any two keys k1 and k2 in the same container,
|
||
calling pred(k1, k2) shall always return the same value[.](#general-5.sentence-4)
|
||
|
||
For any key k in a container, calling hash(k) shall always return the same value[.](#general-5.sentence-5)
|
||
|
||
[6](#general-6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4165)
|
||
|
||
An unordered associative container supports *unique keys* if it
|
||
may contain at most one element for each key[.](#general-6.sentence-1)
|
||
|
||
Otherwise, it supports*equivalent keys*[.](#general-6.sentence-2)
|
||
|
||
unordered_set and unordered_map support unique keys[.](#general-6.sentence-3)
|
||
|
||
unordered_multiset and unordered_multimap support equivalent keys[.](#general-6.sentence-4)
|
||
|
||
In containers that support equivalent keys,
|
||
elements with equivalent keys are adjacent to each other
|
||
in the iteration order of the container[.](#general-6.sentence-5)
|
||
|
||
Thus, although the absolute order
|
||
of elements in an unordered container is not specified, its elements are
|
||
grouped into [*equivalent-key groups*](#def:equivalent-key_group "23.2.8.1 General [unord.req.general]") such that all elements of each
|
||
group have equivalent keys[.](#general-6.sentence-6)
|
||
|
||
Mutating operations on unordered containers shall
|
||
preserve the relative order of elements within each equivalent-key group
|
||
unless otherwise specified[.](#general-6.sentence-7)
|
||
|
||
[7](#general-7)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4181)
|
||
|
||
For unordered_set and unordered_multiset the value type is
|
||
the same as the key type[.](#general-7.sentence-1)
|
||
|
||
For unordered_map andunordered_multimap it is pair<const Key,
|
||
T>[.](#general-7.sentence-2)
|
||
|
||
[8](#general-8)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4187)
|
||
|
||
For unordered containers where the value type is the same as the key
|
||
type, both iterator and const_iterator are constant
|
||
iterators[.](#general-8.sentence-1)
|
||
|
||
It is unspecified whether or not iterator andconst_iterator are the same type[.](#general-8.sentence-2)
|
||
|
||
[*Note [2](#general-note-2)*:
|
||
|
||
iterator and const_iterator have identical
|
||
semantics in this case, and iterator is convertible toconst_iterator[.](#general-8.sentence-3)
|
||
|
||
Users can avoid violating the one-definition rule
|
||
by always using const_iterator in their function parameter lists[.](#general-8.sentence-4)
|
||
|
||
â *end note*]
|
||
|
||
[9](#general-9)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4199)
|
||
|
||
The elements of an unordered associative container are organized into*buckets*[.](#general-9.sentence-1)
|
||
|
||
Keys with the same hash code appear in the same
|
||
bucket[.](#general-9.sentence-2)
|
||
|
||
The number of buckets is automatically increased as elements
|
||
are added to an unordered associative container, so that the average
|
||
number of elements per bucket is kept below a bound[.](#general-9.sentence-3)
|
||
|
||
Rehashing
|
||
invalidates iterators, changes ordering between elements, and changes
|
||
which buckets elements appear in, but does not invalidate pointers or
|
||
references to elements[.](#general-9.sentence-4)
|
||
|
||
For unordered_multiset andunordered_multimap, rehashing preserves the relative ordering of
|
||
equivalent elements[.](#general-9.sentence-5)
|
||
|
||
[10](#general-10)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4213)
|
||
|
||
In this subclause,
|
||
|
||
- [(10.1)](#general-10.1)
|
||
|
||
X denotes an unordered associative container class,
|
||
|
||
- [(10.2)](#general-10.2)
|
||
|
||
a denotes a value of type X,
|
||
|
||
- [(10.3)](#general-10.3)
|
||
|
||
a2 denotes a value of a type with nodes compatible
|
||
with type X (Table [75](container.node.overview#tab:container.node.compat "Table 75: Container types with compatible nodes")),
|
||
|
||
- [(10.4)](#general-10.4)
|
||
|
||
b denotes a value of type X or const X,
|
||
|
||
- [(10.5)](#general-10.5)
|
||
|
||
a_uniq denotes a value of type X when X supports unique keys,
|
||
|
||
- [(10.6)](#general-10.6)
|
||
|
||
a_eq denotes a value of type X when X supports equivalent keys,
|
||
|
||
- [(10.7)](#general-10.7)
|
||
|
||
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]")*s*X::key_equal::is_transparent and X::hasher::is_transparent are both valid and denote types ([[temp.deduct]](temp.deduct "13.10.3 Template argument deduction")),
|
||
|
||
- [(10.8)](#general-10.8)
|
||
|
||
i and j denote input iterators
|
||
that refer to value_type,
|
||
|
||
- [(10.9)](#general-10.9)
|
||
|
||
[i, j) denotes a valid range,
|
||
|
||
- [(10.10)](#general-10.10)
|
||
|
||
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>,
|
||
|
||
- [(10.11)](#general-10.11)
|
||
|
||
p and q2 denote valid constant iterators to a,
|
||
|
||
- [(10.12)](#general-10.12)
|
||
|
||
q and q1 denote
|
||
valid dereferenceable constant iterators to a,
|
||
|
||
- [(10.13)](#general-10.13)
|
||
|
||
r denotes a valid dereferenceable iterator to a,
|
||
|
||
- [(10.14)](#general-10.14)
|
||
|
||
[q1, q2) denotes a valid range in a,
|
||
|
||
- [(10.15)](#general-10.15)
|
||
|
||
il denotes a value of type initializer_list<value_type>,
|
||
|
||
- [(10.16)](#general-10.16)
|
||
|
||
t denotes a value of type X::value_type,
|
||
|
||
- [(10.17)](#general-10.17)
|
||
|
||
k denotes a value of type key_type,
|
||
|
||
- [(10.18)](#general-10.18)
|
||
|
||
hf denotes a value of type hasher or const hasher,
|
||
|
||
- [(10.19)](#general-10.19)
|
||
|
||
eq denotes a value of type key_equal or const key_equal,
|
||
|
||
- [(10.20)](#general-10.20)
|
||
|
||
ke is a value such that
|
||
* [(10.20.1)](#general-10.20.1)
|
||
|
||
eq(r1, ke) == eq(ke, r1),
|
||
|
||
* [(10.20.2)](#general-10.20.2)
|
||
|
||
hf(r1) == hf(ke) if eq(r1, ke) is true, and
|
||
|
||
* [(10.20.3)](#general-10.20.3)
|
||
|
||
if any two of eq(r1, ke), eq(r2, ke), and eq(r1, r2) are true, then all three are true,
|
||
|
||
where r1 and r2 are keys of elements in a_tran,
|
||
|
||
- [(10.21)](#general-10.21)
|
||
|
||
kx is a value such that
|
||
* [(10.21.1)](#general-10.21.1)
|
||
|
||
eq(r1, kx) == eq(kx, r1),
|
||
|
||
* [(10.21.2)](#general-10.21.2)
|
||
|
||
hf(r1) == hf(kx) if eq(r1, kx) is true,
|
||
|
||
* [(10.21.3)](#general-10.21.3)
|
||
|
||
if any two of eq(r1, kx), eq(r2, kx), and eq(r1, r2) are true, then all three are true, and
|
||
|
||
* [(10.21.4)](#general-10.21.4)
|
||
|
||
kx is not convertible to
|
||
either iterator or const_iterator,
|
||
|
||
where r1 and r2 are keys of elements in a_tran,
|
||
|
||
- [(10.22)](#general-10.22)
|
||
|
||
n denotes a value of type size_type,
|
||
|
||
- [(10.23)](#general-10.23)
|
||
|
||
z denotes a value of type float, and
|
||
|
||
- [(10.24)](#general-10.24)
|
||
|
||
nh denotes an rvalue of type X::node_type[.](#general-10.sentence-1)
|
||
|
||
[11](#general-11)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4300)
|
||
|
||
A type X meets
|
||
the [*unordered associative container*](#def:container,unordered_associative "23.2.8.1 General [unord.req.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 for unordered_map and unordered_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[.](#general-11.sentence-1)
|
||
|
||
[*Note [3](#general-note-3)*:
|
||
|
||
For example, key_type and mapped_type sometimes need to be *Cpp17CopyAssignable* even though the associated value_type,pair<const key_type, mapped_type>,
|
||
is not *Cpp17CopyAssignable*[.](#general-11.sentence-2)
|
||
|
||
â *end note*]
|
||
|
||
[ð](#lib:key_type,unordered_associative_containers)
|
||
|
||
`typename X::key_type
|
||
`
|
||
|
||
[12](#general-12)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4333)
|
||
|
||
*Result*: Key[.](#general-12.sentence-1)
|
||
|
||
[ð](#lib:mapped_type,unordered_associative_containers)
|
||
|
||
`typename X::mapped_type
|
||
`
|
||
|
||
[13](#general-13)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4344)
|
||
|
||
*Result*: T[.](#general-13.sentence-1)
|
||
|
||
[14](#general-14)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4348)
|
||
|
||
*Remarks*: For unordered_map and unordered_multimap only[.](#general-14.sentence-1)
|
||
|
||
[ð](#lib:value_type,unordered_associative_containers)
|
||
|
||
`typename X::value_type
|
||
`
|
||
|
||
[15](#general-15)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4359)
|
||
|
||
*Result*: Key for unordered_set and unordered_multiset only;pair<const Key, T> for unordered_map and unordered_multimap only[.](#general-15.sentence-1)
|
||
|
||
[16](#general-16)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4365)
|
||
|
||
*Preconditions*: value_type is *Cpp17Erasable* from X[.](#general-16.sentence-1)
|
||
|
||
[ð](#lib:hasher,unordered_associative_containers)
|
||
|
||
`typename X::hasher
|
||
`
|
||
|
||
[17](#general-17)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4376)
|
||
|
||
*Result*: Hash[.](#general-17.sentence-1)
|
||
|
||
[18](#general-18)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4380)
|
||
|
||
*Preconditions*: Hash is a unary function object type
|
||
such that the expression hf(k) has type size_t[.](#general-18.sentence-1)
|
||
|
||
[ð](#lib:key_equal,unordered_associative_containers)
|
||
|
||
`typename X::key_equal
|
||
`
|
||
|
||
[19](#general-19)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4392)
|
||
|
||
*Result*: Pred[.](#general-19.sentence-1)
|
||
|
||
[20](#general-20)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4396)
|
||
|
||
*Preconditions*: Pred meets the *Cpp17CopyConstructible* requirements[.](#general-20.sentence-1)
|
||
|
||
Pred is a binary predicate that takes two arguments of type Key[.](#general-20.sentence-2)
|
||
|
||
Pred is an equivalence relation[.](#general-20.sentence-3)
|
||
|
||
[ð](#lib:local_iterator,unordered_associative_containers)
|
||
|
||
`typename X::local_iterator
|
||
`
|
||
|
||
[21](#general-21)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4409)
|
||
|
||
*Result*: An iterator type
|
||
whose category, value type, difference type, and pointer and reference types
|
||
are the same as X::iterator's[.](#general-21.sentence-1)
|
||
|
||
[*Note [4](#general-note-4)*:
|
||
|
||
A local_iterator object can be used to iterate through a single bucket,
|
||
but cannot be used to iterate across buckets[.](#general-21.sentence-2)
|
||
|
||
â *end note*]
|
||
|
||
[ð](#lib:const_local_iterator,unordered_associative_containers)
|
||
|
||
`typename X::const_local_iterator
|
||
`
|
||
|
||
[22](#general-22)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4426)
|
||
|
||
*Result*: An iterator type
|
||
whose category, value type, difference type, and pointer and reference types
|
||
are the same as X::const_iterator's[.](#general-22.sentence-1)
|
||
|
||
[*Note [5](#general-note-5)*:
|
||
|
||
A const_local_iterator object can be used to iterate
|
||
through a single bucket,
|
||
but cannot be used to iterate across buckets[.](#general-22.sentence-2)
|
||
|
||
â *end note*]
|
||
|
||
[ð](#lib:node_type,unordered_associative_containers)
|
||
|
||
`typename X::node_type
|
||
`
|
||
|
||
[23](#general-23)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4444)
|
||
|
||
*Result*: A specialization of a *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[.](#general-23.sentence-1)
|
||
|
||
[ð](#lib:unordered_set,constructor)
|
||
|
||
`X(n, hf, eq)
|
||
`
|
||
|
||
[24](#general-24)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4460)
|
||
|
||
*Effects*: Constructs an empty container with at least n buckets,
|
||
using hf as the hash function andeq as the key equality predicate[.](#general-24.sentence-1)
|
||
|
||
[25](#general-25)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4466)
|
||
|
||
*Complexity*: O(n)
|
||
|
||
[ð](#general-itemdecl:10)
|
||
|
||
`X(n, hf)
|
||
`
|
||
|
||
[26](#general-26)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4476)
|
||
|
||
*Preconditions*: key_equal meets the *Cpp17DefaultConstructible* requirements[.](#general-26.sentence-1)
|
||
|
||
[27](#general-27)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4480)
|
||
|
||
*Effects*: Constructs an empty container with at least n buckets,
|
||
using hf as the hash function andkey_equal() as the key equality predicate[.](#general-27.sentence-1)
|
||
|
||
[28](#general-28)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4486)
|
||
|
||
*Complexity*: O(n)
|
||
|
||
[ð](#general-itemdecl:11)
|
||
|
||
`X(n)
|
||
`
|
||
|
||
[29](#general-29)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4496)
|
||
|
||
*Preconditions*: hasher and key_equal meet the *Cpp17DefaultConstructible* requirements[.](#general-29.sentence-1)
|
||
|
||
[30](#general-30)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4501)
|
||
|
||
*Effects*: Constructs an empty container with at least n buckets,
|
||
using hasher() as the hash function andkey_equal() as the key equality predicate[.](#general-30.sentence-1)
|
||
|
||
[31](#general-31)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4507)
|
||
|
||
*Complexity*: O(n)
|
||
|
||
[ð](#general-itemdecl:12)
|
||
|
||
`X a = X();
|
||
X a;
|
||
`
|
||
|
||
[32](#general-32)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4518)
|
||
|
||
*Preconditions*: hasher and key_equal meet
|
||
the *Cpp17DefaultConstructible* requirements[.](#general-32.sentence-1)
|
||
|
||
[33](#general-33)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4523)
|
||
|
||
*Effects*: Constructs an empty container with an unspecified number of buckets,
|
||
using hasher() as the hash function andkey_equal() as the key equality predicate[.](#general-33.sentence-1)
|
||
|
||
[34](#general-34)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4529)
|
||
|
||
*Complexity*: Constant[.](#general-34.sentence-1)
|
||
|
||
[ð](#general-itemdecl:13)
|
||
|
||
`X(i, j, n, hf, eq)
|
||
`
|
||
|
||
[35](#general-35)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4539)
|
||
|
||
*Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from *i[.](#general-35.sentence-1)
|
||
|
||
[36](#general-36)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4544)
|
||
|
||
*Effects*: Constructs an empty container with at least n buckets,
|
||
using hf as the hash function andeq as the key equality predicate, and
|
||
inserts elements from [i, j) into it[.](#general-36.sentence-1)
|
||
|
||
[37](#general-37)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4551)
|
||
|
||
*Complexity*: Average case O(N) (N is distance(i, j)), worst case O(N2)[.](#general-37.sentence-1)
|
||
|
||
[ð](#general-itemdecl:14)
|
||
|
||
`X(i, j, n, hf)
|
||
`
|
||
|
||
[38](#general-38)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4561)
|
||
|
||
*Preconditions*: key_equal meets the *Cpp17DefaultConstructible* requirements[.](#general-38.sentence-1)
|
||
|
||
value_type is*Cpp17EmplaceConstructible* into X from *i[.](#general-38.sentence-2)
|
||
|
||
[39](#general-39)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4567)
|
||
|
||
*Effects*: Constructs an empty container with at least n buckets,
|
||
using hf as the hash function andkey_equal() as the key equality predicate, and
|
||
inserts elements from [i, j) into it[.](#general-39.sentence-1)
|
||
|
||
[40](#general-40)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4574)
|
||
|
||
*Complexity*: Average case O(N) (N is distance(i, j)), worst case O(N2)[.](#general-40.sentence-1)
|
||
|
||
[ð](#general-itemdecl:15)
|
||
|
||
`X(i, j, n)
|
||
`
|
||
|
||
[41](#general-41)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4584)
|
||
|
||
*Preconditions*: hasher and key_equal meet
|
||
the *Cpp17DefaultConstructible* requirements[.](#general-41.sentence-1)
|
||
|
||
value_type is*Cpp17EmplaceConstructible* into X from *i[.](#general-41.sentence-2)
|
||
|
||
[42](#general-42)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4591)
|
||
|
||
*Effects*: Constructs an empty container with at least n buckets,
|
||
using hasher() as the hash function andkey_equal() as the key equality predicate, and
|
||
inserts elements from [i, j) into it[.](#general-42.sentence-1)
|
||
|
||
[43](#general-43)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4598)
|
||
|
||
*Complexity*: Average case O(N) (N is distance(i, j)), worst case O(N2)[.](#general-43.sentence-1)
|
||
|
||
[ð](#general-itemdecl:16)
|
||
|
||
`X(i, j)
|
||
`
|
||
|
||
[44](#general-44)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4608)
|
||
|
||
*Preconditions*: hasher and key_equal meet
|
||
the *Cpp17DefaultConstructible* requirements[.](#general-44.sentence-1)
|
||
|
||
value_type is*Cpp17EmplaceConstructible* into X from *i[.](#general-44.sentence-2)
|
||
|
||
[45](#general-45)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4615)
|
||
|
||
*Effects*: Constructs an empty container with an unspecified number of buckets,
|
||
using hasher() as the hash function andkey_equal() as the key equality predicate, and
|
||
inserts elements from [i, j) into it[.](#general-45.sentence-1)
|
||
|
||
[46](#general-46)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4622)
|
||
|
||
*Complexity*: Average case O(N) (N is distance(i, j)), worst case O(N2)[.](#general-46.sentence-1)
|
||
|
||
[ð](#general-itemdecl:17)
|
||
|
||
`X(from_range, rg, n, hf, eq)
|
||
`
|
||
|
||
[47](#general-47)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4632)
|
||
|
||
*Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from *ranges::begin(rg)[.](#general-47.sentence-1)
|
||
|
||
[48](#general-48)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4638)
|
||
|
||
*Effects*: Constructs an empty container with at least n buckets,
|
||
using hf as the hash function andeq as the key equality predicate, and
|
||
inserts elements from rg into it[.](#general-48.sentence-1)
|
||
|
||
[49](#general-49)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4645)
|
||
|
||
*Complexity*: Average case O(N) (N is ranges::distance(rg)),
|
||
worst case O(N2)[.](#general-49.sentence-1)
|
||
|
||
[ð](#general-itemdecl:18)
|
||
|
||
`X(from_range, rg, n, hf)
|
||
`
|
||
|
||
[50](#general-50)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4656)
|
||
|
||
*Preconditions*: key_equal meets the *Cpp17DefaultConstructible* requirements[.](#general-50.sentence-1)
|
||
|
||
value_type is*Cpp17EmplaceConstructible* into X from *ranges::begin(rg)[.](#general-50.sentence-2)
|
||
|
||
[51](#general-51)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4663)
|
||
|
||
*Effects*: Constructs an empty container with at least n buckets,
|
||
using hf as the hash function andkey_equal() as the key equality predicate, and
|
||
inserts elements from rg into it[.](#general-51.sentence-1)
|
||
|
||
[52](#general-52)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4670)
|
||
|
||
*Complexity*: Average case O(N) (N is ranges::distance(rg)),
|
||
worst case O(N2)[.](#general-52.sentence-1)
|
||
|
||
[ð](#general-itemdecl:19)
|
||
|
||
`X(from_range, rg, n)
|
||
`
|
||
|
||
[53](#general-53)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4681)
|
||
|
||
*Preconditions*: hasher and key_equal meet
|
||
the *Cpp17DefaultConstructible* requirements[.](#general-53.sentence-1)
|
||
|
||
value_type is*Cpp17EmplaceConstructible* into X from *ranges::begin(rg)[.](#general-53.sentence-2)
|
||
|
||
[54](#general-54)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4689)
|
||
|
||
*Effects*: Constructs an empty container with at least n buckets,
|
||
using hasher() as the hash function andkey_equal() as the key equality predicate, and
|
||
inserts elements from rg into it[.](#general-54.sentence-1)
|
||
|
||
[55](#general-55)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4696)
|
||
|
||
*Complexity*: Average case O(N) (N is ranges::distance(rg)),
|
||
worst case O(N2)[.](#general-55.sentence-1)
|
||
|
||
[ð](#general-itemdecl:20)
|
||
|
||
`X(from_range, rg)
|
||
`
|
||
|
||
[56](#general-56)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4707)
|
||
|
||
*Preconditions*: hasher and key_equal meet
|
||
the *Cpp17DefaultConstructible* requirements[.](#general-56.sentence-1)
|
||
|
||
value_type is*Cpp17EmplaceConstructible* into X from *ranges::begin(rg)[.](#general-56.sentence-2)
|
||
|
||
[57](#general-57)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4715)
|
||
|
||
*Effects*: Constructs an empty container with an unspecified number of buckets,
|
||
using hasher() as the hash function andkey_equal() as the key equality predicate, and
|
||
inserts elements from rg into it[.](#general-57.sentence-1)
|
||
|
||
[58](#general-58)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4722)
|
||
|
||
*Complexity*: Average case O(N) (N is ranges::distance(rg)),
|
||
worst case O(N2)[.](#general-58.sentence-1)
|
||
|
||
[ð](#general-itemdecl:21)
|
||
|
||
`X(il)
|
||
`
|
||
|
||
[59](#general-59)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4733)
|
||
|
||
*Effects*: Equivalent to X(il.begin(), il.end())[.](#general-59.sentence-1)
|
||
|
||
[ð](#general-itemdecl:22)
|
||
|
||
`X(il, n)
|
||
`
|
||
|
||
[60](#general-60)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4743)
|
||
|
||
*Effects*: Equivalent to X(il.begin(), il.end(), n)[.](#general-60.sentence-1)
|
||
|
||
[ð](#general-itemdecl:23)
|
||
|
||
`X(il, n, hf)
|
||
`
|
||
|
||
[61](#general-61)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4753)
|
||
|
||
*Effects*: Equivalent to X(il.begin(), il.end(), n, hf)[.](#general-61.sentence-1)
|
||
|
||
[ð](#general-itemdecl:24)
|
||
|
||
`X(il, n, hf, eq)
|
||
`
|
||
|
||
[62](#general-62)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4763)
|
||
|
||
*Effects*: Equivalent to X(il.begin(), il.end(), n, hf, eq)[.](#general-62.sentence-1)
|
||
|
||
[ð](#general-itemdecl:25)
|
||
|
||
`X(b)
|
||
`
|
||
|
||
[63](#general-63)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4773)
|
||
|
||
*Effects*: In addition to the container requirements ([[container.reqmts]](container.reqmts "23.2.2.2 Container requirements")),
|
||
copies the hash function, predicate, and maximum load factor[.](#general-63.sentence-1)
|
||
|
||
[64](#general-64)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4778)
|
||
|
||
*Complexity*: Average case linear in b.size(), worst case quadratic[.](#general-64.sentence-1)
|
||
|
||
[ð](#general-itemdecl:26)
|
||
|
||
`a = b
|
||
`
|
||
|
||
[65](#general-65)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4788)
|
||
|
||
*Result*: X&
|
||
|
||
[66](#general-66)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4792)
|
||
|
||
*Effects*: In addition to the container requirements,
|
||
copies the hash function, predicate, and maximum load factor[.](#general-66.sentence-1)
|
||
|
||
[67](#general-67)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4797)
|
||
|
||
*Complexity*: Average case linear in b.size(), worst case quadratic[.](#general-67.sentence-1)
|
||
|
||
[ð](#general-itemdecl:27)
|
||
|
||
`a = il
|
||
`
|
||
|
||
[68](#general-68)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4807)
|
||
|
||
*Result*: X&
|
||
|
||
[69](#general-69)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4811)
|
||
|
||
*Preconditions*: value_type is *Cpp17CopyInsertable* into X and *Cpp17CopyAssignable*[.](#general-69.sentence-1)
|
||
|
||
[70](#general-70)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4816)
|
||
|
||
*Effects*: Assigns the range [il.begin(), il.end()) into a[.](#general-70.sentence-1)
|
||
|
||
All existing elements of a are either assigned to or destroyed[.](#general-70.sentence-2)
|
||
|
||
[71](#general-71)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4821)
|
||
|
||
*Complexity*: Average case linear in il.size(), worst case quadratic[.](#general-71.sentence-1)
|
||
|
||
[ð](#lib:hash_function,unordered_associative_containers)
|
||
|
||
`b.hash_function()
|
||
`
|
||
|
||
[72](#general-72)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4832)
|
||
|
||
*Result*: hasher
|
||
|
||
[73](#general-73)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4836)
|
||
|
||
*Returns*: b's hash function[.](#general-73.sentence-1)
|
||
|
||
[74](#general-74)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4840)
|
||
|
||
*Complexity*: Constant[.](#general-74.sentence-1)
|
||
|
||
[ð](#lib:key_eq,unordered_associative_containers)
|
||
|
||
`b.key_eq()
|
||
`
|
||
|
||
[75](#general-75)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4851)
|
||
|
||
*Result*: key_equal
|
||
|
||
[76](#general-76)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4855)
|
||
|
||
*Returns*: b's key equality predicate[.](#general-76.sentence-1)
|
||
|
||
[77](#general-77)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4859)
|
||
|
||
*Complexity*: Constant[.](#general-77.sentence-1)
|
||
|
||
[ð](#lib:emplace,unordered_associative_containers)
|
||
|
||
`a_uniq.emplace(args)
|
||
`
|
||
|
||
[78](#general-78)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4870)
|
||
|
||
*Result*: pair<iterator, bool>
|
||
|
||
[79](#general-79)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4874)
|
||
|
||
*Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from args[.](#general-79.sentence-1)
|
||
|
||
[80](#general-80)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4879)
|
||
|
||
*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-80.sentence-1)
|
||
|
||
[81](#general-81)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4886)
|
||
|
||
*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-81.sentence-1)
|
||
|
||
[82](#general-82)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4893)
|
||
|
||
*Complexity*: Average case O(1), worst case O(a_uniq.size())[.](#general-82.sentence-1)
|
||
|
||
[ð](#lib:emplace,unordered_associative_containers_)
|
||
|
||
`a_eq.emplace(args)
|
||
`
|
||
|
||
[83](#general-83)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4904)
|
||
|
||
*Result*: iterator
|
||
|
||
[84](#general-84)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4908)
|
||
|
||
*Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from args[.](#general-84.sentence-1)
|
||
|
||
[85](#general-85)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4913)
|
||
|
||
*Effects*: Inserts a value_type object t constructed with std::forward<Args>(args)...[.](#general-85.sentence-1)
|
||
|
||
[86](#general-86)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4918)
|
||
|
||
*Returns*: An iterator pointing to the newly inserted element[.](#general-86.sentence-1)
|
||
|
||
[87](#general-87)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4922)
|
||
|
||
*Complexity*: Average case O(1), worst case O(a_eq.size())[.](#general-87.sentence-1)
|
||
|
||
[ð](#lib:emplace_hint,unordered_associative_containers)
|
||
|
||
`a.emplace_hint(p, args)
|
||
`
|
||
|
||
[88](#general-88)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4933)
|
||
|
||
*Result*: iterator
|
||
|
||
[89](#general-89)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4937)
|
||
|
||
*Effects*: Equivalent to a.emplace(std::forward<Args>(args)...),
|
||
except that the const_iterator p is a hint
|
||
pointing to where the search should start[.](#general-89.sentence-1)
|
||
|
||
Implementations are permitted to ignore the hint[.](#general-89.sentence-2)
|
||
|
||
[90](#general-90)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4944)
|
||
|
||
*Returns*: The iterator returned by emplace[.](#general-90.sentence-1)
|
||
|
||
[ð](#lib:insert,unordered_associative_containers)
|
||
|
||
`a_uniq.insert(t)
|
||
`
|
||
|
||
[91](#general-91)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4955)
|
||
|
||
*Result*: pair<iterator, bool>
|
||
|
||
[92](#general-92)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4959)
|
||
|
||
*Preconditions*: If t is a non-const rvalue,value_type is *Cpp17MoveInsertable* into X;
|
||
otherwise, value_type is *Cpp17CopyInsertable* into X[.](#general-92.sentence-1)
|
||
|
||
[93](#general-93)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4965)
|
||
|
||
*Effects*: Inserts t if and only if there is no element in the container
|
||
with key equivalent to the key of t[.](#general-93.sentence-1)
|
||
|
||
[94](#general-94)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4970)
|
||
|
||
*Returns*: The bool component of the returned pair indicates
|
||
whether the insertion takes place, and
|
||
the iterator component points to
|
||
the element with key equivalent to the key of t[.](#general-94.sentence-1)
|
||
|
||
[95](#general-95)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4977)
|
||
|
||
*Complexity*: Average case O(1), worst case O(a_uniq.size())[.](#general-95.sentence-1)
|
||
|
||
[ð](#lib:insert,unordered_associative_containers_)
|
||
|
||
`a_eq.insert(t)
|
||
`
|
||
|
||
[96](#general-96)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4988)
|
||
|
||
*Result*: iterator
|
||
|
||
[97](#general-97)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4992)
|
||
|
||
*Preconditions*: If t is a non-const rvalue,value_type is *Cpp17MoveInsertable* into X;
|
||
otherwise, value_type is *Cpp17CopyInsertable* into X[.](#general-97.sentence-1)
|
||
|
||
[98](#general-98)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L4998)
|
||
|
||
*Effects*: Inserts t[.](#general-98.sentence-1)
|
||
|
||
[99](#general-99)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5002)
|
||
|
||
*Returns*: An iterator pointing to the newly inserted element[.](#general-99.sentence-1)
|
||
|
||
[100](#general-100)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5006)
|
||
|
||
*Complexity*: Average case O(1), worst case O(a_eq.size())[.](#general-100.sentence-1)
|
||
|
||
[ð](#lib:insert,unordered_associative_containers__)
|
||
|
||
`a.insert(p, t)
|
||
`
|
||
|
||
[101](#general-101)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5017)
|
||
|
||
*Result*: iterator
|
||
|
||
[102](#general-102)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5021)
|
||
|
||
*Preconditions*: If t is a non-const rvalue,value_type is *Cpp17MoveInsertable* into X;
|
||
otherwise, value_type is *Cpp17CopyInsertable* into X[.](#general-102.sentence-1)
|
||
|
||
[103](#general-103)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5027)
|
||
|
||
*Effects*: Equivalent to a.insert(t)[.](#general-103.sentence-1)
|
||
|
||
The iterator p is a hint pointing to where the search should start[.](#general-103.sentence-2)
|
||
|
||
Implementations are permitted to ignore the hint[.](#general-103.sentence-3)
|
||
|
||
[104](#general-104)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5033)
|
||
|
||
*Returns*: An iterator pointing to
|
||
the element with the key equivalent to that of t[.](#general-104.sentence-1)
|
||
|
||
[105](#general-105)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5038)
|
||
|
||
*Complexity*: Average case O(1), worst case O(a.size())[.](#general-105.sentence-1)
|
||
|
||
[ð](#lib:insert,unordered_associative_containers___)
|
||
|
||
`a.insert(i, j)
|
||
`
|
||
|
||
[106](#general-106)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5049)
|
||
|
||
*Result*: void
|
||
|
||
[107](#general-107)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5053)
|
||
|
||
*Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from *i[.](#general-107.sentence-1)
|
||
|
||
Neither i nor j are iterators into a[.](#general-107.sentence-2)
|
||
|
||
[108](#general-108)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5059)
|
||
|
||
*Effects*: Equivalent to a.insert(t) for each element in [i, j)[.](#general-108.sentence-1)
|
||
|
||
[109](#general-109)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5063)
|
||
|
||
*Complexity*: Average case O(N), where N is distance(i, j),
|
||
worst case O(N(a.size()+1))[.](#general-109.sentence-1)
|
||
|
||
[ð](#lib:insert_range,unordered_associative_containers)
|
||
|
||
`a.insert_range(rg)
|
||
`
|
||
|
||
[110](#general-110)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5075)
|
||
|
||
*Result*: void
|
||
|
||
[111](#general-111)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5079)
|
||
|
||
*Preconditions*: value_type is*Cpp17EmplaceConstructible* into X from *ranges::begin(rg)[.](#general-111.sentence-1)
|
||
|
||
rg and a do not overlap[.](#general-111.sentence-2)
|
||
|
||
[112](#general-112)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5086)
|
||
|
||
*Effects*: Equivalent to a.insert(t) for each element t in rg[.](#general-112.sentence-1)
|
||
|
||
[113](#general-113)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5090)
|
||
|
||
*Complexity*: Average case O(N), where N is ranges::distance(rg),
|
||
worst case O(N(a.size()+1))[.](#general-113.sentence-1)
|
||
|
||
[ð](#lib:insert,unordered_associative_containers____)
|
||
|
||
`a.insert(il)
|
||
`
|
||
|
||
[114](#general-114)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5102)
|
||
|
||
*Effects*: Equivalent to a.insert(il.begin(), il.end())[.](#general-114.sentence-1)
|
||
|
||
[ð](#lib:insert,unordered_associative_containers_____)
|
||
|
||
`a_uniq.insert(nh)
|
||
`
|
||
|
||
[115](#general-115)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5113)
|
||
|
||
*Result*: insert_return_type
|
||
|
||
[116](#general-116)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5117)
|
||
|
||
*Preconditions*: nh is empty ora_uniq.get_allocator() == nh.get_allocator() is true[.](#general-116.sentence-1)
|
||
|
||
[117](#general-117)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5122)
|
||
|
||
*Effects*: If nh is empty, has no effect[.](#general-117.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-117.sentence-2)
|
||
|
||
[118](#general-118)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5128)
|
||
|
||
*Postconditions*: If nh is empty, inserted is false,position is end(), and node is empty[.](#general-118.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, and position points to an element with a key equivalent to nh.key()[.](#general-118.sentence-2)
|
||
|
||
[119](#general-119)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5138)
|
||
|
||
*Complexity*: Average case O(1), worst case O(a_uniq.size())[.](#general-119.sentence-1)
|
||
|
||
[ð](#lib:insert,unordered_associative_containers______)
|
||
|
||
`a_eq.insert(nh)
|
||
`
|
||
|
||
[120](#general-120)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5149)
|
||
|
||
*Result*: iterator
|
||
|
||
[121](#general-121)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5153)
|
||
|
||
*Preconditions*: nh is empty ora_eq.get_allocator() == nh.get_allocator() is true[.](#general-121.sentence-1)
|
||
|
||
[122](#general-122)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5158)
|
||
|
||
*Effects*: If nh is empty, has no effect and returns a_eq.end()[.](#general-122.sentence-1)
|
||
|
||
Otherwise, inserts the element owned by nh and
|
||
returns an iterator pointing to the newly inserted element[.](#general-122.sentence-2)
|
||
|
||
[123](#general-123)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5164)
|
||
|
||
*Postconditions*: nh is empty[.](#general-123.sentence-1)
|
||
|
||
[124](#general-124)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5168)
|
||
|
||
*Complexity*: Average case O(1), worst case O(a_eq.size())[.](#general-124.sentence-1)
|
||
|
||
[ð](#lib:insert,unordered_associative_containers_______)
|
||
|
||
`a.insert(q, nh)
|
||
`
|
||
|
||
[125](#general-125)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5179)
|
||
|
||
*Result*: iterator
|
||
|
||
[126](#general-126)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5183)
|
||
|
||
*Preconditions*: nh is empty ora.get_allocator() == nh.get_allocator() is true[.](#general-126.sentence-1)
|
||
|
||
[127](#general-127)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5188)
|
||
|
||
*Effects*: If nh is empty, has no effect and returns a.end()[.](#general-127.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-127.sentence-2)
|
||
|
||
The iterator q is a hint pointing to where the search should start[.](#general-127.sentence-3)
|
||
|
||
Implementations are permitted to ignore the hint[.](#general-127.sentence-4)
|
||
|
||
[128](#general-128)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5199)
|
||
|
||
*Postconditions*: nh is empty if insertion succeeds, unchanged if insertion fails[.](#general-128.sentence-1)
|
||
|
||
[129](#general-129)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5203)
|
||
|
||
*Returns*: An iterator pointing to the element with key equivalent to nh.key()[.](#general-129.sentence-1)
|
||
|
||
[130](#general-130)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5207)
|
||
|
||
*Complexity*: Average case O(1), worst case O(a.size())[.](#general-130.sentence-1)
|
||
|
||
[ð](#lib:extract,unordered_associative_containers)
|
||
|
||
`a.extract(k)
|
||
`
|
||
|
||
[131](#general-131)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5218)
|
||
|
||
*Result*: node_type
|
||
|
||
[132](#general-132)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5222)
|
||
|
||
*Effects*: Removes an element in the container with key equivalent to k[.](#general-132.sentence-1)
|
||
|
||
[133](#general-133)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5226)
|
||
|
||
*Returns*: A node_type owning the element if found,
|
||
otherwise an empty node_type[.](#general-133.sentence-1)
|
||
|
||
[134](#general-134)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5231)
|
||
|
||
*Complexity*: Average case O(1), worst case O(a.size())[.](#general-134.sentence-1)
|
||
|
||
[ð](#lib:extract,unordered_associative_containers_)
|
||
|
||
`a_tran.extract(kx)
|
||
`
|
||
|
||
[135](#general-135)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5242)
|
||
|
||
*Result*: node_type
|
||
|
||
[136](#general-136)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5246)
|
||
|
||
*Effects*: Removes an element in the container with key equivalent to kx[.](#general-136.sentence-1)
|
||
|
||
[137](#general-137)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5250)
|
||
|
||
*Returns*: A node_type owning the element if found,
|
||
otherwise an empty node_type[.](#general-137.sentence-1)
|
||
|
||
[138](#general-138)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5255)
|
||
|
||
*Complexity*: Average case O(1), worst case O(a_tran.size())[.](#general-138.sentence-1)
|
||
|
||
[ð](#lib:extract,unordered_associative_containers__)
|
||
|
||
`a.extract(q)
|
||
`
|
||
|
||
[139](#general-139)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5266)
|
||
|
||
*Result*: node_type
|
||
|
||
[140](#general-140)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5270)
|
||
|
||
*Effects*: Removes the element pointed to by q[.](#general-140.sentence-1)
|
||
|
||
[141](#general-141)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5274)
|
||
|
||
*Returns*: A node_type owning that element[.](#general-141.sentence-1)
|
||
|
||
[142](#general-142)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5278)
|
||
|
||
*Complexity*: Average case O(1), worst case O(a.size())[.](#general-142.sentence-1)
|
||
|
||
[ð](#lib:merge,unordered_associative_containers)
|
||
|
||
`a.merge(a2)
|
||
`
|
||
|
||
[143](#general-143)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5289)
|
||
|
||
*Result*: void
|
||
|
||
[144](#general-144)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5293)
|
||
|
||
*Preconditions*: a.get_allocator() == a2.get_allocator()[.](#general-144.sentence-1)
|
||
|
||
[145](#general-145)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5297)
|
||
|
||
*Effects*: Attempts to extract each element in a2 and insert it into a using the hash function and key equality predicate of a[.](#general-145.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-145.sentence-2)
|
||
|
||
[146](#general-146)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5305)
|
||
|
||
*Postconditions*: Pointers and references to the transferred elements of a2 refer to
|
||
those same elements but as members of a[.](#general-146.sentence-1)
|
||
|
||
Iterators referring to the transferred elements and
|
||
all iterators referring to a will be invalidated,
|
||
but iterators to elements remaining in a2 will remain valid[.](#general-146.sentence-2)
|
||
|
||
[147](#general-147)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5313)
|
||
|
||
*Complexity*: Average case O(N), where N is a2.size(),
|
||
worst case O(N*a.size() + N)[.](#general-147.sentence-1)
|
||
|
||
[ð](#lib:erase,unordered_associative_containers)
|
||
|
||
`a.erase(k)
|
||
`
|
||
|
||
[148](#general-148)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5325)
|
||
|
||
*Result*: size_type
|
||
|
||
[149](#general-149)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5329)
|
||
|
||
*Effects*: Erases all elements with key equivalent to k[.](#general-149.sentence-1)
|
||
|
||
[150](#general-150)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5333)
|
||
|
||
*Returns*: The number of elements erased[.](#general-150.sentence-1)
|
||
|
||
[151](#general-151)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5337)
|
||
|
||
*Complexity*: Average case O(a.count(k)), worst case O(a.size())[.](#general-151.sentence-1)
|
||
|
||
[ð](#lib:erase,unordered_associative_containers_)
|
||
|
||
`a_tran.erase(kx)
|
||
`
|
||
|
||
[152](#general-152)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5348)
|
||
|
||
*Result*: size_type
|
||
|
||
[153](#general-153)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5352)
|
||
|
||
*Effects*: Erases all elements with key equivalent to kx[.](#general-153.sentence-1)
|
||
|
||
[154](#general-154)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5356)
|
||
|
||
*Returns*: The number of elements erased[.](#general-154.sentence-1)
|
||
|
||
[155](#general-155)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5360)
|
||
|
||
*Complexity*: Average case O(a_tran.count(kx)),
|
||
worst case O(a_tran.size())[.](#general-155.sentence-1)
|
||
|
||
[ð](#lib:erase,unordered_associative_containers__)
|
||
|
||
`a.erase(q)
|
||
`
|
||
|
||
[156](#general-156)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5372)
|
||
|
||
*Result*: iterator
|
||
|
||
[157](#general-157)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5376)
|
||
|
||
*Effects*: Erases the element pointed to by q[.](#general-157.sentence-1)
|
||
|
||
[158](#general-158)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5380)
|
||
|
||
*Returns*: The iterator immediately following q prior to the erasure[.](#general-158.sentence-1)
|
||
|
||
[159](#general-159)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5384)
|
||
|
||
*Complexity*: Average case O(1), worst case O(a.size())[.](#general-159.sentence-1)
|
||
|
||
[ð](#lib:erase,unordered_associative_containers___)
|
||
|
||
`a.erase(r)
|
||
`
|
||
|
||
[160](#general-160)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5395)
|
||
|
||
*Result*: iterator
|
||
|
||
[161](#general-161)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5399)
|
||
|
||
*Effects*: Erases the element pointed to by r[.](#general-161.sentence-1)
|
||
|
||
[162](#general-162)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5403)
|
||
|
||
*Returns*: The iterator immediately following r prior to the erasure[.](#general-162.sentence-1)
|
||
|
||
[163](#general-163)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5407)
|
||
|
||
*Complexity*: Average case O(1), worst case O(a.size())[.](#general-163.sentence-1)
|
||
|
||
[ð](#lib:erase,unordered_associative_containers____)
|
||
|
||
`a.erase(q1, q2)
|
||
`
|
||
|
||
[164](#general-164)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5418)
|
||
|
||
*Result*: iterator
|
||
|
||
[165](#general-165)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5422)
|
||
|
||
*Effects*: Erases all elements in the range [q1, q2)[.](#general-165.sentence-1)
|
||
|
||
[166](#general-166)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5426)
|
||
|
||
*Returns*: The iterator immediately following the erased elements prior to the erasure[.](#general-166.sentence-1)
|
||
|
||
[167](#general-167)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5430)
|
||
|
||
*Complexity*: Average case linear in distance(q1, q2),
|
||
worst case O(a.size())[.](#general-167.sentence-1)
|
||
|
||
[ð](#lib:clear,unordered_associative_containers)
|
||
|
||
`a.clear()
|
||
`
|
||
|
||
[168](#general-168)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5442)
|
||
|
||
*Result*: void
|
||
|
||
[169](#general-169)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5446)
|
||
|
||
*Effects*: Erases all elements in the container[.](#general-169.sentence-1)
|
||
|
||
[170](#general-170)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5450)
|
||
|
||
*Postconditions*: a.empty() is true[.](#general-170.sentence-1)
|
||
|
||
[171](#general-171)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5454)
|
||
|
||
*Complexity*: Linear in a.size()[.](#general-171.sentence-1)
|
||
|
||
[ð](#lib:find,unordered_associative_containers)
|
||
|
||
`b.find(k)
|
||
`
|
||
|
||
[172](#general-172)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5465)
|
||
|
||
*Result*: iterator; const_iterator for constant b[.](#general-172.sentence-1)
|
||
|
||
[173](#general-173)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5469)
|
||
|
||
*Returns*: An iterator pointing to an element with key equivalent to k, orb.end() if no such element exists[.](#general-173.sentence-1)
|
||
|
||
[174](#general-174)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5474)
|
||
|
||
*Complexity*: Average case O(1), worst case O(b.size())[.](#general-174.sentence-1)
|
||
|
||
[ð](#lib:find,unordered_associative_containers_)
|
||
|
||
`a_tran.find(ke)
|
||
`
|
||
|
||
[175](#general-175)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5485)
|
||
|
||
*Result*: iterator; const_iterator for constant a_tran[.](#general-175.sentence-1)
|
||
|
||
[176](#general-176)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5489)
|
||
|
||
*Returns*: An iterator pointing to an element with key equivalent to ke, ora_tran.end() if no such element exists[.](#general-176.sentence-1)
|
||
|
||
[177](#general-177)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5494)
|
||
|
||
*Complexity*: Average case O(1), worst case O(a_tran.size())[.](#general-177.sentence-1)
|
||
|
||
[ð](#lib:count,unordered_associative_containers)
|
||
|
||
`b.count(k)
|
||
`
|
||
|
||
[178](#general-178)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5505)
|
||
|
||
*Result*: size_type
|
||
|
||
[179](#general-179)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5509)
|
||
|
||
*Returns*: The number of elements with key equivalent to k[.](#general-179.sentence-1)
|
||
|
||
[180](#general-180)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5513)
|
||
|
||
*Complexity*: Average case O(b.count(k)), worst case O(b.size())[.](#general-180.sentence-1)
|
||
|
||
[ð](#lib:count,unordered_associative_containers_)
|
||
|
||
`a_tran.count(ke)
|
||
`
|
||
|
||
[181](#general-181)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5524)
|
||
|
||
*Result*: size_type
|
||
|
||
[182](#general-182)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5528)
|
||
|
||
*Returns*: The number of elements with key equivalent to ke[.](#general-182.sentence-1)
|
||
|
||
[183](#general-183)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5532)
|
||
|
||
*Complexity*: Average case O(a_tran.count(ke)),
|
||
worst case O(a_tran.size())[.](#general-183.sentence-1)
|
||
|
||
[ð](#lib:contains,unordered_associative_containers)
|
||
|
||
`b.contains(k)
|
||
`
|
||
|
||
[184](#general-184)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5544)
|
||
|
||
*Effects*: Equivalent to b.find(k) != b.end()[.](#general-184.sentence-1)
|
||
|
||
[ð](#lib:contains,unordered_associative_containers_)
|
||
|
||
`a_tran.contains(ke)
|
||
`
|
||
|
||
[185](#general-185)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5555)
|
||
|
||
*Effects*: Equivalent to a_tran.find(ke) != a_tran.end()[.](#general-185.sentence-1)
|
||
|
||
[ð](#lib:equal_range,unordered_associative_containers)
|
||
|
||
`b.equal_range(k)
|
||
`
|
||
|
||
[186](#general-186)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5566)
|
||
|
||
*Result*: pair<iterator, iterator>;pair<const_iterator, const_iterator> for constant b[.](#general-186.sentence-1)
|
||
|
||
[187](#general-187)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5571)
|
||
|
||
*Returns*: A range containing all elements with keys equivalent to k[.](#general-187.sentence-1)
|
||
|
||
Returns make_pair(b.end(), b.end()) if no such elements exist[.](#general-187.sentence-2)
|
||
|
||
[188](#general-188)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5576)
|
||
|
||
*Complexity*: Average case O(b.count(k)), worst case O(b.size())[.](#general-188.sentence-1)
|
||
|
||
[ð](#lib:equal_range,unordered_associative_containers_)
|
||
|
||
`a_tran.equal_range(ke)
|
||
`
|
||
|
||
[189](#general-189)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5587)
|
||
|
||
*Result*: pair<iterator, iterator>;pair<const_iterator, const_iterator> for constant a_tran[.](#general-189.sentence-1)
|
||
|
||
[190](#general-190)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5592)
|
||
|
||
*Returns*: A range containing all elements with keys equivalent to ke[.](#general-190.sentence-1)
|
||
|
||
Returns make_pair(a_tran.end(), a_tran.end()) if no such elements exist[.](#general-190.sentence-2)
|
||
|
||
[191](#general-191)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5597)
|
||
|
||
*Complexity*: Average case O(a_tran.count(ke)),
|
||
worst case O(a_tran.size())[.](#general-191.sentence-1)
|
||
|
||
[ð](#lib:bucket_count,unordered_associative_containers)
|
||
|
||
`b.bucket_count()
|
||
`
|
||
|
||
[192](#general-192)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5609)
|
||
|
||
*Result*: size_type
|
||
|
||
[193](#general-193)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5613)
|
||
|
||
*Returns*: The number of buckets that b contains[.](#general-193.sentence-1)
|
||
|
||
[194](#general-194)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5617)
|
||
|
||
*Complexity*: Constant[.](#general-194.sentence-1)
|
||
|
||
[ð](#lib:max_bucket_count,unordered_associative_containers)
|
||
|
||
`b.max_bucket_count()
|
||
`
|
||
|
||
[195](#general-195)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5628)
|
||
|
||
*Result*: size_type
|
||
|
||
[196](#general-196)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5632)
|
||
|
||
*Returns*: An upper bound on the number of buckets that b can ever contain[.](#general-196.sentence-1)
|
||
|
||
[197](#general-197)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5636)
|
||
|
||
*Complexity*: Constant[.](#general-197.sentence-1)
|
||
|
||
[ð](#lib:bucket,unordered_associative_containers)
|
||
|
||
`b.bucket(k)
|
||
`
|
||
|
||
[198](#general-198)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5647)
|
||
|
||
*Result*: size_type
|
||
|
||
[199](#general-199)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5651)
|
||
|
||
*Preconditions*: b.bucket_count() > 0[.](#general-199.sentence-1)
|
||
|
||
[200](#general-200)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5655)
|
||
|
||
*Returns*: The index of the bucket
|
||
in which elements with keys equivalent to k would be found,
|
||
if any such element existed[.](#general-200.sentence-1)
|
||
|
||
The return value is in the range [0, b.bucket_count())[.](#general-200.sentence-2)
|
||
|
||
[201](#general-201)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5662)
|
||
|
||
*Complexity*: Constant[.](#general-201.sentence-1)
|
||
|
||
[ð](#lib:bucket,unordered_associative_containers_)
|
||
|
||
`a_tran.bucket(ke)
|
||
`
|
||
|
||
[202](#general-202)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5673)
|
||
|
||
*Result*: size_type
|
||
|
||
[203](#general-203)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5677)
|
||
|
||
*Preconditions*: a_tran.bucket_count() > 0[.](#general-203.sentence-1)
|
||
|
||
[204](#general-204)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5681)
|
||
|
||
*Postconditions*: The return value is in the range [0, a_tran.bucket_count())[.](#general-204.sentence-1)
|
||
|
||
[205](#general-205)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5685)
|
||
|
||
*Returns*: The index of the bucket
|
||
in which elements with keys equivalent to ke would be found,
|
||
if any such element existed[.](#general-205.sentence-1)
|
||
|
||
[206](#general-206)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5691)
|
||
|
||
*Complexity*: Constant[.](#general-206.sentence-1)
|
||
|
||
[ð](#lib:bucket_size,unordered_associative_containers)
|
||
|
||
`b.bucket_size(n)
|
||
`
|
||
|
||
[207](#general-207)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5702)
|
||
|
||
*Result*: size_type
|
||
|
||
[208](#general-208)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5706)
|
||
|
||
*Preconditions*: n shall be in the range [0, b.bucket_count())[.](#general-208.sentence-1)
|
||
|
||
[209](#general-209)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5710)
|
||
|
||
*Returns*: The number of elements in the nth bucket[.](#general-209.sentence-1)
|
||
|
||
[210](#general-210)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5714)
|
||
|
||
*Complexity*: O(b.bucket_size(n))
|
||
|
||
[ð](#lib:begin,unordered_associative_containers)
|
||
|
||
`b.begin(n)
|
||
`
|
||
|
||
[211](#general-211)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5725)
|
||
|
||
*Result*: local_iterator; const_local_iterator for constant b[.](#general-211.sentence-1)
|
||
|
||
[212](#general-212)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5729)
|
||
|
||
*Preconditions*: n is in the range [0, b.bucket_count())[.](#general-212.sentence-1)
|
||
|
||
[213](#general-213)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5733)
|
||
|
||
*Returns*: An iterator referring to the first element in the bucket[.](#general-213.sentence-1)
|
||
|
||
If the bucket is empty, then b.begin(n) == b.end(n)[.](#general-213.sentence-2)
|
||
|
||
[214](#general-214)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5738)
|
||
|
||
*Complexity*: Constant[.](#general-214.sentence-1)
|
||
|
||
[ð](#lib:end,unordered_associative_containers)
|
||
|
||
`b.end(n)
|
||
`
|
||
|
||
[215](#general-215)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5749)
|
||
|
||
*Result*: local_iterator; const_local_iterator for constant b[.](#general-215.sentence-1)
|
||
|
||
[216](#general-216)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5753)
|
||
|
||
*Preconditions*: n is in the range [0, b.bucket_count())[.](#general-216.sentence-1)
|
||
|
||
[217](#general-217)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5757)
|
||
|
||
*Returns*: An iterator which is the past-the-end value for the bucket[.](#general-217.sentence-1)
|
||
|
||
[218](#general-218)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5761)
|
||
|
||
*Complexity*: Constant[.](#general-218.sentence-1)
|
||
|
||
[ð](#lib:cbegin,unordered_associative_containers)
|
||
|
||
`b.cbegin(n)
|
||
`
|
||
|
||
[219](#general-219)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5772)
|
||
|
||
*Result*: const_local_iterator
|
||
|
||
[220](#general-220)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5776)
|
||
|
||
*Preconditions*: n shall be in the range [0, b.bucket_count())[.](#general-220.sentence-1)
|
||
|
||
[221](#general-221)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5780)
|
||
|
||
*Returns*: An iterator referring to the first element in the bucket[.](#general-221.sentence-1)
|
||
|
||
If the bucket is empty, then b.cbegin(n) == b.cend(n)[.](#general-221.sentence-2)
|
||
|
||
[222](#general-222)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5785)
|
||
|
||
*Complexity*: Constant[.](#general-222.sentence-1)
|
||
|
||
[ð](#lib:cend,unordered_associative_containers)
|
||
|
||
`b.cend(n)
|
||
`
|
||
|
||
[223](#general-223)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5796)
|
||
|
||
*Result*: const_local_iterator
|
||
|
||
[224](#general-224)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5800)
|
||
|
||
*Preconditions*: n is in the range [0, b.bucket_count())[.](#general-224.sentence-1)
|
||
|
||
[225](#general-225)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5804)
|
||
|
||
*Returns*: An iterator which is the past-the-end value for the bucket[.](#general-225.sentence-1)
|
||
|
||
[226](#general-226)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5808)
|
||
|
||
*Complexity*: Constant[.](#general-226.sentence-1)
|
||
|
||
[ð](#lib:load_factor,unordered_associative_containers)
|
||
|
||
`b.load_factor()
|
||
`
|
||
|
||
[227](#general-227)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5819)
|
||
|
||
*Result*: float
|
||
|
||
[228](#general-228)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5823)
|
||
|
||
*Returns*: The average number of elements per bucket[.](#general-228.sentence-1)
|
||
|
||
[229](#general-229)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5827)
|
||
|
||
*Complexity*: Constant[.](#general-229.sentence-1)
|
||
|
||
[ð](#lib:max_load_factor,unordered_associative_containers)
|
||
|
||
`b.max_load_factor()
|
||
`
|
||
|
||
[230](#general-230)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5838)
|
||
|
||
*Result*: float
|
||
|
||
[231](#general-231)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5842)
|
||
|
||
*Returns*: A positive number
|
||
that the container attempts to keep the load factor less than or equal to[.](#general-231.sentence-1)
|
||
|
||
The container automatically increases the number of buckets as necessary
|
||
to keep the load factor below this number[.](#general-231.sentence-2)
|
||
|
||
[232](#general-232)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5849)
|
||
|
||
*Complexity*: Constant[.](#general-232.sentence-1)
|
||
|
||
[ð](#lib:max_load_factor,unordered_associative_containers_)
|
||
|
||
`a.max_load_factor(z)
|
||
`
|
||
|
||
[233](#general-233)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5860)
|
||
|
||
*Result*: void
|
||
|
||
[234](#general-234)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5864)
|
||
|
||
*Preconditions*: z is positive[.](#general-234.sentence-1)
|
||
|
||
May change the container's maximum load factor, using z as a hint[.](#general-234.sentence-2)
|
||
|
||
[235](#general-235)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5869)
|
||
|
||
*Complexity*: Constant[.](#general-235.sentence-1)
|
||
|
||
[ð](#lib:rehash,unordered_associative_containers)
|
||
|
||
`a.rehash(n)
|
||
`
|
||
|
||
[236](#general-236)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5880)
|
||
|
||
*Result*: void
|
||
|
||
[237](#general-237)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5884)
|
||
|
||
*Postconditions*: a.bucket_count() >= a.size() / a.max_load_factor() anda.bucket_count() >= n[.](#general-237.sentence-1)
|
||
|
||
[238](#general-238)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5889)
|
||
|
||
*Complexity*: Average case linear in a.size(), worst case quadratic[.](#general-238.sentence-1)
|
||
|
||
[ð](#lib:reserve,unordered_associative_containers)
|
||
|
||
`a.reserve(n)
|
||
`
|
||
|
||
[239](#general-239)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5900)
|
||
|
||
*Effects*: Equivalent to a.rehash(ceil(n / a.max_load_factor()))[.](#general-239.sentence-1)
|
||
|
||
[240](#general-240)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5905)
|
||
|
||
Two unordered containers a and b compare equal ifa.size() == b.size() and, for every equivalent-key group
|
||
[Ea1, Ea2) obtained from a.equal_range(Ea1), there exists an
|
||
equivalent-key group [Eb1, Eb2) obtained from b.equal_range(Ea1),
|
||
such thatis_permutation(Ea1, Ea2, Eb1, Eb2) returns true[.](#general-240.sentence-1)
|
||
|
||
Forunordered_set and unordered_map, the complexity ofoperator== (i.e., the number of calls to the == operator
|
||
of the value_type, to the predicate returned by key_eq(),
|
||
and to the hasher returned by hash_function()) is proportional toN in the average case and to N2 in the worst case, where N isa.size()[.](#general-240.sentence-2)
|
||
|
||
For unordered_multiset and unordered_multimap,
|
||
the complexity of operator== is proportional to âE2i in the average case and to N2 in the worst case, where N is a.size(),
|
||
and Ei is the size of the ith equivalent-key group in a[.](#general-240.sentence-3)
|
||
|
||
However, if the respective elements of each corresponding pair of
|
||
equivalent-key groups Eai and Ebi are arranged in the same order
|
||
(as is commonly the case, e.g., if a and b are unmodified copies
|
||
of the same container), then the average-case complexity forunordered_multiset and unordered_multimap becomes
|
||
proportional to N (but worst-case complexity remains O(N2), e.g., for
|
||
a pathologically bad hash function)[.](#general-240.sentence-4)
|
||
|
||
The behavior of a program that usesoperator== or operator!= on unordered containers is undefined
|
||
unless the Pred function object has
|
||
the same behavior for both containers and the equality comparison function
|
||
for Key is a refinement[194](#footnote-194 "Equality comparison is a refinement of partitioning if no two objects that compare equal fall into different partitions.") of the partition into equivalent-key groups produced by Pred[.](#general-240.sentence-5)
|
||
|
||
[241](#general-241)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5939)
|
||
|
||
The iterator types iterator and const_iterator of
|
||
an unordered associative container are of at least the forward iterator
|
||
category[.](#general-241.sentence-1)
|
||
|
||
For unordered associative containers where the key type and
|
||
value type are the same, both iterator andconst_iterator are constant iterators[.](#general-241.sentence-2)
|
||
|
||
[242](#general-242)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5947)
|
||
|
||
The insert, insert_range, and emplace members
|
||
shall not affect the validity of references to
|
||
container elements, but may invalidate all iterators to the
|
||
container[.](#general-242.sentence-1)
|
||
|
||
The erase members shall invalidate only iterators and
|
||
references to the erased elements, and preserve the relative order of the
|
||
elements that are not erased[.](#general-242.sentence-2)
|
||
|
||
[243](#general-243)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5956)
|
||
|
||
The insert, insert_range, and emplace members
|
||
shall not affect the validity of iterators if(N + n) <= z * B, where N is the number of elements in
|
||
the container prior to the insert operation, n is the
|
||
number of elements inserted, B is the container's bucket count, andz is the container's maximum load factor[.](#general-243.sentence-1)
|
||
|
||
[244](#general-244)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5966)
|
||
|
||
The extract members invalidate only iterators to the removed element,
|
||
and preserve the relative order of the elements that are not erased; pointers
|
||
and references to the removed element remain valid[.](#general-244.sentence-1)
|
||
|
||
However, accessing the
|
||
element through such pointers and references while the element is owned by anode_type is undefined behavior[.](#general-244.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-244.sentence-3)
|
||
|
||
[245](#general-245)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5975)
|
||
|
||
The member function templatesfind, count, equal_range, contains,extract, erase, and bucket 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]")*s*Pred::is_transparent andHash::is_transparent are both valid and denote types ([[temp.deduct]](temp.deduct "13.10.3 Template argument deduction"))[.](#general-245.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-245.sentence-2)
|
||
|
||
[246](#general-246)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L5990)
|
||
|
||
A deduction guide for an unordered associative container shall not participate in overload resolution
|
||
if any of the following are true:
|
||
|
||
- [(246.1)](#general-246.1)
|
||
|
||
It has an InputIterator template parameter
|
||
and a type that does not qualify as an input iterator is deduced for that parameter[.](#general-246.1.sentence-1)
|
||
|
||
- [(246.2)](#general-246.2)
|
||
|
||
It has an Allocator template parameter
|
||
and a type that does not qualify as an allocator is deduced for that parameter[.](#general-246.2.sentence-1)
|
||
|
||
- [(246.3)](#general-246.3)
|
||
|
||
It has a Hash template parameter
|
||
and an integral type or a type that qualifies as an allocator is deduced for that parameter[.](#general-246.3.sentence-1)
|
||
|
||
- [(246.4)](#general-246.4)
|
||
|
||
It has a Pred template parameter
|
||
and a type that qualifies as an allocator is deduced for that parameter[.](#general-246.4.sentence-1)
|
||
|
||
[194)](#footnote-194)[194)](#footnoteref-194)
|
||
|
||
Equality comparison is a refinement
|
||
of partitioning if no two objects that
|
||
compare equal fall into different partitions[.](#footnote-194.sentence-1)
|
||
|
||
#### [23.2.8.2](#except) Exception safety guarantees [[unord.req.except]](unord.req.except)
|
||
|
||
[1](#except-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6009)
|
||
|
||
For unordered 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 Hash orPred object (if any)[.](#except-1.sentence-2)
|
||
|
||
[2](#except-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6017)
|
||
|
||
For unordered associative containers, if an exception is thrown by any
|
||
operation other than the container's hash function from within aninsert 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#L6023)
|
||
|
||
For unordered associative containers, no swap function throws
|
||
an exception unless that exception is thrown by the swap of the container'sHash or Pred object (if any)[.](#except-3.sentence-1)
|
||
|
||
[4](#except-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6028)
|
||
|
||
For unordered associative containers, if an exception is thrown
|
||
from within a rehash() function other than by the container's hash
|
||
function or comparison function, the rehash() function has no effect[.](#except-4.sentence-1)
|