google_hash 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +21 -0
- data/Rakefile +11 -0
- data/VERSION +1 -0
- data/ext/extconf.rb +15 -0
- data/ext/go.cpp +109 -0
- data/ext/sparsehash-1.5.2/AUTHORS +2 -0
- data/ext/sparsehash-1.5.2/COPYING +28 -0
- data/ext/sparsehash-1.5.2/ChangeLog +167 -0
- data/ext/sparsehash-1.5.2/INSTALL +236 -0
- data/ext/sparsehash-1.5.2/Makefile.am +157 -0
- data/ext/sparsehash-1.5.2/Makefile.in +1019 -0
- data/ext/sparsehash-1.5.2/NEWS +0 -0
- data/ext/sparsehash-1.5.2/README +149 -0
- data/ext/sparsehash-1.5.2/README.windows +25 -0
- data/ext/sparsehash-1.5.2/TODO +28 -0
- data/ext/sparsehash-1.5.2/aclocal.m4 +868 -0
- data/ext/sparsehash-1.5.2/compile +99 -0
- data/ext/sparsehash-1.5.2/config.guess +1516 -0
- data/ext/sparsehash-1.5.2/config.sub +1626 -0
- data/ext/sparsehash-1.5.2/configure +8054 -0
- data/ext/sparsehash-1.5.2/configure.ac +74 -0
- data/ext/sparsehash-1.5.2/depcomp +530 -0
- data/ext/sparsehash-1.5.2/doc/dense_hash_map.html +1591 -0
- data/ext/sparsehash-1.5.2/doc/dense_hash_set.html +1445 -0
- data/ext/sparsehash-1.5.2/doc/designstyle.css +115 -0
- data/ext/sparsehash-1.5.2/doc/implementation.html +365 -0
- data/ext/sparsehash-1.5.2/doc/index.html +69 -0
- data/ext/sparsehash-1.5.2/doc/performance.html +96 -0
- data/ext/sparsehash-1.5.2/doc/sparse_hash_map.html +1527 -0
- data/ext/sparsehash-1.5.2/doc/sparse_hash_set.html +1376 -0
- data/ext/sparsehash-1.5.2/doc/sparsetable.html +1393 -0
- data/ext/sparsehash-1.5.2/experimental/Makefile +9 -0
- data/ext/sparsehash-1.5.2/experimental/README +14 -0
- data/ext/sparsehash-1.5.2/experimental/example.c +54 -0
- data/ext/sparsehash-1.5.2/experimental/libchash.c +1537 -0
- data/ext/sparsehash-1.5.2/experimental/libchash.h +252 -0
- data/ext/sparsehash-1.5.2/google-sparsehash.sln +47 -0
- data/ext/sparsehash-1.5.2/install-sh +323 -0
- data/ext/sparsehash-1.5.2/m4/acx_pthread.m4 +363 -0
- data/ext/sparsehash-1.5.2/m4/google_namespace.m4 +42 -0
- data/ext/sparsehash-1.5.2/m4/namespaces.m4 +15 -0
- data/ext/sparsehash-1.5.2/m4/stl_hash.m4 +70 -0
- data/ext/sparsehash-1.5.2/m4/stl_hash_fun.m4 +36 -0
- data/ext/sparsehash-1.5.2/m4/stl_namespace.m4 +25 -0
- data/ext/sparsehash-1.5.2/missing +360 -0
- data/ext/sparsehash-1.5.2/mkinstalldirs +158 -0
- data/ext/sparsehash-1.5.2/packages/deb.sh +74 -0
- data/ext/sparsehash-1.5.2/packages/deb/README +7 -0
- data/ext/sparsehash-1.5.2/packages/deb/changelog +107 -0
- data/ext/sparsehash-1.5.2/packages/deb/compat +1 -0
- data/ext/sparsehash-1.5.2/packages/deb/control +17 -0
- data/ext/sparsehash-1.5.2/packages/deb/copyright +35 -0
- data/ext/sparsehash-1.5.2/packages/deb/docs +16 -0
- data/ext/sparsehash-1.5.2/packages/deb/rules +117 -0
- data/ext/sparsehash-1.5.2/packages/deb/sparsehash.dirs +2 -0
- data/ext/sparsehash-1.5.2/packages/deb/sparsehash.install +2 -0
- data/ext/sparsehash-1.5.2/packages/rpm.sh +86 -0
- data/ext/sparsehash-1.5.2/packages/rpm/rpm.spec +61 -0
- data/ext/sparsehash-1.5.2/src/config.h.in +131 -0
- data/ext/sparsehash-1.5.2/src/config.h.include +23 -0
- data/ext/sparsehash-1.5.2/src/google/dense_hash_map +310 -0
- data/ext/sparsehash-1.5.2/src/google/dense_hash_set +287 -0
- data/ext/sparsehash-1.5.2/src/google/sparse_hash_map +294 -0
- data/ext/sparsehash-1.5.2/src/google/sparse_hash_set +275 -0
- data/ext/sparsehash-1.5.2/src/google/sparsehash/densehashtable.h +1062 -0
- data/ext/sparsehash-1.5.2/src/google/sparsehash/sparsehashtable.h +1015 -0
- data/ext/sparsehash-1.5.2/src/google/sparsetable +1468 -0
- data/ext/sparsehash-1.5.2/src/google/type_traits.h +250 -0
- data/ext/sparsehash-1.5.2/src/hashtable_unittest.cc +1375 -0
- data/ext/sparsehash-1.5.2/src/simple_test.cc +103 -0
- data/ext/sparsehash-1.5.2/src/sparsetable_unittest.cc +696 -0
- data/ext/sparsehash-1.5.2/src/time_hash_map.cc +488 -0
- data/ext/sparsehash-1.5.2/src/type_traits_unittest.cc +492 -0
- data/ext/sparsehash-1.5.2/src/windows/config.h +149 -0
- data/ext/sparsehash-1.5.2/src/windows/google/sparsehash/sparseconfig.h +32 -0
- data/ext/sparsehash-1.5.2/src/windows/port.cc +63 -0
- data/ext/sparsehash-1.5.2/src/windows/port.h +81 -0
- data/ext/sparsehash-1.5.2/src/words +8944 -0
- data/ext/sparsehash-1.5.2/vsprojects/hashtable_unittest/hashtable_unittest.vcproj +187 -0
- data/ext/sparsehash-1.5.2/vsprojects/sparsetable_unittest/sparsetable_unittest.vcproj +172 -0
- data/ext/sparsehash-1.5.2/vsprojects/time_hash_map/time_hash_map.vcproj +187 -0
- data/ext/sparsehash-1.5.2/vsprojects/type_traits_unittest/type_traits_unittest.vcproj +169 -0
- data/ext/test.rb +10 -0
- data/test/spec.go +70 -0
- metadata +147 -0
@@ -0,0 +1,69 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Google Sparsehash Package</title>
|
5
|
+
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
7
|
+
<link href="http://www.google.com/favicon.ico" type="image/x-icon"
|
8
|
+
rel="shortcut icon">
|
9
|
+
<link href="designstyle.css" type="text/css" rel="stylesheet">
|
10
|
+
<style>
|
11
|
+
<!--
|
12
|
+
ol.bluelist li {
|
13
|
+
color: #3366ff;
|
14
|
+
font-family: sans-serif;
|
15
|
+
}
|
16
|
+
ol.bluelist li p {
|
17
|
+
color: #000;
|
18
|
+
font-family: "Times Roman", times, serif;
|
19
|
+
}
|
20
|
+
ul.blacklist li {
|
21
|
+
color: #000;
|
22
|
+
font-family: "Times Roman", times, serif;
|
23
|
+
}
|
24
|
+
//-->
|
25
|
+
</style>
|
26
|
+
</head>
|
27
|
+
<body>
|
28
|
+
|
29
|
+
<h1> <a name="Google_Sparsehash_Package"></a>Google Sparsehash Package </h1>
|
30
|
+
<br>
|
31
|
+
|
32
|
+
<p>The Google sparsehash package consists of two hashtable
|
33
|
+
implementations: <i>sparse</i>, which is designed to be very space
|
34
|
+
efficient, and <i>dense</i>, which is designed to be very time
|
35
|
+
efficient. For each one, the package provides both a hash-map and a
|
36
|
+
hash-set, to mirror the classes in the common STL implementation.</p>
|
37
|
+
|
38
|
+
<p>Documentation on how to use these classes:</p>
|
39
|
+
<ul>
|
40
|
+
<li> <A HREF="sparse_hash_map.html">sparse_hash_map</A>
|
41
|
+
<li> <A HREF="sparse_hash_set.html">sparse_hash_set</A>
|
42
|
+
<li> <A HREF="dense_hash_map.html">dense_hash_map</A>
|
43
|
+
<li> <A HREF="dense_hash_set.html">dense_hash_set</A>
|
44
|
+
</ul>
|
45
|
+
|
46
|
+
<p>In addition to the hash-map (and hash-set) classes, there's also a
|
47
|
+
lower-level class that implements a "sparse" array. This class can be
|
48
|
+
useful in its own right; consider using it when you'd normally use a
|
49
|
+
<code>sparse_hash_map</code>, but your keys are all small-ish
|
50
|
+
integers.</p>
|
51
|
+
<ul>
|
52
|
+
<li> <A HREF="sparsetable.html">sparsetable</A>
|
53
|
+
</ul>
|
54
|
+
|
55
|
+
<p>There is also a doc explaining the <A
|
56
|
+
HREF="implementation.html">implementation details</A> of these
|
57
|
+
classes, for those who are curious. And finally, you can see some
|
58
|
+
<A HREF="performance.html">performance comparisons</A>, both between
|
59
|
+
the various classes here, but also between these implementations and
|
60
|
+
other standard hashtable implementations.</p>
|
61
|
+
|
62
|
+
<hr>
|
63
|
+
<address>
|
64
|
+
Craig Silverstein<br>
|
65
|
+
Last modified: Thu Jan 25 17:58:02 PST 2007
|
66
|
+
</address>
|
67
|
+
|
68
|
+
</body>
|
69
|
+
</html>
|
@@ -0,0 +1,96 @@
|
|
1
|
+
<HTML>
|
2
|
+
|
3
|
+
<HEAD>
|
4
|
+
<title>Performance notes: sparse_hash, dense_hash, sparsetable</title>
|
5
|
+
</HEAD>
|
6
|
+
|
7
|
+
<BODY>
|
8
|
+
|
9
|
+
<H2>Performance Numbers</H2>
|
10
|
+
|
11
|
+
<p>Here are some performance numbers from an example desktop machine,
|
12
|
+
taken from a version of time_hash_map that was instrumented to also
|
13
|
+
report memory allocation information (this modification is not
|
14
|
+
included by default because it required a big hack to do, including
|
15
|
+
modifying the STL code to not try to do its own freelist management).</p>
|
16
|
+
|
17
|
+
<p>Note there are lots of caveats on these numbers: they may differ from
|
18
|
+
machine to machine and compiler to compiler, and they only test a very
|
19
|
+
particular usage pattern that may not match how you use hashtables --
|
20
|
+
for instance, they test hashtables with very small keys. However,
|
21
|
+
they're still useful for a baseline comparison of the various
|
22
|
+
hashtable implementations.</p>
|
23
|
+
|
24
|
+
<p>These figures are from a 2.80GHz Pentium 4 with 2G of memory. The
|
25
|
+
'standard' hash_map and map implementations are the SGI STL code
|
26
|
+
included with <tt>gcc2</tt>. Compiled with <tt>gcc2.95.3 -g
|
27
|
+
-O2</tt></p>
|
28
|
+
|
29
|
+
<pre>
|
30
|
+
======
|
31
|
+
Average over 10000000 iterations
|
32
|
+
Wed Dec 8 14:56:38 PST 2004
|
33
|
+
|
34
|
+
SPARSE_HASH_MAP:
|
35
|
+
map_grow 665 ns
|
36
|
+
map_predict/grow 303 ns
|
37
|
+
map_replace 177 ns
|
38
|
+
map_fetch 117 ns
|
39
|
+
map_remove 192 ns
|
40
|
+
memory used in map_grow 84.3956 Mbytes
|
41
|
+
|
42
|
+
DENSE_HASH_MAP:
|
43
|
+
map_grow 84 ns
|
44
|
+
map_predict/grow 22 ns
|
45
|
+
map_replace 18 ns
|
46
|
+
map_fetch 13 ns
|
47
|
+
map_remove 23 ns
|
48
|
+
memory used in map_grow 256.0000 Mbytes
|
49
|
+
|
50
|
+
STANDARD HASH_MAP:
|
51
|
+
map_grow 162 ns
|
52
|
+
map_predict/grow 107 ns
|
53
|
+
map_replace 44 ns
|
54
|
+
map_fetch 22 ns
|
55
|
+
map_remove 124 ns
|
56
|
+
memory used in map_grow 204.1643 Mbytes
|
57
|
+
|
58
|
+
STANDARD MAP:
|
59
|
+
map_grow 297 ns
|
60
|
+
map_predict/grow 282 ns
|
61
|
+
map_replace 113 ns
|
62
|
+
map_fetch 113 ns
|
63
|
+
map_remove 238 ns
|
64
|
+
memory used in map_grow 236.8081 Mbytes
|
65
|
+
</pre>
|
66
|
+
|
67
|
+
|
68
|
+
<H2><A name="hashfn">A Note on Hash Functions</A></H2>
|
69
|
+
|
70
|
+
<p>For good performance, the Google hash routines depend on a good
|
71
|
+
hash function: one that distributes data evenly. Many hashtable
|
72
|
+
implementations come with sub-optimal hash functions that can degrade
|
73
|
+
performance. For instance, the hash function given in Knuth's _Art of
|
74
|
+
Computer Programming_, and the default string hash function in SGI's
|
75
|
+
STL implementation, both distribute certain data sets unevenly,
|
76
|
+
leading to poor performance.</p>
|
77
|
+
|
78
|
+
<p>As an example, in one test of the default SGI STL string hash
|
79
|
+
function against the Hsieh hash function (see below), for a particular
|
80
|
+
set of string keys, the Hsieh function resulted in hashtable lookups
|
81
|
+
that were 20 times as fast as the STLPort hash function. The string
|
82
|
+
keys were chosen to be "hard" to hash well, so these results may not
|
83
|
+
be typical, but they are suggestive.</p>
|
84
|
+
|
85
|
+
<p>There has been much research over the years into good hash
|
86
|
+
functions. Here are some hash functions of note.</p>
|
87
|
+
|
88
|
+
<ul>
|
89
|
+
<li> Bob Jenkins: <A HREF="http://burtleburtle.net/bob/hash/">http://burtleburtle.net/bob/hash/</A>
|
90
|
+
<li> Paul Hsieh: <A HREF="http://www.azillionmonkeys.com/qed/hash.html">http://www.azillionmonkeys.com/qed/hash.html</A>
|
91
|
+
<li> Fowler/Noll/Vo (FNV): <A HREF="http://www.isthe.com/chongo/tech/comp/fnv/">http://www.isthe.com/chongo/tech/comp/fnv/</A>
|
92
|
+
<li> MurmurHash: <A HREF="http://murmurhash.googlepages.com/">http://murmurhash.googlepages.com/</A>
|
93
|
+
</ul>
|
94
|
+
|
95
|
+
</body>
|
96
|
+
</html>
|
@@ -0,0 +1,1527 @@
|
|
1
|
+
<HTML>
|
2
|
+
<!-- The API of this class and the documentation -- but not the
|
3
|
+
implementation! -- are based on that for SGI's hash_map class,
|
4
|
+
augmented with tr1 support.
|
5
|
+
-->
|
6
|
+
<!--
|
7
|
+
-- Copyright (c) 1996-1999
|
8
|
+
-- Silicon Graphics Computer Systems, Inc.
|
9
|
+
--
|
10
|
+
-- Permission to use, copy, modify, distribute and sell this software
|
11
|
+
-- and its documentation for any purpose is hereby granted without fee,
|
12
|
+
-- provided that the above copyright notice appears in all copies and
|
13
|
+
-- that both that copyright notice and this permission notice appear
|
14
|
+
-- in supporting documentation. Silicon Graphics makes no
|
15
|
+
-- representations about the suitability of this software for any
|
16
|
+
-- purpose. It is provided "as is" without express or implied warranty.
|
17
|
+
--
|
18
|
+
-- Copyright (c) 1994
|
19
|
+
-- Hewlett-Packard Company
|
20
|
+
--
|
21
|
+
-- Permission to use, copy, modify, distribute and sell this software
|
22
|
+
-- and its documentation for any purpose is hereby granted without fee,
|
23
|
+
-- provided that the above copyright notice appears in all copies and
|
24
|
+
-- that both that copyright notice and this permission notice appear
|
25
|
+
-- in supporting documentation. Hewlett-Packard Company makes no
|
26
|
+
-- representations about the suitability of this software for any
|
27
|
+
-- purpose. It is provided "as is" without express or implied warranty.
|
28
|
+
--
|
29
|
+
-->
|
30
|
+
|
31
|
+
<HEAD>
|
32
|
+
<Title>sparse_hash_map<Key, Data, HashFcn, EqualKey, Alloc></Title>
|
33
|
+
</HEAD>
|
34
|
+
|
35
|
+
<BODY>
|
36
|
+
|
37
|
+
<p><i>[Note: this document is formatted similarly to the SGI STL
|
38
|
+
implementation documentation pages, and refers to concepts and classes
|
39
|
+
defined there. However, neither this document nor the code it
|
40
|
+
describes is associated with SGI, nor is it necessary to have SGI's
|
41
|
+
STL implementation installed in order to use this class.]</i></p>
|
42
|
+
|
43
|
+
|
44
|
+
<H1>sparse_hash_map<Key, Data, HashFcn, EqualKey, Alloc></H1>
|
45
|
+
|
46
|
+
<p><tt>sparse_hash_map</tt> is a <A
|
47
|
+
href="http://www.sgi.com/tech/stl/HashedAssociativeContainer.html">Hashed
|
48
|
+
Associative Container</A> that associates objects of type <tt>Key</tt>
|
49
|
+
with objects of type <tt>Data</tt>. <tt>sparse_hash_map</tt> is a <A
|
50
|
+
href="http://www.sgi.com/tech/stl/PairAssociativeContainer.html">Pair
|
51
|
+
Associative Container</A>, meaning that its value type is <tt><A
|
52
|
+
href="pair.html">pair</A><const Key, Data></tt>. It is also a
|
53
|
+
<A
|
54
|
+
href="http://www.sgi.com/tech/stl/UniqueAssociativeContainer.html">Unique
|
55
|
+
Associative Container</A>, meaning that no two elements have keys that
|
56
|
+
compare equal using <tt>EqualKey</tt>.</p>
|
57
|
+
|
58
|
+
<p>Looking up an element in a <tt>sparse_hash_map</tt> by its key is
|
59
|
+
efficient, so <tt>sparse_hash_map</tt> is useful for "dictionaries"
|
60
|
+
where the order of elements is irrelevant. If it is important for the
|
61
|
+
elements to be in a particular order, however, then <tt><A
|
62
|
+
href="http://www.sgi.com/tech/stl/Map.html">map</A></tt> is more appropriate.</p>
|
63
|
+
|
64
|
+
<p><tt>sparse_hash_map</tt> is distinguished from other hash-map
|
65
|
+
implementations by its stingy use of memory and by the ability to save
|
66
|
+
and restore contents to disk. On the other hand, this hash-map
|
67
|
+
implementation, while still efficient, is slower than other hash-map
|
68
|
+
implementations, and it also has requirements -- for instance, for a
|
69
|
+
distinguished "deleted key" -- that may not be easy for all
|
70
|
+
applications to satisfy.</p>
|
71
|
+
|
72
|
+
<p>This class is appropriate for applications that need to store
|
73
|
+
large "dictionaries" in memory, or for applications that need these
|
74
|
+
dictionaries to be persistent.</p>
|
75
|
+
|
76
|
+
|
77
|
+
<h3>Example</h3>
|
78
|
+
|
79
|
+
(Note: this example uses SGI semantics for <code>hash<></code>
|
80
|
+
-- the kind used by gcc and most Unix compiler suites -- and not
|
81
|
+
Dinkumware semantics -- the kind used by Microsoft Visual Studio. If
|
82
|
+
you are using MSVC, this example will not compile as-is: you'll need
|
83
|
+
to change <code>hash</code> to <code>hash_compare</code>, and you
|
84
|
+
won't use <code>eqstr</code> at all. See the MSVC documentation for
|
85
|
+
<code>hash_map</code> and <code>hash_compare</code>, for more
|
86
|
+
details.)
|
87
|
+
|
88
|
+
<pre>
|
89
|
+
#include <iostream>
|
90
|
+
#include <google/sparse_hash_map>
|
91
|
+
|
92
|
+
using google::sparse_hash_map; // namespace where class lives by default
|
93
|
+
using std::cout;
|
94
|
+
using std::endl;
|
95
|
+
using ext::hash; // or __gnu_cxx::hash, or maybe tr1::hash, depending on your OS
|
96
|
+
|
97
|
+
struct eqstr
|
98
|
+
{
|
99
|
+
bool operator()(const char* s1, const char* s2) const
|
100
|
+
{
|
101
|
+
return (s1 == s2) || (s1 && s2 && strcmp(s1, s2) == 0);
|
102
|
+
}
|
103
|
+
};
|
104
|
+
|
105
|
+
int main()
|
106
|
+
{
|
107
|
+
sparse_hash_map<const char*, int, hash<const char*>, eqstr> months;
|
108
|
+
|
109
|
+
months["january"] = 31;
|
110
|
+
months["february"] = 28;
|
111
|
+
months["march"] = 31;
|
112
|
+
months["april"] = 30;
|
113
|
+
months["may"] = 31;
|
114
|
+
months["june"] = 30;
|
115
|
+
months["july"] = 31;
|
116
|
+
months["august"] = 31;
|
117
|
+
months["september"] = 30;
|
118
|
+
months["october"] = 31;
|
119
|
+
months["november"] = 30;
|
120
|
+
months["december"] = 31;
|
121
|
+
|
122
|
+
cout << "september -> " << months["september"] << endl;
|
123
|
+
cout << "april -> " << months["april"] << endl;
|
124
|
+
cout << "june -> " << months["june"] << endl;
|
125
|
+
cout << "november -> " << months["november"] << endl;
|
126
|
+
}
|
127
|
+
</pre>
|
128
|
+
|
129
|
+
|
130
|
+
<h3>Definition</h3>
|
131
|
+
|
132
|
+
Defined in the header <A href="sparse_hash_map">sparse_hash_map</A>.
|
133
|
+
This class is not part of the C++ standard, though it is mostly
|
134
|
+
compatible with the tr1 class <code>unordered_map</code>.
|
135
|
+
|
136
|
+
|
137
|
+
<h3>Template parameters</h3>
|
138
|
+
|
139
|
+
<table border>
|
140
|
+
<TR><TH>Parameter</TH><TH>Description</TH><TH>Default</TH></TR>
|
141
|
+
|
142
|
+
<TR>
|
143
|
+
<TD VAlign=top>
|
144
|
+
<tt>Key</tt>
|
145
|
+
</TD>
|
146
|
+
<TD VAlign=top>
|
147
|
+
The hash_map's key type. This is also defined as
|
148
|
+
<tt>sparse_hash_map::key_type</tt>.
|
149
|
+
</TD>
|
150
|
+
<TD VAlign=top>
|
151
|
+
|
152
|
+
</TD>
|
153
|
+
</TR>
|
154
|
+
|
155
|
+
<TR>
|
156
|
+
<TD VAlign=top>
|
157
|
+
<tt>Data</tt>
|
158
|
+
</TD>
|
159
|
+
<TD VAlign=top>
|
160
|
+
The hash_map's data type. This is also defined as
|
161
|
+
<tt>sparse_hash_map::data_type</tt>.
|
162
|
+
</TD>
|
163
|
+
<TD VAlign=top>
|
164
|
+
|
165
|
+
</TD>
|
166
|
+
</TR>
|
167
|
+
|
168
|
+
<TR>
|
169
|
+
<TD VAlign=top>
|
170
|
+
<tt>HashFcn</tt>
|
171
|
+
</TD>
|
172
|
+
<TD VAlign=top>
|
173
|
+
The <A href="http://www.sgi.com/tech/stl/HashFunction.html">hash function</A> used by the
|
174
|
+
hash_map. This is also defined as <tt>sparse_hash_map::hasher</tt>.
|
175
|
+
<br><b>Note:</b> Hashtable performance depends heavliy on the choice of
|
176
|
+
hash function. See <A HREF="performance.html#hashfn">the performance
|
177
|
+
page</A> for more information.
|
178
|
+
</TD>
|
179
|
+
<TD VAlign=top>
|
180
|
+
<tt><A href="http://www.sgi.com/tech/stl/hash.html">hash</A><Key></tt>
|
181
|
+
</TD>
|
182
|
+
</TR>
|
183
|
+
|
184
|
+
<TR>
|
185
|
+
<TD VAlign=top>
|
186
|
+
<tt>EqualKey</tt>
|
187
|
+
</TD>
|
188
|
+
<TD VAlign=top>
|
189
|
+
The hash_map key equality function: a <A
|
190
|
+
href="http://www.sgi.com/tech/stl/BinaryPredicate.html">binary predicate</A> that determines
|
191
|
+
whether two keys are equal. This is also defined as
|
192
|
+
<tt>sparse_hash_map::key_equal</tt>.
|
193
|
+
</TD>
|
194
|
+
<TD VAlign=top>
|
195
|
+
<tt><A href="http://www.sgi.com/tech/stl/equal_to.html">equal_to</A><Key></tt>
|
196
|
+
</TD>
|
197
|
+
</TR>
|
198
|
+
|
199
|
+
<TR>
|
200
|
+
<TD VAlign=top>
|
201
|
+
<tt>Alloc</tt>
|
202
|
+
</TD>
|
203
|
+
<TD VAlign=top>
|
204
|
+
<b>Ignored</b>; this is included only for API-compatibility
|
205
|
+
with SGI's (and tr1's) STL implementation.
|
206
|
+
</TD>
|
207
|
+
<TD VAlign=top>
|
208
|
+
</TD>
|
209
|
+
</TR>
|
210
|
+
|
211
|
+
</table>
|
212
|
+
|
213
|
+
|
214
|
+
<h3>Model of</h3>
|
215
|
+
|
216
|
+
<A href="http://www.sgi.com/tech/stl/UniqueHashedAssociativeContainer.html">Unique Hashed Associative Container</A>,
|
217
|
+
<A href="http://www.sgi.com/tech/stl/PairAssociativeContainer.html">Pair Associative Container</A>
|
218
|
+
|
219
|
+
|
220
|
+
<h3>Type requirements</h3>
|
221
|
+
|
222
|
+
<UL>
|
223
|
+
<LI>
|
224
|
+
<tt>Key</tt> is Assignable.
|
225
|
+
<LI>
|
226
|
+
<tt>EqualKey</tt> is a Binary Predicate whose argument type is Key.
|
227
|
+
<LI>
|
228
|
+
<tt>EqualKey</tt> is an equivalence relation.
|
229
|
+
<LI>
|
230
|
+
<tt>Alloc</tt> is an Allocator.
|
231
|
+
</UL>
|
232
|
+
|
233
|
+
|
234
|
+
<h3>Public base classes</h3>
|
235
|
+
|
236
|
+
None.
|
237
|
+
|
238
|
+
|
239
|
+
<h3>Members</h3>
|
240
|
+
|
241
|
+
<table border>
|
242
|
+
<TR><TH>Member</TH><TH>Where defined</TH><TH>Description</TH></TR>
|
243
|
+
|
244
|
+
<TR>
|
245
|
+
<TD VAlign=top>
|
246
|
+
<tt>key_type</tt>
|
247
|
+
</TD>
|
248
|
+
<TD VAlign=top>
|
249
|
+
<A
|
250
|
+
href="http://www.sgi.com/tech/stl/AssociativeContainer.html">Associative
|
251
|
+
Container</A>
|
252
|
+
</TD>
|
253
|
+
<TD VAlign=top>
|
254
|
+
The <tt>sparse_hash_map</tt>'s key type, <tt>Key</tt>.
|
255
|
+
</TD>
|
256
|
+
</TR>
|
257
|
+
|
258
|
+
<TR>
|
259
|
+
<TD VAlign=top>
|
260
|
+
<tt>data_type</tt>
|
261
|
+
</TD>
|
262
|
+
<TD VAlign=top>
|
263
|
+
<A
|
264
|
+
href="http://www.sgi.com/tech/stl/PairAssociativeContainer.html">Pair
|
265
|
+
Associative Container</A>
|
266
|
+
</TD>
|
267
|
+
<TD VAlign=top>
|
268
|
+
The type of object associated with the keys.
|
269
|
+
</TD>
|
270
|
+
</TR>
|
271
|
+
|
272
|
+
<TR>
|
273
|
+
<TD VAlign=top>
|
274
|
+
<tt>value_type</tt>
|
275
|
+
</TD>
|
276
|
+
<TD VAlign=top>
|
277
|
+
<A
|
278
|
+
href="http://www.sgi.com/tech/stl/PairAssociativeContainer.html">Pair
|
279
|
+
Associative Container</A>
|
280
|
+
</TD>
|
281
|
+
<TD VAlign=top>
|
282
|
+
The type of object, <tt>pair<const key_type, data_type></tt>,
|
283
|
+
stored in the hash_map.
|
284
|
+
</TD>
|
285
|
+
</TR>
|
286
|
+
|
287
|
+
<TR>
|
288
|
+
<TD VAlign=top>
|
289
|
+
<tt>hasher</tt>
|
290
|
+
</TD>
|
291
|
+
<TD VAlign=top>
|
292
|
+
<A
|
293
|
+
href="http://www.sgi.com/tech/stl/HashedAssociativeContainer.html">Hashed
|
294
|
+
Associative Container</A>
|
295
|
+
</TD>
|
296
|
+
<TD VAlign=top>
|
297
|
+
The <tt>sparse_hash_map</tt>'s <A
|
298
|
+
href="http://www.sgi.com/tech/stl/HashFunction.html">hash
|
299
|
+
function</A>.
|
300
|
+
</TD>
|
301
|
+
</TR>
|
302
|
+
|
303
|
+
<TR>
|
304
|
+
<TD VAlign=top>
|
305
|
+
<tt>key_equal</tt>
|
306
|
+
</TD>
|
307
|
+
<TD VAlign=top>
|
308
|
+
<A
|
309
|
+
href="http://www.sgi.com/tech/stl/HashedAssociativeContainer.html">Hashed
|
310
|
+
Associative Container</A>
|
311
|
+
</TD>
|
312
|
+
<TD VAlign=top>
|
313
|
+
<A href="http://www.sgi.com/tech/stl/functors.html">Function
|
314
|
+
object</A> that compares keys for equality.
|
315
|
+
</TD>
|
316
|
+
</TR>
|
317
|
+
|
318
|
+
<TR>
|
319
|
+
<TD VAlign=top>
|
320
|
+
<tt>allocator_type</tt>
|
321
|
+
</TD>
|
322
|
+
<TD VAlign=top>
|
323
|
+
<tt>Unordered Associative Container</tt> (tr1)
|
324
|
+
</TD>
|
325
|
+
<TD VAlign=top>
|
326
|
+
The type of the Allocator given as a template parameter.
|
327
|
+
</TD>
|
328
|
+
</TR>
|
329
|
+
|
330
|
+
<TR>
|
331
|
+
<TD VAlign=top>
|
332
|
+
<tt>pointer</tt>
|
333
|
+
</TD>
|
334
|
+
<TD VAlign=top>
|
335
|
+
<A href="http://www.sgi.com/tech/stl/Container.html">Container</A>
|
336
|
+
</TD>
|
337
|
+
<TD VAlign=top>
|
338
|
+
Pointer to <tt>T</tt>.
|
339
|
+
</TD>
|
340
|
+
</TR>
|
341
|
+
|
342
|
+
<TR>
|
343
|
+
<TD VAlign=top>
|
344
|
+
<tt>reference</tt>
|
345
|
+
</TD>
|
346
|
+
<TD VAlign=top>
|
347
|
+
<A href="http://www.sgi.com/tech/stl/Container.html">Container</A>
|
348
|
+
</TD>
|
349
|
+
<TD VAlign=top>
|
350
|
+
Reference to <tt>T</tt>
|
351
|
+
</TD>
|
352
|
+
</TR>
|
353
|
+
|
354
|
+
<TR>
|
355
|
+
<TD VAlign=top>
|
356
|
+
<tt>const_reference</tt>
|
357
|
+
</TD>
|
358
|
+
<TD VAlign=top>
|
359
|
+
<A href="http://www.sgi.com/tech/stl/Container.html">Container</A>
|
360
|
+
</TD>
|
361
|
+
<TD VAlign=top>
|
362
|
+
Const reference to <tt>T</tt>
|
363
|
+
</TD>
|
364
|
+
</TR>
|
365
|
+
|
366
|
+
<TR>
|
367
|
+
<TD VAlign=top>
|
368
|
+
<tt>size_type</tt>
|
369
|
+
</TD>
|
370
|
+
<TD VAlign=top>
|
371
|
+
<A href="http://www.sgi.com/tech/stl/Container.html">Container</A>
|
372
|
+
</TD>
|
373
|
+
<TD VAlign=top>
|
374
|
+
An unsigned integral type.
|
375
|
+
</TD>
|
376
|
+
</TR>
|
377
|
+
|
378
|
+
<TR>
|
379
|
+
<TD VAlign=top>
|
380
|
+
<tt>difference_type</tt>
|
381
|
+
</TD>
|
382
|
+
<TD VAlign=top>
|
383
|
+
<A href="http://www.sgi.com/tech/stl/Container.html">Container</A>
|
384
|
+
</TD>
|
385
|
+
<TD VAlign=top>
|
386
|
+
A signed integral type.
|
387
|
+
</TD>
|
388
|
+
</TR>
|
389
|
+
|
390
|
+
<TR>
|
391
|
+
<TD VAlign=top>
|
392
|
+
<tt>iterator</tt>
|
393
|
+
</TD>
|
394
|
+
<TD VAlign=top>
|
395
|
+
<A href="http://www.sgi.com/tech/stl/Container.html">Container</A>
|
396
|
+
</TD>
|
397
|
+
<TD VAlign=top>
|
398
|
+
Iterator used to iterate through a <tt>sparse_hash_map</tt>. <A
|
399
|
+
href="#1">[1]</A>
|
400
|
+
</TD>
|
401
|
+
</TR>
|
402
|
+
|
403
|
+
<TR>
|
404
|
+
<TD VAlign=top>
|
405
|
+
<tt>const_iterator</tt>
|
406
|
+
</TD>
|
407
|
+
<TD VAlign=top>
|
408
|
+
<A href="http://www.sgi.com/tech/stl/Container.html">Container</A>
|
409
|
+
</TD>
|
410
|
+
<TD VAlign=top>
|
411
|
+
Const iterator used to iterate through a <tt>sparse_hash_map</tt>.
|
412
|
+
</TD>
|
413
|
+
</TR>
|
414
|
+
|
415
|
+
<TR>
|
416
|
+
<TD VAlign=top>
|
417
|
+
<tt>local_iterator</tt>
|
418
|
+
</TD>
|
419
|
+
<TD VAlign=top>
|
420
|
+
<tt>Unordered Associative Container</tt> (tr1)
|
421
|
+
</TD>
|
422
|
+
<TD VAlign=top>
|
423
|
+
Iterator used to iterate through a subset of
|
424
|
+
<tt>sparse_hash_map</tt>. <A href="#1">[1]</A>
|
425
|
+
</TD>
|
426
|
+
</TR>
|
427
|
+
|
428
|
+
<TR>
|
429
|
+
<TD VAlign=top>
|
430
|
+
<tt>const_local_iterator</tt>
|
431
|
+
</TD>
|
432
|
+
<TD VAlign=top>
|
433
|
+
<tt>Unordered Associative Container</tt> (tr1)
|
434
|
+
</TD>
|
435
|
+
<TD VAlign=top>
|
436
|
+
Const iterator used to iterate through a subset of
|
437
|
+
<tt>sparse_hash_map</tt>.
|
438
|
+
</TD>
|
439
|
+
</TR>
|
440
|
+
|
441
|
+
<TR>
|
442
|
+
<TD VAlign=top>
|
443
|
+
<tt>iterator begin()</tt>
|
444
|
+
</TD>
|
445
|
+
<TD VAlign=top>
|
446
|
+
<A href="http://www.sgi.com/tech/stl/Container.html">Container</A>
|
447
|
+
</TD>
|
448
|
+
<TD VAlign=top>
|
449
|
+
Returns an <tt>iterator</tt> pointing to the beginning of the
|
450
|
+
<tt>sparse_hash_map</tt>.
|
451
|
+
</TD>
|
452
|
+
</TR>
|
453
|
+
|
454
|
+
<TR>
|
455
|
+
<TD VAlign=top>
|
456
|
+
<tt>iterator end()</tt>
|
457
|
+
</TD>
|
458
|
+
<TD VAlign=top>
|
459
|
+
<A href="http://www.sgi.com/tech/stl/Container.html">Container</A>
|
460
|
+
</TD>
|
461
|
+
<TD VAlign=top>
|
462
|
+
Returns an <tt>iterator</tt> pointing to the end of the
|
463
|
+
<tt>sparse_hash_map</tt>.
|
464
|
+
</TD>
|
465
|
+
</TR>
|
466
|
+
|
467
|
+
<TR>
|
468
|
+
<TD VAlign=top>
|
469
|
+
<tt>const_iterator begin() const</tt>
|
470
|
+
</TD>
|
471
|
+
<TD VAlign=top>
|
472
|
+
<A href="http://www.sgi.com/tech/stl/Container.html">Container</A>
|
473
|
+
</TD>
|
474
|
+
<TD VAlign=top>
|
475
|
+
Returns an <tt>const_iterator</tt> pointing to the beginning of the
|
476
|
+
<tt>sparse_hash_map</tt>.
|
477
|
+
</TD>
|
478
|
+
</TR>
|
479
|
+
|
480
|
+
<TR>
|
481
|
+
<TD VAlign=top>
|
482
|
+
<tt>const_iterator end() const</tt>
|
483
|
+
</TD>
|
484
|
+
<TD VAlign=top>
|
485
|
+
<A href="http://www.sgi.com/tech/stl/Container.html">Container</A>
|
486
|
+
</TD>
|
487
|
+
<TD VAlign=top>
|
488
|
+
Returns an <tt>const_iterator</tt> pointing to the end of the
|
489
|
+
<tt>sparse_hash_map</tt>.
|
490
|
+
</TD>
|
491
|
+
</TR>
|
492
|
+
|
493
|
+
<TR>
|
494
|
+
<TD VAlign=top>
|
495
|
+
<tt>local_iterator begin(size_type i)</tt>
|
496
|
+
</TD>
|
497
|
+
<TD VAlign=top>
|
498
|
+
<tt>Unordered Associative Container</tt> (tr1)
|
499
|
+
</TD>
|
500
|
+
<TD VAlign=top>
|
501
|
+
Returns a <tt>local_iterator</tt> pointing to the beginning of bucket
|
502
|
+
<tt>i</tt> in the <tt>sparse_hash_map</tt>.
|
503
|
+
</TD>
|
504
|
+
</TR>
|
505
|
+
|
506
|
+
<TR>
|
507
|
+
<TD VAlign=top>
|
508
|
+
<tt>local_iterator end(size_type i)</tt>
|
509
|
+
</TD>
|
510
|
+
<TD VAlign=top>
|
511
|
+
<tt>Unordered Associative Container</tt> (tr1)
|
512
|
+
</TD>
|
513
|
+
<TD VAlign=top>
|
514
|
+
Returns a <tt>local_iterator</tt> pointing to the end of bucket
|
515
|
+
<tt>i</tt> in the <tt>sparse_hash_map</tt>. For
|
516
|
+
<tt>sparse_hash_map</tt>, each bucket contains either 0 or 1 item.
|
517
|
+
</TD>
|
518
|
+
</TR>
|
519
|
+
|
520
|
+
<TR>
|
521
|
+
<TD VAlign=top>
|
522
|
+
<tt>const_local_iterator begin(size_type i) const</tt>
|
523
|
+
</TD>
|
524
|
+
<TD VAlign=top>
|
525
|
+
<tt>Unordered Associative Container</tt> (tr1)
|
526
|
+
</TD>
|
527
|
+
<TD VAlign=top>
|
528
|
+
Returns a <tt>const_local_iterator</tt> pointing to the beginning of bucket
|
529
|
+
<tt>i</tt> in the <tt>sparse_hash_map</tt>.
|
530
|
+
</TD>
|
531
|
+
</TR>
|
532
|
+
|
533
|
+
<TR>
|
534
|
+
<TD VAlign=top>
|
535
|
+
<tt>const_local_iterator end(size_type i) const</tt>
|
536
|
+
</TD>
|
537
|
+
<TD VAlign=top>
|
538
|
+
<tt>Unordered Associative Container</tt> (tr1)
|
539
|
+
</TD>
|
540
|
+
<TD VAlign=top>
|
541
|
+
Returns a <tt>const_local_iterator</tt> pointing to the end of bucket
|
542
|
+
<tt>i</tt> in the <tt>sparse_hash_map</tt>. For
|
543
|
+
<tt>sparse_hash_map</tt>, each bucket contains either 0 or 1 item.
|
544
|
+
</TD>
|
545
|
+
</TR>
|
546
|
+
|
547
|
+
<TR>
|
548
|
+
<TD VAlign=top>
|
549
|
+
<tt>size_type size() const</tt>
|
550
|
+
</TD>
|
551
|
+
<TD VAlign=top>
|
552
|
+
<A href="http://www.sgi.com/tech/stl/Container.html">Container</A>
|
553
|
+
</TD>
|
554
|
+
<TD VAlign=top>
|
555
|
+
Returns the size of the <tt>sparse_hash_map</tt>.
|
556
|
+
</TD>
|
557
|
+
</TR>
|
558
|
+
|
559
|
+
<TR>
|
560
|
+
<TD VAlign=top>
|
561
|
+
<tt>size_type max_size() const</tt>
|
562
|
+
</TD>
|
563
|
+
<TD VAlign=top>
|
564
|
+
<A href="http://www.sgi.com/tech/stl/Container.html">Container</A>
|
565
|
+
</TD>
|
566
|
+
<TD VAlign=top>
|
567
|
+
Returns the largest possible size of the <tt>sparse_hash_map</tt>.
|
568
|
+
</TD>
|
569
|
+
</TR>
|
570
|
+
|
571
|
+
<TR>
|
572
|
+
<TD VAlign=top>
|
573
|
+
<tt>bool empty() const</tt>
|
574
|
+
</TD>
|
575
|
+
<TD VAlign=top>
|
576
|
+
<A href="http://www.sgi.com/tech/stl/Container.html">Container</A>
|
577
|
+
</TD>
|
578
|
+
<TD VAlign=top>
|
579
|
+
<tt>true</tt> if the <tt>sparse_hash_map</tt>'s size is <tt>0</tt>.
|
580
|
+
</TD>
|
581
|
+
</TR>
|
582
|
+
|
583
|
+
<TR>
|
584
|
+
<TD VAlign=top>
|
585
|
+
<tt>size_type bucket_count() const</tt>
|
586
|
+
</TD>
|
587
|
+
<TD VAlign=top>
|
588
|
+
<A
|
589
|
+
href="http://www.sgi.com/tech/stl/HashedAssociativeContainer.html">Hashed
|
590
|
+
Associative Container</A>
|
591
|
+
</TD>
|
592
|
+
<TD VAlign=top>
|
593
|
+
Returns the number of buckets used by the <tt>sparse_hash_map</tt>.
|
594
|
+
</TD>
|
595
|
+
</TR>
|
596
|
+
|
597
|
+
<TR>
|
598
|
+
<TD VAlign=top>
|
599
|
+
<tt>size_type max_bucket_count() const</tt>
|
600
|
+
</TD>
|
601
|
+
<TD VAlign=top>
|
602
|
+
<A
|
603
|
+
href="http://www.sgi.com/tech/stl/HashedAssociativeContainer.html">Hashed
|
604
|
+
Associative Container</A>
|
605
|
+
</TD>
|
606
|
+
<TD VAlign=top>
|
607
|
+
Returns the largest possible number of buckets used by the <tt>sparse_hash_map</tt>.
|
608
|
+
</TD>
|
609
|
+
</TR>
|
610
|
+
|
611
|
+
<TR>
|
612
|
+
<TD VAlign=top>
|
613
|
+
<tt>size_type bucket_size(size_type i) const</tt>
|
614
|
+
</TD>
|
615
|
+
<TD VAlign=top>
|
616
|
+
<tt>Unordered Associative Container</tt> (tr1)
|
617
|
+
</TD>
|
618
|
+
<TD VAlign=top>
|
619
|
+
Returns the number of elements in bucket <tt>i</tt>. For
|
620
|
+
<tt>sparse_hash_map</tt>, this will be either 0 or 1.
|
621
|
+
</TD>
|
622
|
+
</TR>
|
623
|
+
|
624
|
+
<TR>
|
625
|
+
<TD VAlign=top>
|
626
|
+
<tt>size_type bucket(const key_type& key) const</tt>
|
627
|
+
</TD>
|
628
|
+
<TD VAlign=top>
|
629
|
+
<tt>Unordered Associative Container</tt> (tr1)
|
630
|
+
</TD>
|
631
|
+
<TD VAlign=top>
|
632
|
+
If the key exists in the map, returns the index of the bucket
|
633
|
+
containing the given key, otherwise, return the bucket the key
|
634
|
+
would be inserted into.
|
635
|
+
This value may be passed to <tt>begin(size_type)</tt> and
|
636
|
+
<tt>end(size_type)</tt>.
|
637
|
+
</TD>
|
638
|
+
</TR>
|
639
|
+
|
640
|
+
<TR>
|
641
|
+
<TD VAlign=top>
|
642
|
+
<tt>float load_factor() const</tt>
|
643
|
+
</TD>
|
644
|
+
<TD VAlign=top>
|
645
|
+
<tt>Unordered Associative Container</tt> (tr1)
|
646
|
+
</TD>
|
647
|
+
<TD VAlign=top>
|
648
|
+
The number of elements in the <tt>sparse_hash_map</tt> divided by
|
649
|
+
the number of buckets.
|
650
|
+
</TD>
|
651
|
+
</TR>
|
652
|
+
|
653
|
+
<TR>
|
654
|
+
<TD VAlign=top>
|
655
|
+
<tt>float max_load_factor() const</tt>
|
656
|
+
</TD>
|
657
|
+
<TD VAlign=top>
|
658
|
+
<tt>Unordered Associative Container</tt> (tr1)
|
659
|
+
</TD>
|
660
|
+
<TD VAlign=top>
|
661
|
+
The maximum load factor before increasing the number of buckets in
|
662
|
+
the <tt>sparse_hash_map</tt>.
|
663
|
+
</TD>
|
664
|
+
</TR>
|
665
|
+
|
666
|
+
<TR>
|
667
|
+
<TD VAlign=top>
|
668
|
+
<tt>float max_load_factor(size_t new_grow)</tt>
|
669
|
+
</TD>
|
670
|
+
<TD VAlign=top>
|
671
|
+
<tt>Unordered Associative Container</tt> (tr1)
|
672
|
+
</TD>
|
673
|
+
<TD VAlign=top>
|
674
|
+
Sets the maximum load factor before increasing the number of
|
675
|
+
buckets in the <tt>sparse_hash_map</tt>.
|
676
|
+
</TD>
|
677
|
+
</TR>
|
678
|
+
|
679
|
+
<TR>
|
680
|
+
<TD VAlign=top>
|
681
|
+
<tt>float min_load_factor() const</tt>
|
682
|
+
</TD>
|
683
|
+
<TD VAlign=top>
|
684
|
+
<tt>sparse_hash_map</tt>
|
685
|
+
</TD>
|
686
|
+
<TD VAlign=top>
|
687
|
+
The minimum load factor before decreasing the number of buckets in
|
688
|
+
the <tt>sparse_hash_map</tt>.
|
689
|
+
</TD>
|
690
|
+
</TR>
|
691
|
+
|
692
|
+
<TR>
|
693
|
+
<TD VAlign=top>
|
694
|
+
<tt>float min_load_factor(size_t new_grow)</tt>
|
695
|
+
</TD>
|
696
|
+
<TD VAlign=top>
|
697
|
+
<tt>sparse_hash_map</tt>
|
698
|
+
</TD>
|
699
|
+
<TD VAlign=top>
|
700
|
+
Sets the minimum load factor before decreasing the number of
|
701
|
+
buckets in the <tt>sparse_hash_map</tt>.
|
702
|
+
</TD>
|
703
|
+
</TR>
|
704
|
+
|
705
|
+
<TR>
|
706
|
+
<TD VAlign=top>
|
707
|
+
<tt>void set_resizing_parameters(float shrink, float grow)</tt>
|
708
|
+
</TD>
|
709
|
+
<TD VAlign=top>
|
710
|
+
<tt>sparse_hash_map</tt>
|
711
|
+
</TD>
|
712
|
+
<TD VAlign=top>
|
713
|
+
DEPRECATED. <A HREF="#new">See below</A>.
|
714
|
+
</TD>
|
715
|
+
</TR>
|
716
|
+
|
717
|
+
<TR>
|
718
|
+
<TD VAlign=top>
|
719
|
+
<tt>void resize(size_type n)</tt>
|
720
|
+
</TD>
|
721
|
+
<TD VAlign=top>
|
722
|
+
<A
|
723
|
+
href="http://www.sgi.com/tech/stl/HashedAssociativeContainer.html">Hashed
|
724
|
+
Associative Container</A>
|
725
|
+
</TD>
|
726
|
+
<TD VAlign=top>
|
727
|
+
Increases the bucket count to hold at least <tt>n</tt> items.
|
728
|
+
<A href="#4">[4]</A> <A href="#5">[5]</A>
|
729
|
+
</TD>
|
730
|
+
</TR>
|
731
|
+
|
732
|
+
<TR>
|
733
|
+
<TD VAlign=top>
|
734
|
+
<tt>void rehash(size_type n)</tt>
|
735
|
+
</TD>
|
736
|
+
<TD VAlign=top>
|
737
|
+
<tt>Unordered Associative Container</tt> (tr1)
|
738
|
+
</TD>
|
739
|
+
<TD VAlign=top>
|
740
|
+
Increases the bucket count to hold at least <tt>n</tt> items.
|
741
|
+
This is identical to <tt>resize</tt>.
|
742
|
+
<A href="#4">[4]</A> <A href="#5">[5]</A>
|
743
|
+
</TD>
|
744
|
+
</TR>
|
745
|
+
|
746
|
+
<TR>
|
747
|
+
<TD VAlign=top>
|
748
|
+
<tt>hasher hash_funct() const</tt>
|
749
|
+
</TD>
|
750
|
+
<TD VAlign=top>
|
751
|
+
<A
|
752
|
+
href="http://www.sgi.com/tech/stl/HashedAssociativeContainer.html">Hashed
|
753
|
+
Associative Container</A>
|
754
|
+
</TD>
|
755
|
+
<TD VAlign=top>
|
756
|
+
Returns the <tt>hasher</tt> object used by the <tt>sparse_hash_map</tt>.
|
757
|
+
</TD>
|
758
|
+
</TR>
|
759
|
+
|
760
|
+
<TR>
|
761
|
+
<TD VAlign=top>
|
762
|
+
<tt>hasher hash_function() const</tt>
|
763
|
+
</TD>
|
764
|
+
<TD VAlign=top>
|
765
|
+
<tt>Unordered Associative Container</tt> (tr1)
|
766
|
+
</TD>
|
767
|
+
<TD VAlign=top>
|
768
|
+
Returns the <tt>hasher</tt> object used by the <tt>sparse_hash_map</tt>.
|
769
|
+
This is idential to <tt>hash_funct</tt>.
|
770
|
+
</TD>
|
771
|
+
</TR>
|
772
|
+
|
773
|
+
<TR>
|
774
|
+
<TD VAlign=top>
|
775
|
+
<tt>key_equal key_eq() const</tt>
|
776
|
+
</TD>
|
777
|
+
<TD VAlign=top>
|
778
|
+
<A
|
779
|
+
href="http://www.sgi.com/tech/stl/HashedAssociativeContainer.html">Hashed
|
780
|
+
Associative Container</A>
|
781
|
+
</TD>
|
782
|
+
<TD VAlign=top>
|
783
|
+
Returns the <tt>key_equal</tt> object used by the
|
784
|
+
<tt>sparse_hash_map</tt>.
|
785
|
+
</TD>
|
786
|
+
</TR>
|
787
|
+
|
788
|
+
<TR>
|
789
|
+
<TD VAlign=top>
|
790
|
+
<tt>sparse_hash_map()</tt>
|
791
|
+
</TD>
|
792
|
+
<TD VAlign=top>
|
793
|
+
<A href="http://www.sgi.com/tech/stl/Container.html">Container</A>
|
794
|
+
</TD>
|
795
|
+
<TD VAlign=top>
|
796
|
+
Creates an empty <tt>sparse_hash_map</tt>.
|
797
|
+
</TD>
|
798
|
+
</TR>
|
799
|
+
|
800
|
+
<TR>
|
801
|
+
<TD VAlign=top>
|
802
|
+
<tt>sparse_hash_map(size_type n)</tt>
|
803
|
+
</TD>
|
804
|
+
<TD VAlign=top>
|
805
|
+
<A
|
806
|
+
href="http://www.sgi.com/tech/stl/HashedAssociativeContainer.html">Hashed
|
807
|
+
Associative Container</A>
|
808
|
+
</TD>
|
809
|
+
<TD VAlign=top>
|
810
|
+
Creates an empty <tt>sparse_hash_map</tt> that's optimized for holding
|
811
|
+
up to <tt>n</tt> items.
|
812
|
+
<A href="#5">[5]</A>
|
813
|
+
</TD>
|
814
|
+
</TR>
|
815
|
+
|
816
|
+
<TR>
|
817
|
+
<TD VAlign=top>
|
818
|
+
<tt>sparse_hash_map(size_type n, const hasher& h)</tt>
|
819
|
+
</TD>
|
820
|
+
<TD VAlign=top>
|
821
|
+
<A
|
822
|
+
href="http://www.sgi.com/tech/stl/HashedAssociativeContainer.html">Hashed
|
823
|
+
Associative Container</A>
|
824
|
+
</TD>
|
825
|
+
<TD VAlign=top>
|
826
|
+
Creates an empty <tt>sparse_hash_map</tt> that's optimized for up
|
827
|
+
to <tt>n</tt> items, using <tt>h</tt> as the hash function.
|
828
|
+
</TD>
|
829
|
+
</TR>
|
830
|
+
|
831
|
+
<TR>
|
832
|
+
<TD VAlign=top>
|
833
|
+
<tt>sparse_hash_map(size_type n, const hasher& h, const
|
834
|
+
key_equal& k)</tt>
|
835
|
+
</TD>
|
836
|
+
<TD VAlign=top>
|
837
|
+
<A
|
838
|
+
href="http://www.sgi.com/tech/stl/HashedAssociativeContainer.html">Hashed
|
839
|
+
Associative Container</A>
|
840
|
+
</TD>
|
841
|
+
<TD VAlign=top>
|
842
|
+
Creates an empty <tt>sparse_hash_map</tt> that's optimized for up
|
843
|
+
to <tt>n</tt> items, using <tt>h</tt> as the hash function and
|
844
|
+
<tt>k</tt> as the key equal function.
|
845
|
+
</TD>
|
846
|
+
</TR>
|
847
|
+
|
848
|
+
<TR>
|
849
|
+
<TD VAlign=top>
|
850
|
+
<pre>template <class <A
|
851
|
+
href="http://www.sgi.com/tech/stl/InputIterator.html">InputIterator</A>>
|
852
|
+
sparse_hash_map(InputIterator f, InputIterator l) </pre>
|
853
|
+
<A href="#2">[2]</A>
|
854
|
+
</TD>
|
855
|
+
<TD VAlign=top>
|
856
|
+
<A
|
857
|
+
href="http://www.sgi.com/tech/stl/UniqueHashedAssociativeContainer.html">Unique
|
858
|
+
Hashed Associative Container</A>
|
859
|
+
</TD>
|
860
|
+
<TD VAlign=top>
|
861
|
+
Creates a sparse_hash_map with a copy of a range.
|
862
|
+
</TD>
|
863
|
+
</TR>
|
864
|
+
|
865
|
+
<TR>
|
866
|
+
<TD VAlign=top>
|
867
|
+
<pre>template <class <A
|
868
|
+
href="http://www.sgi.com/tech/stl/InputIterator.html">InputIterator</A>>
|
869
|
+
sparse_hash_map(InputIterator f, InputIterator l, size_type n) </pre>
|
870
|
+
<A href="#2">[2]</A>
|
871
|
+
</TD>
|
872
|
+
<TD VAlign=top>
|
873
|
+
<A
|
874
|
+
href="http://www.sgi.com/tech/stl/UniqueHashedAssociativeContainer.html">Unique
|
875
|
+
Hashed Associative Container</A>
|
876
|
+
</TD>
|
877
|
+
<TD VAlign=top>
|
878
|
+
Creates a hash_map with a copy of a range that's optimized to
|
879
|
+
hold up to <tt>n</tt> items.
|
880
|
+
</TD>
|
881
|
+
</TR>
|
882
|
+
|
883
|
+
<TR>
|
884
|
+
<TD VAlign=top>
|
885
|
+
<pre>template <class <A
|
886
|
+
href="http://www.sgi.com/tech/stl/InputIterator.html">InputIterator</A>>
|
887
|
+
sparse_hash_map(InputIterator f, InputIterator l, size_type n, const
|
888
|
+
hasher& h) </pre> <A href="#2">[2]</A>
|
889
|
+
</TD>
|
890
|
+
<TD VAlign=top>
|
891
|
+
<A
|
892
|
+
href="http://www.sgi.com/tech/stl/UniqueHashedAssociativeContainer.html">Unique
|
893
|
+
Hashed Associative Container</A>
|
894
|
+
</TD>
|
895
|
+
<TD VAlign=top>
|
896
|
+
Creates a hash_map with a copy of a range that's optimized to hold
|
897
|
+
up to <tt>n</tt> items, using <tt>h</tt> as the hash function.
|
898
|
+
</TD>
|
899
|
+
</TR>
|
900
|
+
|
901
|
+
<TR>
|
902
|
+
<TD VAlign=top>
|
903
|
+
<pre>template <class <A
|
904
|
+
href="http://www.sgi.com/tech/stl/InputIterator.html">InputIterator</A>>
|
905
|
+
sparse_hash_map(InputIterator f, InputIterator l, size_type n, const
|
906
|
+
hasher& h, const key_equal& k) </pre> <A href="#2">[2]</A>
|
907
|
+
</TD>
|
908
|
+
<TD VAlign=top>
|
909
|
+
<A
|
910
|
+
href="http://www.sgi.com/tech/stl/UniqueHashedAssociativeContainer.html">Unique
|
911
|
+
Hashed Associative Container</A>
|
912
|
+
</TD>
|
913
|
+
<TD VAlign=top>
|
914
|
+
Creates a hash_map with a copy of a range that's optimized for
|
915
|
+
holding up to <tt>n</tt> items, using <tt>h</tt> as the hash
|
916
|
+
function and <tt>k</tt> as the key equal function.
|
917
|
+
</TD>
|
918
|
+
</TR>
|
919
|
+
|
920
|
+
<TR>
|
921
|
+
<TD VAlign=top>
|
922
|
+
<tt>sparse_hash_map(const hash_map&)</tt>
|
923
|
+
</TD>
|
924
|
+
<TD VAlign=top>
|
925
|
+
<A href="http://www.sgi.com/tech/stl/Container.html">Container</A>
|
926
|
+
</TD>
|
927
|
+
<TD VAlign=top>
|
928
|
+
The copy constructor.
|
929
|
+
</TD>
|
930
|
+
</TR>
|
931
|
+
|
932
|
+
<TR>
|
933
|
+
<TD VAlign=top>
|
934
|
+
<tt>sparse_hash_map& operator=(const hash_map&)</tt>
|
935
|
+
</TD>
|
936
|
+
<TD VAlign=top>
|
937
|
+
<A href="http://www.sgi.com/tech/stl/Container.html">Container</A>
|
938
|
+
</TD>
|
939
|
+
<TD VAlign=top>
|
940
|
+
The assignment operator
|
941
|
+
</TD>
|
942
|
+
</TR>
|
943
|
+
|
944
|
+
<TR>
|
945
|
+
<TD VAlign=top>
|
946
|
+
<tt>void swap(hash_map&)</tt>
|
947
|
+
</TD>
|
948
|
+
<TD VAlign=top>
|
949
|
+
<A href="http://www.sgi.com/tech/stl/Container.html">Container</A>
|
950
|
+
</TD>
|
951
|
+
<TD VAlign=top>
|
952
|
+
Swaps the contents of two hash_maps.
|
953
|
+
</TD>
|
954
|
+
</TR>
|
955
|
+
|
956
|
+
<TR>
|
957
|
+
<TD VAlign=top>
|
958
|
+
<pre>pair<iterator, bool> insert(const value_type& x)
|
959
|
+
</pre>
|
960
|
+
</TD>
|
961
|
+
<TD VAlign=top>
|
962
|
+
<A
|
963
|
+
href="http://www.sgi.com/tech/stl/UniqueAssociativeContainer.html">Unique
|
964
|
+
Associative Container</A>
|
965
|
+
</TD>
|
966
|
+
<TD VAlign=top>
|
967
|
+
Inserts <tt>x</tt> into the <tt>sparse_hash_map</tt>.
|
968
|
+
</TD>
|
969
|
+
</TR>
|
970
|
+
|
971
|
+
<TR>
|
972
|
+
<TD VAlign=top>
|
973
|
+
<pre>template <class <A
|
974
|
+
href="http://www.sgi.com/tech/stl/InputIterator.html">InputIterator</A>>
|
975
|
+
void insert(InputIterator f, InputIterator l) </pre> <A href="#2">[2]</A>
|
976
|
+
</TD>
|
977
|
+
<TD VAlign=top>
|
978
|
+
<A
|
979
|
+
href="http://www.sgi.com/tech/stl/UniqueAssociativeContainer.html">Unique
|
980
|
+
Associative Container</A>
|
981
|
+
</TD>
|
982
|
+
<TD VAlign=top>
|
983
|
+
Inserts a range into the <tt>sparse_hash_map</tt>.
|
984
|
+
</TD>
|
985
|
+
</TR>
|
986
|
+
|
987
|
+
<TR>
|
988
|
+
<TD VAlign=top>
|
989
|
+
<tt>void set_deleted_key(const key_type& key)</tt> <A href="#6">[6]</A>
|
990
|
+
</TD>
|
991
|
+
<TD VAlign=top>
|
992
|
+
<tt>sparse_hash_map</tt>
|
993
|
+
</TD>
|
994
|
+
<TD VAlign=top>
|
995
|
+
<A HREF="#new">See below</A>.
|
996
|
+
</TD>
|
997
|
+
</TR>
|
998
|
+
|
999
|
+
<TR>
|
1000
|
+
<TD VAlign=top>
|
1001
|
+
<tt>void clear_deleted_key()</tt> <A href="#6">[6]</A>
|
1002
|
+
</TD>
|
1003
|
+
<TD VAlign=top>
|
1004
|
+
<tt>sparse_hash_map</tt>
|
1005
|
+
</TD>
|
1006
|
+
<TD VAlign=top>
|
1007
|
+
<A HREF="#new">See below</A>.
|
1008
|
+
</TD>
|
1009
|
+
</TR>
|
1010
|
+
|
1011
|
+
<TR>
|
1012
|
+
<TD VAlign=top>
|
1013
|
+
<tt>void erase(iterator pos)</tt>
|
1014
|
+
</TD>
|
1015
|
+
<TD VAlign=top>
|
1016
|
+
<A
|
1017
|
+
href="http://www.sgi.com/tech/stl/AssociativeContainer.html">Associative
|
1018
|
+
Container</A>
|
1019
|
+
</TD>
|
1020
|
+
<TD VAlign=top>
|
1021
|
+
Erases the element pointed to by <tt>pos</tt>.
|
1022
|
+
<A href="#6">[6]</A>
|
1023
|
+
</TD>
|
1024
|
+
</TR>
|
1025
|
+
|
1026
|
+
<TR>
|
1027
|
+
<TD VAlign=top>
|
1028
|
+
<tt>size_type erase(const key_type& k)</tt>
|
1029
|
+
</TD>
|
1030
|
+
<TD VAlign=top>
|
1031
|
+
<A
|
1032
|
+
href="http://www.sgi.com/tech/stl/AssociativeContainer.html">Associative
|
1033
|
+
Container</A>
|
1034
|
+
</TD>
|
1035
|
+
<TD VAlign=top>
|
1036
|
+
Erases the element whose key is <tt>k</tt>.
|
1037
|
+
<A href="#6">[6]</A>
|
1038
|
+
</TD>
|
1039
|
+
</TR>
|
1040
|
+
|
1041
|
+
<TR>
|
1042
|
+
<TD VAlign=top>
|
1043
|
+
<tt>void erase(iterator first, iterator last)</tt>
|
1044
|
+
</TD>
|
1045
|
+
<TD VAlign=top>
|
1046
|
+
<A
|
1047
|
+
href="http://www.sgi.com/tech/stl/AssociativeContainer.html">Associative
|
1048
|
+
Container</A>
|
1049
|
+
</TD>
|
1050
|
+
<TD VAlign=top>
|
1051
|
+
Erases all elements in a range.
|
1052
|
+
<A href="#6">[6]</A>
|
1053
|
+
</TD>
|
1054
|
+
</TR>
|
1055
|
+
|
1056
|
+
<TR>
|
1057
|
+
<TD VAlign=top>
|
1058
|
+
<tt>void clear()</tt>
|
1059
|
+
</TD>
|
1060
|
+
<TD VAlign=top>
|
1061
|
+
<A
|
1062
|
+
href="http://www.sgi.com/tech/stl/AssociativeContainer.html">Associative
|
1063
|
+
Container</A>
|
1064
|
+
</TD>
|
1065
|
+
<TD VAlign=top>
|
1066
|
+
Erases all of the elements.
|
1067
|
+
</TD>
|
1068
|
+
</TR>
|
1069
|
+
|
1070
|
+
<TR>
|
1071
|
+
<TD VAlign=top>
|
1072
|
+
<tt>const_iterator find(const key_type& k) const</tt>
|
1073
|
+
</TD>
|
1074
|
+
<TD VAlign=top>
|
1075
|
+
<A
|
1076
|
+
href="http://www.sgi.com/tech/stl/AssociativeContainer.html">Associative
|
1077
|
+
Container</A>
|
1078
|
+
</TD>
|
1079
|
+
<TD VAlign=top>
|
1080
|
+
Finds an element whose key is <tt>k</tt>.
|
1081
|
+
</TD>
|
1082
|
+
</TR>
|
1083
|
+
|
1084
|
+
<TR>
|
1085
|
+
<TD VAlign=top>
|
1086
|
+
<tt>iterator find(const key_type& k)</tt>
|
1087
|
+
</TD>
|
1088
|
+
<TD VAlign=top>
|
1089
|
+
<A
|
1090
|
+
href="http://www.sgi.com/tech/stl/AssociativeContainer.html">Associative
|
1091
|
+
Container</A>
|
1092
|
+
</TD>
|
1093
|
+
<TD VAlign=top>
|
1094
|
+
Finds an element whose key is <tt>k</tt>.
|
1095
|
+
</TD>
|
1096
|
+
</TR>
|
1097
|
+
|
1098
|
+
<TR>
|
1099
|
+
<TD VAlign=top>
|
1100
|
+
<tt>size_type count(const key_type& k) const</tt>
|
1101
|
+
</TD>
|
1102
|
+
<TD VAlign=top>
|
1103
|
+
<A
|
1104
|
+
href="http://www.sgi.com/tech/stl/UniqueAssociativeContainer.html">Unique
|
1105
|
+
Associative Container</A>
|
1106
|
+
</TD>
|
1107
|
+
<TD VAlign=top>
|
1108
|
+
Counts the number of elements whose key is <tt>k</tt>.
|
1109
|
+
</TD>
|
1110
|
+
</TR>
|
1111
|
+
|
1112
|
+
<TR>
|
1113
|
+
<TD VAlign=top>
|
1114
|
+
<pre>pair<const_iterator, const_iterator> equal_range(const
|
1115
|
+
key_type& k) const </pre>
|
1116
|
+
</TD>
|
1117
|
+
<TD VAlign=top>
|
1118
|
+
<A
|
1119
|
+
href="http://www.sgi.com/tech/stl/AssociativeContainer.html">Associative
|
1120
|
+
Container</A>
|
1121
|
+
</TD>
|
1122
|
+
<TD VAlign=top>
|
1123
|
+
Finds a range containing all elements whose key is <tt>k</tt>.
|
1124
|
+
</TD>
|
1125
|
+
</TR>
|
1126
|
+
|
1127
|
+
<TR>
|
1128
|
+
<TD VAlign=top>
|
1129
|
+
<pre>pair<iterator, iterator> equal_range(const
|
1130
|
+
key_type& k) </pre>
|
1131
|
+
</TD>
|
1132
|
+
<TD VAlign=top>
|
1133
|
+
<A
|
1134
|
+
href="http://www.sgi.com/tech/stl/AssociativeContainer.html">Associative
|
1135
|
+
Container</A>
|
1136
|
+
</TD>
|
1137
|
+
<TD VAlign=top>
|
1138
|
+
Finds a range containing all elements whose key is <tt>k</tt>.
|
1139
|
+
</TD>
|
1140
|
+
</TR>
|
1141
|
+
|
1142
|
+
<TR>
|
1143
|
+
<TD VAlign=top>
|
1144
|
+
<pre>data_type& operator[](const key_type& k) <A
|
1145
|
+
href="http://www.sgi.com/tech/stl/#3">[3]</A> </pre>
|
1146
|
+
</TD>
|
1147
|
+
<TD VAlign=top>
|
1148
|
+
<tt>sparse_hash_map</tt>
|
1149
|
+
</TD>
|
1150
|
+
<TD VAlign=top>
|
1151
|
+
<A HREF="#new">See below</A>.
|
1152
|
+
</TD>
|
1153
|
+
</TR>
|
1154
|
+
|
1155
|
+
<TR>
|
1156
|
+
<TD VAlign=top>
|
1157
|
+
<tt>bool write_metadata(FILE *fp)</tt>
|
1158
|
+
</TD>
|
1159
|
+
<TD VAlign=top>
|
1160
|
+
<tt>sparse_hash_map</tt>
|
1161
|
+
</TD>
|
1162
|
+
<TD VAlign=top>
|
1163
|
+
<A HREF="#new">See below</A>.
|
1164
|
+
</TD>
|
1165
|
+
</TR>
|
1166
|
+
|
1167
|
+
<TR>
|
1168
|
+
<TD VAlign=top>
|
1169
|
+
<tt>bool read_metadata(FILE *fp)</tt>
|
1170
|
+
</TD>
|
1171
|
+
<TD VAlign=top>
|
1172
|
+
<tt>sparse_hash_map</tt>
|
1173
|
+
</TD>
|
1174
|
+
<TD VAlign=top>
|
1175
|
+
<A HREF="#new">See below</A>.
|
1176
|
+
</TD>
|
1177
|
+
</TR>
|
1178
|
+
|
1179
|
+
<TR>
|
1180
|
+
<TD VAlign=top>
|
1181
|
+
<tt>bool write_nopointer_data(FILE *fp)</tt>
|
1182
|
+
</TD>
|
1183
|
+
<TD VAlign=top>
|
1184
|
+
<tt>sparse_hash_map</tt>
|
1185
|
+
</TD>
|
1186
|
+
<TD VAlign=top>
|
1187
|
+
<A HREF="#new">See below</A>.
|
1188
|
+
</TD>
|
1189
|
+
</TR>
|
1190
|
+
|
1191
|
+
<TR>
|
1192
|
+
<TD VAlign=top>
|
1193
|
+
<tt>bool read_nopointer_data(FILE *fp)</tt>
|
1194
|
+
</TD>
|
1195
|
+
<TD VAlign=top>
|
1196
|
+
<tt>sparse_hash_map</tt>
|
1197
|
+
</TD>
|
1198
|
+
<TD VAlign=top>
|
1199
|
+
<A HREF="#new">See below</A>.
|
1200
|
+
</TD>
|
1201
|
+
</TR>
|
1202
|
+
|
1203
|
+
<TR>
|
1204
|
+
<TD VAlign=top>
|
1205
|
+
<pre>bool operator==(const hash_map&, const hash_map&)
|
1206
|
+
</pre>
|
1207
|
+
</TD>
|
1208
|
+
<TD VAlign=top>
|
1209
|
+
<A
|
1210
|
+
href="http://www.sgi.com/tech/stl/HashedAssociativeContainer.html">Hashed
|
1211
|
+
Associative Container</A>
|
1212
|
+
</TD>
|
1213
|
+
<TD VAlign=top>
|
1214
|
+
Tests two hash_maps for equality. This is a global function, not a
|
1215
|
+
member function.
|
1216
|
+
</TD>
|
1217
|
+
</TR>
|
1218
|
+
|
1219
|
+
</table>
|
1220
|
+
|
1221
|
+
|
1222
|
+
<h3><A NAME="new">New members</A></h3>
|
1223
|
+
|
1224
|
+
These members are not defined in the <A
|
1225
|
+
href="http://www.sgi.com/tech/stl/UniqueHashedAssociativeContainer.html">Unique
|
1226
|
+
Hashed Associative Container</A>, <A
|
1227
|
+
href="http://www.sgi.com/tech/stl/PairAssociativeContainer.html">Pair
|
1228
|
+
Associative Container</A>, or tr1's
|
1229
|
+
<tt>Unordered Associative Container</tt> requirements,
|
1230
|
+
but are specific to <tt>sparse_hash_map</tt>.
|
1231
|
+
|
1232
|
+
<table border>
|
1233
|
+
<TR><TH>Member</TH><TH>Description</TH></TR>
|
1234
|
+
|
1235
|
+
<TR>
|
1236
|
+
<TR>
|
1237
|
+
<TD VAlign=top>
|
1238
|
+
<tt>void set_deleted_key(const key_type& key)</tt>
|
1239
|
+
</TD>
|
1240
|
+
<TD VAlign=top>
|
1241
|
+
Sets the distinguished "deleted" key to <tt>key</tt>. This must be
|
1242
|
+
called before any calls to <tt>erase()</tt>. <A href="#6">[6]</A>
|
1243
|
+
</TD>
|
1244
|
+
</TR>
|
1245
|
+
|
1246
|
+
<TR>
|
1247
|
+
<TD VAlign=top>
|
1248
|
+
<tt>void clear_deleted_key()</tt>
|
1249
|
+
</TD>
|
1250
|
+
<TD VAlign=top>
|
1251
|
+
Clears the distinguished "deleted" key. After this is called,
|
1252
|
+
calls to <tt>erase()</tt> are not valid on this object.
|
1253
|
+
<A href="#6">[6]</A>
|
1254
|
+
</TD>
|
1255
|
+
</TR>
|
1256
|
+
|
1257
|
+
<TR>
|
1258
|
+
<TD VAlign=top>
|
1259
|
+
<pre>
|
1260
|
+
data_type&
|
1261
|
+
operator[](const key_type& k) <A
|
1262
|
+
href="http://www.sgi.com/tech/stl/#3">[3]</A>
|
1263
|
+
</pre>
|
1264
|
+
</TD>
|
1265
|
+
<TD VAlign=top>
|
1266
|
+
Returns a reference to the object that is associated with
|
1267
|
+
a particular key. If the <tt>sparse_hash_map</tt> does not already
|
1268
|
+
contain such an object, <tt>operator[]</tt> inserts the default
|
1269
|
+
object <tt>data_type()</tt>. <A
|
1270
|
+
href="http://www.sgi.com/tech/stl/#3">[3]</A>
|
1271
|
+
</TD>
|
1272
|
+
</TR>
|
1273
|
+
|
1274
|
+
<TD VAlign=top>
|
1275
|
+
<tt>void set_resizing_parameters(float shrink, float grow)</tt>
|
1276
|
+
</TD>
|
1277
|
+
<TD VAlign=top>
|
1278
|
+
This function is DEPRECATED. It is equivalent to calling
|
1279
|
+
<tt>min_load_factor(shrink); max_load_factor(grow)</tt>.
|
1280
|
+
</TD>
|
1281
|
+
</TR>
|
1282
|
+
|
1283
|
+
<TR>
|
1284
|
+
<TD VAlign=top>
|
1285
|
+
<tt>bool write_metadata(FILE *fp)</tt>
|
1286
|
+
</TD>
|
1287
|
+
<TD VAlign=top>
|
1288
|
+
Write hashtable metadata to <tt>fp</tt>. See <A HREF="#io">below</A>.
|
1289
|
+
</TD>
|
1290
|
+
</TR>
|
1291
|
+
|
1292
|
+
<TR>
|
1293
|
+
<TD VAlign=top>
|
1294
|
+
<tt>bool read_metadata(FILE *fp)</tt>
|
1295
|
+
</TD>
|
1296
|
+
<TD VAlign=top>
|
1297
|
+
Read hashtable metadata from <tt>fp</tt>. See <A HREF="#io">below</A>.
|
1298
|
+
</TD>
|
1299
|
+
</TR>
|
1300
|
+
|
1301
|
+
<TR>
|
1302
|
+
<TD VAlign=top>
|
1303
|
+
<tt>bool write_nopointer_data(FILE *fp)</tt>
|
1304
|
+
</TD>
|
1305
|
+
<TD VAlign=top>
|
1306
|
+
Write hashtable contents to <tt>fp</tt>. This is valid only if the
|
1307
|
+
hashtable key and value are "plain" data. See <A HREF="#io">below</A>.
|
1308
|
+
</TD>
|
1309
|
+
</TR>
|
1310
|
+
|
1311
|
+
<TR>
|
1312
|
+
<TD VAlign=top>
|
1313
|
+
<tt>bool read_nopointer_data(FILE *fp)</tt>
|
1314
|
+
</TD>
|
1315
|
+
<TD VAlign=top>
|
1316
|
+
Read hashtable contents to <tt>fp</tt>. This is valid only if the
|
1317
|
+
hashtable key and value are "plain" data. See <A HREF="#io">below</A>.
|
1318
|
+
</TD>
|
1319
|
+
</TR>
|
1320
|
+
|
1321
|
+
</table>
|
1322
|
+
|
1323
|
+
|
1324
|
+
<h3>Notes</h3>
|
1325
|
+
|
1326
|
+
<P><A name="1">[1]</A>
|
1327
|
+
|
1328
|
+
<tt>sparse_hash_map::iterator</tt> is not a mutable iterator, because
|
1329
|
+
<tt>sparse_hash_map::value_type</tt> is not <A
|
1330
|
+
href="http://www.sgi.com/tech/stl/Assignable.html">Assignable</A>.
|
1331
|
+
That is, if <tt>i</tt> is of type <tt>sparse_hash_map::iterator</tt>
|
1332
|
+
and <tt>p</tt> is of type <tt>sparse_hash_map::value_type</tt>, then
|
1333
|
+
<tt>*i = p</tt> is not a valid expression. However,
|
1334
|
+
<tt>sparse_hash_map::iterator</tt> isn't a constant iterator either,
|
1335
|
+
because it can be used to modify the object that it points to. Using
|
1336
|
+
the same notation as above, <tt>(*i).second = p</tt> is a valid
|
1337
|
+
expression.</p>
|
1338
|
+
|
1339
|
+
<P><A name="2">[2]</A>
|
1340
|
+
|
1341
|
+
This member function relies on <i>member template</i> functions, which
|
1342
|
+
may not be supported by all compilers. If your compiler supports
|
1343
|
+
member templates, you can call this function with any type of <A
|
1344
|
+
href="http://www.sgi.com/tech/stl/InputIterator.html">input
|
1345
|
+
iterator</A>. If your compiler does not yet support member templates,
|
1346
|
+
though, then the arguments must either be of type <tt>const
|
1347
|
+
value_type*</tt> or of type <tt>sparse_hash_map::const_iterator</tt>.</p>
|
1348
|
+
|
1349
|
+
<P><A name="3">[3]</A>
|
1350
|
+
|
1351
|
+
Since <tt>operator[]</tt> might insert a new element into the
|
1352
|
+
<tt>sparse_hash_map</tt>, it can't possibly be a <tt>const</tt> member
|
1353
|
+
function. Note that the definition of <tt>operator[]</tt> is
|
1354
|
+
extremely simple: <tt>m[k]</tt> is equivalent to
|
1355
|
+
<tt>(*((m.insert(value_type(k, data_type()))).first)).second</tt>.
|
1356
|
+
Strictly speaking, this member function is unnecessary: it exists only
|
1357
|
+
for convenience.</p>
|
1358
|
+
|
1359
|
+
<P><A name="4">[4]</A>
|
1360
|
+
|
1361
|
+
In order to preserve iterators, erasing hashtable elements does not
|
1362
|
+
cause a hashtable to resize. This means that after a string of
|
1363
|
+
<tt>erase()</tt> calls, the hashtable will use more space than is
|
1364
|
+
required. At a cost of invalidating all current iterators, you can
|
1365
|
+
call <tt>resize()</tt> to manually compact the hashtable. The
|
1366
|
+
hashtable promotes too-small <tt>resize()</tt> arguments to the
|
1367
|
+
smallest legal value, so to compact a hashtable, it's sufficient to
|
1368
|
+
call <tt>resize(0)</tt>.
|
1369
|
+
|
1370
|
+
<P><A name="5">[5]</A>
|
1371
|
+
|
1372
|
+
Unlike some other hashtable implementations, the optional <i>n</i> in
|
1373
|
+
the calls to the constructor, <tt>resize</tt>, and <tt>rehash</tt>
|
1374
|
+
indicates not the desired number of buckets that
|
1375
|
+
should be allocated, but instead the expected number of items to be
|
1376
|
+
inserted. The class then sizes the hash-map appropriately for the
|
1377
|
+
number of items specified. It's not an error to actually insert more
|
1378
|
+
or fewer items into the hashtable, but the implementation is most
|
1379
|
+
efficient -- does the fewest hashtable resizes -- if the number of
|
1380
|
+
inserted items is <i>n</i> or slightly less.</p>
|
1381
|
+
|
1382
|
+
<P><A name="6">[6]</A>
|
1383
|
+
|
1384
|
+
<tt>sparse_hash_map</tt> <b>requires</b> you call
|
1385
|
+
<tt>set_deleted_key()</tt> before calling <tt>erase()</tt>. (This is
|
1386
|
+
the largest difference between the <tt>sparse_hash_map</tt> API and
|
1387
|
+
other hash-map APIs. See <A HREF="implementation.html">implementation.html</A>
|
1388
|
+
for why this is necessary.)
|
1389
|
+
The argument to <tt>set_deleted_key()</tt> should be a key-value that
|
1390
|
+
is never used for legitimate hash-map entries. It is an error to call
|
1391
|
+
<tt>erase()</tt> without first calling <tt>set_deleted_key()</tt>, and
|
1392
|
+
it is also an error to call <tt>insert()</tt> with an item whose key
|
1393
|
+
is the "deleted key."</p>
|
1394
|
+
|
1395
|
+
<p>There is no need to call <tt>set_deleted_key</tt> if you do not
|
1396
|
+
wish to call <tt>erase()</tt> on the hash-map.</p>
|
1397
|
+
|
1398
|
+
<p>It is acceptable to change the deleted-key at any time by calling
|
1399
|
+
<tt>set_deleted_key()</tt> with a new argument. You can also call
|
1400
|
+
<tt>clear_deleted_key()</tt>, at which point all keys become valid for
|
1401
|
+
insertion but no hashtable entries can be deleted until
|
1402
|
+
<tt>set_deleted_key()</tt> is called again.</p>
|
1403
|
+
|
1404
|
+
<p><b>Note:</b> If you use <tt>set_deleted_key</tt>, it is also
|
1405
|
+
necessary that <tt>data_type</tt> has a zero-argument default
|
1406
|
+
constructor. This is because <tt>sparse_hash_map</tt> uses the
|
1407
|
+
special value <tt>pair(deleted_key, data_type())</tt> to denote
|
1408
|
+
deleted buckets, and thus needs to be able to create
|
1409
|
+
<tt>data_type</tt> using a zero-argument constructor.</p>
|
1410
|
+
|
1411
|
+
<p>If your <tt>data_type</tt> does not have a zero-argument default
|
1412
|
+
constructor, there are several workarounds:</p>
|
1413
|
+
<ul>
|
1414
|
+
<li> Store a pointer to <tt>data_type</tt> in the map, instead of
|
1415
|
+
<tt>data_type</tt> directly. This may yield faster code as
|
1416
|
+
well, since hashtable-resizes will just have to move pointers
|
1417
|
+
around, rather than copying the entire <tt>data_type</tt>.
|
1418
|
+
<li> Add a zero-argument default constructor to <tt>data_type</tt>.
|
1419
|
+
<li> Subclass <tt>data_type</tt> and add a zero-argument default
|
1420
|
+
constructor to the subclass.
|
1421
|
+
</ul>
|
1422
|
+
|
1423
|
+
<p>If you do not use <tt>set_deleted_key</tt>, then there is no
|
1424
|
+
requirement that <tt>data_type</tt> havea zero-argument default
|
1425
|
+
constructor.
|
1426
|
+
|
1427
|
+
|
1428
|
+
<h3><A NAME=io>Input/Output</A></h3>
|
1429
|
+
|
1430
|
+
<p>It is possible to save and restore <tt>sparse_hash_map</tt> objects
|
1431
|
+
to disk. Storage takes place in two steps. The first writes the
|
1432
|
+
hashtable metadata. The second writes the actual data.</p>
|
1433
|
+
|
1434
|
+
<p>To write a hashtable to disk, first call <tt>write_metadata()</tt>
|
1435
|
+
on an open file pointer. This saves the hashtable information in a
|
1436
|
+
byte-order-independent format.</p>
|
1437
|
+
|
1438
|
+
<p>After the metadata has been written to disk, you must write the
|
1439
|
+
actual data stored in the hash-map to disk. If both the key and data
|
1440
|
+
are "simple" enough, you can do this by calling
|
1441
|
+
<tt>write_nopointer_data()</tt>. "Simple" data is data that can be
|
1442
|
+
safely copied to disk via <tt>fwrite()</tt>. Native C data types fall
|
1443
|
+
into this category, as do structs of native C data types. Pointers
|
1444
|
+
and STL objects do not.</p>
|
1445
|
+
|
1446
|
+
<p>Note that <tt>write_nopointer_data()</tt> does not do any endian
|
1447
|
+
conversion. Thus, it is only appropriate when you intend to read the
|
1448
|
+
data on the same endian architecture as you write the data.</p>
|
1449
|
+
|
1450
|
+
<p>If you cannot use <tt>write_nopointer_data()</tt> for any reason,
|
1451
|
+
you can write the data yourself by iterating over the
|
1452
|
+
<tt>sparse_hash_map</tt> with a <tt>const_iterator</tt> and writing
|
1453
|
+
the key and data in any manner you wish.</p>
|
1454
|
+
|
1455
|
+
<p>To read the hashtable information from disk, first you must create
|
1456
|
+
a <tt>sparse_hash_map</tt> object. Then open a file pointer to point
|
1457
|
+
to the saved hashtable, and call <tt>read_metadata()</tt>. If you
|
1458
|
+
saved the data via <tt>write_nopointer_data()</tt>, you can follow the
|
1459
|
+
<tt>read_metadata()</tt> call with a call to
|
1460
|
+
<tt>read_nopointer_data()</tt>. This is all that is needed.</p>
|
1461
|
+
|
1462
|
+
<p>If you saved the data through a custom write routine, you must call
|
1463
|
+
a custom read routine to read in the data. To do this, iterate over
|
1464
|
+
the <tt>sparse_hash_map</tt> with an <tt>iterator</tt>; this operation
|
1465
|
+
is sensical because the metadata has already been set up. For each
|
1466
|
+
iterator item, you can read the key and value from disk, and set it
|
1467
|
+
appropriately. You will need to do a <tt>const_cast</tt> on the
|
1468
|
+
iterator, since <tt>it->first</tt> is always <tt>const</tt>. You
|
1469
|
+
will also need to use placement-new if the key or value is a C++
|
1470
|
+
object. The code might look like this:</p>
|
1471
|
+
<pre>
|
1472
|
+
for (sparse_hash_map<int*, ComplicatedClass>::iterator it = ht.begin();
|
1473
|
+
it != ht.end(); ++it) {
|
1474
|
+
// The key is stored in the sparse_hash_map as a pointer
|
1475
|
+
const_cast<int*>(it->first) = new int;
|
1476
|
+
fread(const_cast<int*>(it->first), sizeof(int), 1, fp);
|
1477
|
+
// The value is a complicated C++ class that takes an int to construct
|
1478
|
+
int ctor_arg;
|
1479
|
+
fread(&ctor_arg, sizeof(int), 1, fp);
|
1480
|
+
new (&it->second) ComplicatedClass(ctor_arg); // "placement new"
|
1481
|
+
}
|
1482
|
+
</pre>
|
1483
|
+
|
1484
|
+
|
1485
|
+
<h3><A NAME=iter>Validity of Iterators</A></h3>
|
1486
|
+
|
1487
|
+
<p><tt>erase()</tt> is guaranteed not to invalidate any iterators --
|
1488
|
+
except for any iterators pointing to the item being erased, of course.
|
1489
|
+
<tt>insert()</tt> invalidates all iterators, as does
|
1490
|
+
<tt>resize()</tt>. </p>
|
1491
|
+
|
1492
|
+
<p>This is implemented by making <tt>erase()</tt> not resize the
|
1493
|
+
hashtable. If you desire maximum space efficiency, you can call
|
1494
|
+
<tt>resize(0)</tt> after a string of <tt>erase()</tt> calls, to force
|
1495
|
+
the hashtable to resize to the smallest possible size.</p>
|
1496
|
+
|
1497
|
+
<p>In addition to invalidating iterators, <tt>insert()</tt>
|
1498
|
+
and <tt>resize()</tt> invalidate all pointers into the hashtable. If
|
1499
|
+
you want to store a pointer to an object held in a sparse_hash_map,
|
1500
|
+
either do so after finishing hashtable inserts, or store the object on
|
1501
|
+
the heap and a pointer to it in the sparse_hash_map.</p>
|
1502
|
+
|
1503
|
+
|
1504
|
+
<h3>See also</h3>
|
1505
|
+
|
1506
|
+
<p>The following are SGI STL, and some Google STL, concepts and
|
1507
|
+
classes related to <tt>sparse_hash_map</tt>.</p>
|
1508
|
+
|
1509
|
+
<tt><A href="http://www.sgi.com/tech/stl/hash_map.html">hash_map</A></tt>,
|
1510
|
+
<A href="http://www.sgi.com/tech/stl/AssociativeContainer.html">Associative Container</A>,
|
1511
|
+
<A href="http://www.sgi.com/tech/stl/HashedAssociativeContainer.html">Hashed Associative Container</A>,
|
1512
|
+
<A href="http://www.sgi.com/tech/stl/PairAssociativeContainer.html">Pair Associative Container</A>,
|
1513
|
+
<A href="http://www.sgi.com/tech/stl/UniqueHashedAssociativeContainer.html">Unique Hashed Associative Container</A>,
|
1514
|
+
<tt><A href="http://www.sgi.com/tech/stl/set.html">set</A></tt>,
|
1515
|
+
<tt><A href="http://www.sgi.com/tech/stl/Map.html">map</A></tt>
|
1516
|
+
<tt><A href="http://www.sgi.com/tech/stl/multiset.html">multiset</A></tt>,
|
1517
|
+
<tt><A href="http://www.sgi.com/tech/stl/Multimap.html">multimap</A></tt>,
|
1518
|
+
<tt><A href="http://www.sgi.com/tech/stl/hash_set.html">hash_set</A></tt>,
|
1519
|
+
<tt><A href="http://www.sgi.com/tech/stl/hash_multiset.html">hash_multiset</A></tt>,
|
1520
|
+
<tt><A href="http://www.sgi.com/tech/stl/hash_multimap.html">hash_multimap</A></tt>,
|
1521
|
+
<tt><A href="sparsetable.html">sparsetable</A></tt>,
|
1522
|
+
<tt><A href="sparse_hash_set.html">sparse_hash_set</A></tt>,
|
1523
|
+
<tt><A href="dense_hash_set.html">dense_hash_set</A></tt>,
|
1524
|
+
<tt><A href="dense_hash_map.html">dense_hash_map</A></tt>
|
1525
|
+
|
1526
|
+
</BODY>
|
1527
|
+
</HTML>
|