1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
4 <title>Overview</title>
5 <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
6 <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
8 <body bgcolor = "white">
14 The <a href = "introduction.html">Introduction</a> Section described some challenges
15 in designing associative containers. This section describes the <tt>pb_assoc</tt>'s solution.
21 <a href = "#cd">Class hierarchy</a>
22 shows a class diagram of <tt>pb_assoc's associative containers.</tt>
23 Associative container classes subclass other associative container classes such that
24 base classes capture common types and methods
25 [<a href = "references.html#stroustrup97cpp">stroustrup97cpp</a>]. The type <tt>hash_fn</tt> is defined in <a href = "basic_hash_assoc_cntnr.html"><tt>basic_hash_assoc_cntnr</tt></a>, for example, since all hash-based containers employ a hash function;
26 <a href = "cc_hash_assoc_cntnr.html"><tt>cc_hash_assoc_cntnr</tt></a>
28 <a href = "gp_hash_assoc_cntnr.html"><tt>gp_hash_assoc_cntnr</tt></a>,
29 subclasses encapsulating a collision-chaining and (general) probing hash table, respectively, each define other types specific for their underlying data-structure.
30 This is described further in
31 <a href = "ds_gen.html">Data-Structure Genericity</a>.
36 <img src = "cd.jpg" width = "70%" alt = "no image">
44 It is sometimes useful to know the underlying data-structure.
45 Associative containers internally define <tt>ds_category</tt> as a class describing this. Two classes might be different instantiations
47 <a href = "tree_assoc_cntnr.html"><tt>tree_assoc_cntnr</tt></a>, but one might be based on a red-black tree while another might be based on a splay tree. (This might affect the way tree objects should be manipulated.) <tt><b>typename</b> Cntnr::ds_category</tt>
48 yields a "tag" class for the underlying data-structure of some type
50 This is described further in
51 <a href = "ds_gen.html">Data-Structure Genericity</a>.
55 When manipulating generic containers, it is useful to know which types, methods, and guarantees they support. For example, tree-based containers can support split and join operations, while containers based on most other underlying data-structures cannot.
56 These questions can be answered in compile time through a traits mechanism.
57 <a href = "ds_traits.html"><tt>ds_traits</tt><Cntnr>::split_join</a>, for example, answers the above question.
58 This is described further in
59 <a href = "ds_gen.html">Data-Structure Genericity</a>;
60 <a href = "../example/ds_traits_example.cpp"><tt>ds_traits_example.cpp</tt></a>-
65 <tt>pb_assoc</tt> does not contain separate containers for different mapping semantics,
66 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.
70 Instantiating a container's <tt>Data</tt> parameter by all but two distingished types, will make a "map". Thus
72 <a href = "cc_hash_assoc_cntnr.html">cc_hash_assoc_cntnr</a><
75 </pre> is a type mapping each <tt><b>int</b></tt> value to a <tt><b>char</b></tt>
77 <a href = "../example/basic_map_example.cpp"><tt>basic_map_example.cpp</tt></a>
81 Instantiating a container's <tt>Data</tt> parameter by <a href = "null_data_type.html"><tt>null_data_type</tt></a> will make a "set". Thus
83 <a href = "cc_hash_assoc_cntnr.html">cc_hash_assoc_cntnr</a><
85 <a href = "null_data_type.html">null_data_type</a>>
87 is a type storing unique <tt><b>int</b></tt> values.
88 <a href = "../example/basic_set_example.cpp"><tt>basic_set_example.cpp</tt></a> shows an example.
91 Instantiating a container's <tt>Data</tt> parameter by <a href = "compound_data_type.html"><tt>compound_data_type</tt></a><tt><Cntnr></tt>, where <tt>Cntnr</tt> is a different associative container, will make a "(multi)+map". Thus
93 <a href = "cc_hash_assoc_cntnr.html">cc_hash_assoc_cntnr</a><
95 <a href = "compound_data_type.html">compound_data_type</a><
96 <a href = "cc_hash_assoc_cntnr.html">cc_hash_assoc_cntnr</a><
98 <a href = "null_data_type.html">null_data_type</a>> > >
101 mapping each <tt><b>int</b></tt> value to a "set" of <tt><b>char</b></tt>
103 <a href = "../example/basic_multimap_example.cpp"><tt>basic_multimap_example.cpp</tt></a> shows an example.
104 This composition is recursive, however, and more complex relationships can be built.
105 <a href = "../example/mapping_level_example.cpp"><tt>mapping_level_example.cpp</tt></a> shows an example.
110 The associative-container classes derive each from one of the three
111 <a href = "basic_assoc_cntnr.html"><tt>basic_assoc_cntnr</tt></a> classes, depending
112 on the data policy. These three base classes define different types and methods. For example, the "map" specialization of
113 <a href = "basic_assoc_cntnr.html"><tt>basic_assoc_cntnr</tt></a>
114 defines <tt><b>operator</b>[]</tt>, wherase the "set" specialization does not.
115 This is described further in
116 <a href = "ms_gen.html">Mapping-Semantic Genericity</a>.
120 <tt>pb_assoc</tt>'s design contains the concept of a <i>mapping level</i>. "Map" and "set" types have a single mapping level; A container
121 mapping integers to "maps" mapping characters to floats has two mapping levels, since it can be viewed as a type mapping each integer to a "map", or as a type mapping each pair of integer and character to a float. <tt>pb_assoc</tt> contains traits and rebind mechanisms for querying and altering the mapping levels.
122 This is described further in
123 <a href = "ms_gen.html">Mapping-Semantic Genericity</a>.
127 The leaf classes in Figure
128 <a href = "#cd">Class hierarchy</a>
129 are each parameterized by policies, easing configuring containers for different settings.
130 <a href = "hash_based_containers.html">Hash-Based Containers</a> describes the design and policies of hash-based containers,
131 <a href = "tree_based_containers.html">Tree-Based Containers</a> describes the design and policies of tree-based containers, and
132 <a href = "lu_based_containers.html">List-Based Containers</a> describes the design and policies of list-based containers with update policies.