<s>
In	O
computing	O
,	O
associative	B-Application
containers	I-Application
refer	O
to	O
a	O
group	O
of	O
class	O
templates	B-Application
in	O
the	O
standard	B-Language
library	I-Language
of	O
the	O
C++	B-Language
programming	I-Language
language	I-Language
that	O
implement	O
ordered	O
associative	B-Application
arrays	I-Application
.	O
</s>
<s>
Being	O
templates	B-Application
,	O
they	O
can	O
be	O
used	O
to	O
store	O
arbitrary	O
elements	O
,	O
such	O
as	O
integers	O
or	O
custom	O
classes	O
.	O
</s>
<s>
The	O
following	O
containers	B-Application
are	O
defined	O
in	O
the	O
current	O
revision	O
of	O
the	O
C++	B-Language
standard	O
:	O
set	O
,	O
map	O
,	O
multiset	B-Language
,	O
multimap	B-Language
.	O
</s>
<s>
Each	O
of	O
these	O
containers	B-Application
differ	O
only	O
on	O
constraints	O
placed	O
on	O
their	O
elements	O
.	O
</s>
<s>
The	O
associative	B-Application
containers	I-Application
are	O
similar	O
to	O
the	O
unordered	B-Language
associative	I-Language
containers	I-Language
in	O
C++	B-Language
standard	I-Language
library	I-Language
,	O
the	O
only	O
difference	O
is	O
that	O
the	O
unordered	B-Language
associative	I-Language
containers	I-Language
,	O
as	O
their	O
name	O
implies	O
,	O
do	O
not	O
order	O
their	O
elements	O
.	O
</s>
<s>
multimap	B-Language
and	O
multiset	B-Language
do	O
not	O
have	O
this	O
restriction	O
.	O
</s>
<s>
Element	O
composition	O
:	O
in	O
map	O
and	O
multimap	B-Language
each	O
element	O
is	O
composed	O
from	O
a	O
key	O
and	O
a	O
mapped	O
value	O
.	O
</s>
<s>
In	O
set	O
and	O
multiset	B-Language
each	O
element	O
is	O
key	O
;	O
there	O
are	O
no	O
mapped	O
values	O
.	O
</s>
<s>
Associative	B-Application
containers	I-Application
are	O
designed	O
to	O
be	O
especially	O
efficient	O
in	O
accessing	O
its	O
elements	O
by	O
their	O
key	O
,	O
as	O
opposed	O
to	O
sequence	O
containers	B-Application
which	O
are	O
more	O
efficient	O
in	O
accessing	O
elements	O
by	O
their	O
position	O
.	O
</s>
<s>
Associative	B-Application
containers	I-Application
are	O
guaranteed	O
to	O
perform	O
operations	O
of	O
insertion	O
,	O
deletion	O
,	O
and	O
testing	O
whether	O
an	O
element	O
is	O
in	O
it	O
,	O
in	O
logarithmic	O
time	O
–	O
O(log n )	O
.	O
</s>
<s>
As	O
such	O
,	O
they	O
are	O
typically	O
implemented	O
using	O
self-balancing	B-Data_Structure
binary	I-Data_Structure
search	I-Data_Structure
trees	I-Data_Structure
and	O
support	O
bidirectional	O
iteration	O
.	O
</s>
<s>
Iterators	O
and	O
references	O
are	O
not	O
invalidated	O
by	O
insert	O
and	O
erase	O
operations	O
,	O
except	O
for	O
iterators	O
and	O
references	O
to	O
erased	O
elements.The	O
defining	O
characteristic	O
of	O
associative	B-Application
containers	I-Application
is	O
that	O
elements	O
are	O
inserted	O
in	O
a	O
pre-defined	O
order	O
,	O
such	O
as	O
sorted	O
ascending	O
.	O
</s>
<s>
The	O
associative	B-Application
containers	I-Application
can	O
be	O
grouped	O
into	O
two	O
subsets	O
:	O
maps	O
and	O
sets	O
.	O
</s>
<s>
A	O
map	O
,	O
sometimes	O
referred	O
to	O
as	O
a	O
dictionary	B-Application
,	O
consists	O
of	O
a	O
key/value	O
pair	O
.	O
</s>
<s>
A	O
set	O
is	O
simply	O
an	O
ascending	O
container	B-Application
of	O
unique	O
elements	O
.	O
</s>
<s>
As	O
stated	O
earlier	O
,	O
map	O
and	O
set	O
only	O
allow	O
one	O
instance	O
of	O
a	O
key	O
or	O
element	O
to	O
be	O
inserted	O
into	O
the	O
container	B-Application
.	O
</s>
<s>
If	O
multiple	O
instances	O
of	O
elements	O
are	O
required	O
,	O
use	O
multimap	B-Language
or	O
multiset	B-Language
.	O
</s>
<s>
While	O
not	O
officially	O
part	O
of	O
the	O
STL	B-Application
standard	O
,	O
hash_map	O
and	O
hash_set	O
are	O
commonly	O
used	O
to	O
improve	O
searching	O
times	O
.	O
</s>
<s>
These	O
containers	B-Application
store	O
their	O
elements	O
as	O
a	O
hash	B-Algorithm
table	I-Algorithm
,	O
with	O
each	O
table	O
entry	O
containing	O
a	O
bidirectional	O
linked	B-Data_Structure
list	I-Data_Structure
of	O
elements	O
.	O
</s>
<s>
The	O
asymptotic	O
complexity	O
of	O
the	O
operations	O
that	O
can	O
be	O
applied	O
to	O
associative	B-Application
containers	I-Application
are	O
as	O
follows	O
:	O
</s>
<s>
The	O
containers	B-Application
are	O
defined	O
in	O
headers	O
named	O
after	O
the	O
names	O
of	O
the	O
containers	B-Application
,	O
e.g.	O
</s>
<s>
All	O
containers	B-Application
satisfy	O
the	O
requirements	O
of	O
the	O
concept	B-Application
,	O
which	O
means	O
they	O
have	O
begin( )	O
,	O
end( )	O
,	O
size( )	O
,	O
max_size( )	O
,	O
empty( )	O
,	O
and	O
swap( )	O
methods	O
.	O
</s>
<s>
set	O
map	O
multiset	B-Language
multimap	B-Language
Description	O
(	O
constructor	O
)	O
(	O
constructor	O
)	O
(	O
constructor	O
)	O
(	O
constructor	O
)	O
Constructs	O
the	O
container	B-Application
from	O
variety	O
of	O
sources	O
(	O
destructor	O
)	O
(	O
destructor	O
)	O
(	O
destructor	O
)	O
(	O
destructor	O
)	O
Destructs	O
the	O
set	O
and	O
the	O
contained	O
elements	O
operator	O
=	O
operator	O
=	O
operator	O
=	O
operator	O
=	O
Assigns	O
values	O
to	O
the	O
container	B-Application
get_allocator	O
get_allocator	O
get_allocator	O
get_allocator	O
Returns	O
the	O
allocator	O
used	O
to	O
allocate	O
memory	O
for	O
the	O
elements	O
Element	O
access	O
at	O
Accesses	O
specified	O
element	O
with	O
bounds	O
checking	O
.	O
</s>
<s>
Iterators	O
begin	O
begin	O
begin	O
begin	O
Returns	O
an	O
iterator	O
to	O
the	O
beginning	O
of	O
the	O
container	B-Application
end	O
end	O
end	O
end	O
Returns	O
an	O
iterator	O
to	O
the	O
end	O
of	O
the	O
container	B-Application
rbegin	O
rbegin	O
rbegin	O
rbegin	O
Returns	O
a	O
reverse	O
iterator	O
to	O
the	O
reverse	O
beginning	O
of	O
the	O
container	B-Application
rend	O
rend	O
rend	O
rend	O
Returns	O
a	O
reverse	O
iterator	O
to	O
the	O
reverse	O
end	O
of	O
the	O
container	B-Application
Capacity	O
empty	O
empty	O
empty	O
empty	O
Checks	O
whether	O
the	O
container	B-Application
is	O
empty	O
size	O
size	O
size	O
size	O
Returns	O
number	O
of	O
elements	O
in	O
the	O
container	B-Application
.	O
</s>
<s>
max_size	O
max_size	O
max_size	O
max_size	O
Returns	O
the	O
maximum	O
possible	O
number	O
of	O
elements	O
in	O
the	O
container	B-Application
Modifiers	O
clear	O
clear	O
clear	O
clear	O
Clears	O
the	O
contents	O
.	O
</s>
<s>
emplace	O
emplace	O
emplace	O
emplace	O
Constructs	O
elements	O
in-place	O
(	O
C++11	B-Language
)	O
emplace_hint	O
emplace_hint	O
emplace_hint	O
emplace_hint	O
Constructs	O
elements	O
in-place	O
using	O
a	O
hint	O
(	O
C++11	B-Language
)	O
erase	O
erase	O
erase	O
erase	O
Erases	O
elements	O
.	O
</s>
<s>
swap	O
swap	O
swap	O
swap	O
Swaps	O
the	O
contents	O
with	O
another	O
container	B-Application
.	O
</s>
<s>
In	O
set	O
and	O
multiset	B-Language
this	O
function	O
is	O
equivalent	O
to	O
key_comp	O
,	O
since	O
the	O
elements	O
are	O
composed	O
from	O
a	O
key	O
only	O
.	O
</s>
<s>
Example	O
shown	O
above	O
demonstrates	O
the	O
usage	O
of	O
some	O
of	O
the	O
functions	O
provided	O
by	O
map	O
,	O
such	O
as	O
insert( )	O
(	O
place	O
element	O
into	O
the	O
map	O
)	O
,	O
erase( )	O
(	O
remove	O
element	O
from	O
the	O
map	O
)	O
,	O
find( )	O
(	O
check	O
presence	O
of	O
the	O
element	O
in	O
the	O
container	B-Application
)	O
,	O
etc	O
.	O
</s>
<s>
Maps	O
may	O
use	O
iterators	O
to	O
point	O
to	O
specific	O
elements	O
in	O
the	O
container	B-Application
.	O
</s>
