<s>
In	O
computer	B-General_Concept
programming	I-General_Concept
,	O
a	O
collection	O
is	O
a	O
grouping	O
of	O
some	O
variable	O
number	O
of	O
data	O
items	O
(	O
possibly	O
zero	O
)	O
that	O
have	O
some	O
shared	O
significance	O
to	O
the	O
problem	O
being	O
solved	O
and	O
need	O
to	O
be	O
operated	O
upon	O
together	O
in	O
some	O
controlled	O
fashion	O
.	O
</s>
<s>
A	O
collection	O
is	O
a	O
concept	O
applicable	O
to	O
abstract	O
data	O
types	O
,	O
and	O
does	O
not	O
prescribe	O
a	O
specific	O
implementation	O
as	O
a	O
concrete	O
data	B-General_Concept
structure	I-General_Concept
,	O
though	O
often	O
there	O
is	O
a	O
conventional	O
choice	O
(	O
see	O
Container	B-Application
for	O
type	O
theory	O
discussion	O
)	O
.	O
</s>
<s>
Examples	O
of	O
collections	O
include	O
lists	O
,	O
sets	O
,	O
multisets	B-Application
,	O
trees	B-Application
and	O
graphs	B-Application
.	O
</s>
<s>
The	O
actual	O
data	B-General_Concept
structure	I-General_Concept
implementing	O
such	O
a	O
collection	O
need	O
not	O
be	O
linear	O
—	O
for	O
example	O
,	O
a	O
priority	B-Application
queue	I-Application
is	O
often	O
implemented	O
as	O
a	O
heap	B-Application
,	O
which	O
is	O
a	O
kind	O
of	O
tree	O
.	O
</s>
<s>
stacks	B-Application
;	O
</s>
<s>
queues	B-Application
;	O
</s>
<s>
priority	B-Application
queues	I-Application
;	O
</s>
<s>
double-ended	B-Application
queues	I-Application
;	O
</s>
<s>
double-ended	B-Application
priority	I-Application
queues	I-Application
.	O
</s>
<s>
If	O
the	O
principal	O
operations	O
on	O
the	O
list	O
are	O
to	O
be	O
the	O
addition	O
of	O
data	O
items	O
at	O
one	O
end	O
and	O
the	O
removal	O
of	O
data	O
items	O
at	O
the	O
other	O
,	O
it	O
will	O
generally	O
be	O
called	O
a	O
queue	B-Application
or	O
FIFO	B-Operating_System
.	O
</s>
<s>
If	O
the	O
principal	O
operations	O
are	O
the	O
addition	O
and	O
removal	O
of	O
data	O
items	O
at	O
just	O
one	O
end	O
,	O
it	O
will	O
be	O
called	O
a	O
stack	B-Application
or	O
LIFO	B-Application
.	O
</s>
<s>
A	O
stack	B-Application
is	O
a	O
LIFO	B-Application
data	B-General_Concept
structure	I-General_Concept
with	O
two	O
principal	O
operations	O
:	O
push	O
,	O
which	O
adds	O
an	O
element	O
to	O
the	O
"	O
top	O
"	O
of	O
the	O
collection	O
,	O
and	O
pop	O
,	O
which	O
removes	O
the	O
top	O
element	O
.	O
</s>
<s>
In	O
a	O
priority	B-Application
queue	I-Application
,	O
the	O
tracks	O
of	O
the	O
minimum	O
or	O
maximum	O
data	O
item	O
in	O
the	O
collection	O
are	O
kept	O
,	O
according	O
to	O
some	O
ordering	O
criterion	O
,	O
and	O
the	O
order	O
of	O
the	O
other	O
data	O
items	O
does	O
not	O
matter	O
.	O
</s>
<s>
One	O
may	O
think	O
of	O
a	O
priority	B-Application
queue	I-Application
as	O
a	O
list	O
that	O
always	O
keeps	O
the	O
minimum	O
or	O
maximum	O
at	O
the	O
head	O
,	O
while	O
the	O
remaining	O
elements	O
are	O
kept	O
in	O
a	O
bag	O
.	O
</s>
<s>
multisets	B-Application
;	O
</s>
<s>
associative	B-Application
arrays	I-Application
.	O
</s>
<s>
A	O
set	O
can	O
be	O
interpreted	O
as	O
a	O
specialized	O
multiset	B-Application
,	O
which	O
in	O
turn	O
is	O
a	O
specialized	O
associative	B-Application
array	I-Application
,	O
in	O
each	O
case	O
by	O
limiting	O
the	O
possible	O
values	O
—	O
considering	O
a	O
set	O
as	O
represented	O
by	O
its	O
indicator	O
function	O
.	O
</s>
<s>
In	O
others	O
,	O
sets	O
can	O
be	O
implemented	O
by	O
a	O
hash	B-Algorithm
table	I-Algorithm
with	O
dummy	O
values	O
;	O
only	O
the	O
keys	O
are	O
used	O
in	O
representing	O
the	O
set	O
.	O
</s>
<s>
In	O
a	O
multiset	B-Application
(	O
or	O
bag	O
)	O
,	O
like	O
in	O
a	O
set	O
,	O
the	O
order	O
of	O
data	O
items	O
does	O
not	O
matter	O
,	O
but	O
in	O
this	O
case	O
duplicate	O
data	O
items	O
are	O
permitted	O
.	O
</s>
<s>
Examples	O
of	O
operations	O
on	O
multisets	B-Application
are	O
the	O
addition	O
and	O
removal	O
of	O
data	O
items	O
and	O
determining	O
how	O
many	O
duplicates	O
of	O
a	O
particular	O
data	O
item	O
are	O
present	O
in	O
the	O
multiset	B-Application
.	O
</s>
<s>
Multisets	B-Application
can	O
be	O
transformed	O
into	O
lists	O
by	O
the	O
action	O
of	O
sorting	O
.	O
</s>
<s>
In	O
an	O
associative	B-Application
array	I-Application
(	O
or	O
map	O
,	O
dictionary	B-Application
,	O
lookup	O
table	O
)	O
,	O
like	O
in	O
a	O
dictionary	B-Application
,	O
a	O
lookup	O
on	O
a	O
key	O
(	O
like	O
a	O
word	O
)	O
provides	O
a	O
value	O
(	O
like	O
a	O
definition	O
)	O
.	O
</s>
<s>
The	O
value	O
might	O
be	O
a	O
reference	O
to	O
a	O
compound	O
data	B-General_Concept
structure	I-General_Concept
.	O
</s>
<s>
A	O
hash	B-Algorithm
table	I-Algorithm
is	O
usually	O
an	O
efficient	O
implementation	O
,	O
and	O
thus	O
this	O
data	O
type	O
is	O
often	O
known	O
as	O
a	O
"	O
hash	O
"	O
.	O
</s>
<s>
In	O
a	O
graph	O
,	O
data	O
items	O
have	O
associations	O
with	O
one	O
or	O
more	O
other	O
data	O
items	O
in	O
the	O
collection	O
and	O
are	O
somewhat	O
like	O
trees	B-Application
without	O
the	O
concept	O
of	O
a	O
root	O
or	O
a	O
parent-child	O
relationship	O
so	O
that	O
all	O
data	O
items	O
are	O
peers	O
.	O
</s>
<s>
Examples	O
of	O
operations	O
on	O
graphs	B-Application
are	O
traversals	O
and	O
searches	O
which	O
explore	O
the	O
associations	O
of	O
data	O
items	O
looking	O
for	O
some	O
specific	O
property	O
.	O
</s>
<s>
Graphs	B-Application
are	O
frequently	O
used	O
to	O
model	O
real-world	O
situations	O
and	O
to	O
solve	O
related	O
problems	O
.	O
</s>
<s>
An	O
example	O
is	O
the	O
Spanning	B-Protocol
tree	I-Protocol
protocol	I-Protocol
,	O
which	O
creates	O
a	O
graph	O
(	O
or	O
mesh	O
)	O
representation	O
of	O
a	O
data	O
network	O
and	O
figures	O
out	O
which	O
associations	O
between	O
switching	O
nodes	O
need	O
to	O
be	O
broken	O
to	O
turn	O
it	O
into	O
a	O
tree	O
and	O
thus	O
prevent	O
data	O
going	O
around	O
in	O
loops	O
.	O
</s>
<s>
Examples	O
of	O
operations	O
on	O
trees	B-Application
are	O
the	O
addition	O
of	O
data	O
items	O
so	O
as	O
to	O
maintain	O
a	O
specific	O
property	O
of	O
the	O
tree	O
to	O
perform	O
sorting	O
,	O
etc	O
.	O
</s>
<s>
Specialized	O
trees	B-Application
are	O
used	O
in	O
various	O
algorithms	O
.	O
</s>
<s>
For	O
example	O
,	O
the	O
heap	B-Application
sort	I-Application
uses	O
a	O
kind	O
of	O
tree	O
called	O
a	O
heap	B-Application
.	O
</s>
<s>
Assertions	O
that	O
collections	O
like	O
lists	O
,	O
sets	O
,	O
trees	B-Application
,	O
etc	O
.	O
</s>
<s>
are	O
data	B-General_Concept
structures	I-General_Concept
,	O
abstract	O
data	O
types	O
or	O
classes	O
must	O
be	O
read	O
with	O
this	O
in	O
mind	O
.	O
</s>
<s>
For	O
example	O
,	O
a	O
priority	B-Application
queue	I-Application
is	O
often	O
implemented	O
as	O
a	O
heap	B-Application
,	O
while	O
an	O
associative	B-Application
array	I-Application
is	O
often	O
implemented	O
as	O
a	O
hash	B-Algorithm
table	I-Algorithm
,	O
so	O
these	O
abstract	O
types	O
are	O
often	O
referred	O
to	O
by	O
this	O
preferred	O
implementation	O
,	O
as	O
a	O
"	O
heap	B-Application
"	O
or	O
a	O
"	O
hash	O
"	O
,	O
though	O
this	O
is	O
not	O
strictly	O
correct	O
.	O
</s>
<s>
Some	O
collections	O
may	O
be	O
primitive	O
data	O
types	O
in	O
a	O
language	O
,	O
such	O
as	O
lists	O
,	O
while	O
more	O
complex	O
collections	O
are	O
implemented	O
as	O
composite	O
data	O
types	O
in	O
libraries	O
,	O
sometimes	O
in	O
the	O
standard	B-Library
library	I-Library
.	O
</s>
