aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/docs/html/ext/pb_assoc/tutorial.html
blob: b5dd0f512655cbb02ff8f3cbe39ddda1c6b27ddc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Short Tutorial</TITLE>
<META NAME="Generator" content="Microsoft Visual Studio .NET 7.1">
<base target = "content">
</HEAD>
<BODY>
<H1>Short Tutorial</H1>

<p>
    Following is a short tutorial introducing the main points of <tt>pb_assoc</tt>. It
is organized as follows.</p>
<ol>
    <li><a href = "#general_use">Basic Use of Maps</a></li>
</ol>







<h2><a name = "general_use">Basic Use of Maps</a></h2>

<p>
    For the greater part, using <tt>pb_assoc</tt>'s maps is similar
to using those of the STL. For example, the following shows a collision-chaining container mapping integers to characters.

<pre>
<a href = "cc_hash_assoc_cntnr.html">cc_hash_assoc_cntnr</a>&lt;<b>int</b>, <b>char</b>&gt; c;

c[2] = 'b';

assert(c.find(1) == c.end());
</pre>

<p>
	<a href="interface.html#containers">Inteface::Containers</a> describes the containers supported. <a href = "../example/basic_map_example.cpp"><tt>basic_map_example.cpp</tt></a>
shows an example.
</p>


<h2><a name = "ms">Other Mapping Semantics</a></h2>

<p>
	<tt>pb_assoc</tt>	does not contain separate containers for different mapping semantics,
as the STL does (<i>e.g.</i>, <tt>std::map</tt> and <tt>std::multimap</tt>). Rather, containers are parameterized by a <tt>Data</tt> parameter, and this parameter is a policy for the mapping semantics.
</p>

<p>
	Instantiating the <tt>Data</tt> parameter by
<a href = "null_data_type.html"><tt>null_data_type</tt></a>
makes a &quot;set&quot;. For example, the following shows a collision-chaining container storing integers.

<pre>
<a href = "cc_hash_assoc_cntnr.html">cc_hash_assoc_cntnr</a>&lt;<b>int</b>, <a href = "null_data_type.html">null_data_type</a>&gt; c;

c.insert(2);

assert(c.find(1) == c.end());
</pre>
</p>

</BODY>
</HTML>