-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnode14.html
More file actions
208 lines (202 loc) · 6.75 KB
/
Copy pathnode14.html
File metadata and controls
208 lines (202 loc) · 6.75 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!--Converted with LaTeX2HTML 98.1p1 release (March 2nd, 1998)
originally by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds
* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>omap</TITLE>
<META NAME="description" CONTENT="omap">
<META NAME="keywords" CONTENT="graphcode">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<LINK REL="STYLESHEET" HREF="graphcode.css">
<LINK REL="next" HREF="node16.html">
<LINK REL="previous" HREF="node13.html">
<LINK REL="up" HREF="graphcode.html">
<LINK REL="next" HREF="node15.html">
</HEAD>
<BODY >
<!--Navigation Panel-->
<A NAME="tex2html178"
HREF="node15.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next"
SRC="/usr/local/lib/latex2html/icons.gif/next_motif.gif"></A>
<A NAME="tex2html175"
HREF="graphcode.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
SRC="/usr/local/lib/latex2html/icons.gif/up_motif.gif"></A>
<A NAME="tex2html169"
HREF="node13.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
SRC="/usr/local/lib/latex2html/icons.gif/previous_motif.gif"></A>
<A NAME="tex2html177"
HREF="node19.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index"
SRC="/usr/local/lib/latex2html/icons.gif/index_motif.gif"></A>
<BR>
<B> Next:</B> <A NAME="tex2html179"
HREF="node15.html">Note on using macros</A>
<B> Up:</B> <A NAME="tex2html176"
HREF="graphcode.html">Graphcode Documentation</A>
<B> Previous:</B> <A NAME="tex2html170"
HREF="node13.html">Ptrlist</A>
<BR>
<BR>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION00060000000000000000"> </A><A NAME="122"> </A><A NAME="omap"> </A>
<BR>
omap
</H1>
<P>
An omap is a container for storing <EM>objrefs</EM>
§(<A HREF="node12.html#objref">3</A>)<A NAME="128"> </A>, indexed by ID.
<P>
<PRE>
class omap: public MAP
{
public:
objref& operator[](GraphID_t i);
omap& operator=(omap& x);
};
</PRE>
<P>
There are a few different possible ways of implementing omaps, with
differing performance characteristics. Graphcode provides two
different models, <EM>vmap</EM> and <EM>hmap</EM> that may be readily
deployed by the user, however users can fairly easily provide their
own implementation if desired. Different implementations can be
selected by defining the <code>MAP</code> macro<A NAME="133"> </A> to be the desired
omap implementation before including <code>graphcode.h</code>. This will
declare everything in the namespace
<code>graphcode_vmap</code><A NAME="134"> </A> or
<code>graphcode_hmap</code><A NAME="135"> </A> as appropriate. Using
this scheme, it is possible to have two different omap types in the
one object file, by including graphcode.h twice. However, if you do
this, you will need to <code>#undef GRAPHCODE_H</code> guard variable prior
to subsequent includes.
<P>
vmap is intended for use with contiguous GraphID ranges. If there are
holes in the identifier range, then the iterator will return invalid
references for these holes, and the size() method will be incorrect.
<P>
If you need to have non-contiguous ID ranges (perhaps for dynamic
graph management -- note this is not currently supported), then please
use the hmap<A NAME="136"> </A> implementation instead (which will have some performance
penalty).
<P>
MAP must provide the following members:
<PRE>
class MAP
{
protected:
objref& at(GraphID_t i);
public:
MAP();
MAP(const MAP&)
class iterator
{
iterator();
iterator(const iterator&);
iterator& operator=(const iterator&);
iterator operator++(int);
iterator operator++();
iterator operator--(int);
iterator operator--();
bool operator==(const iterator& x) const;
bool operator!=(const iterator& x) const;
objref& operator*();
objref* operator->();
};
iterator begin();
iterator end();
unsigned size();
}
</PRE>
The <code>at</code><A NAME="139"> </A> method is essentially a replacement for <code>operator[]()</code>. A
simple example of an omap implementation is provided by <code>vmap</code><A NAME="140"> </A>:
<PRE>
class vmap: public std::vector<objref>
{
protected:
objref& at(GraphID_t i)
{
if (i>=size()) resize(i+1);
return std::vector<objref>::operator[](i);
}
};
</PRE>
<P>
hmap is a hash map implementation. With all hash maps, performance of
the map is critically dependent upon the choice of hash function, which
is application dependent. hmap is simply defined as:
<PRE>
class hmap: public hashmap<simple_hash> {};
</PRE>You can provide your own omap definition (umap, say), with your own
user defined hash function in the following way:
<DL COMPACT>
<DT>1.
<DD>Create a file ``umap'' somewhere in the default search path with
the following:
<PRE>
#include "hashmap.h"
struct myhash
{
unsigned operator()(GraphID_t i) {...}
};
class umap: public hashmap<myhash> {};
</PRE><DT>2.
<DD>Add the new omap definitions to the Graphcode library:
<PRE>
make MAP=umap
</PRE><DT>3.
<DD>Include the declarations of the <code>graphcode_umap</code> namespace
in your application source file:
<PRE>
#define MAP umap
#undef GRAPHCODE_H
#include <graphcode.h>
</PRE></DL>
<P>
<BR><HR>
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"> </A>
<UL>
<LI><A NAME="tex2html180"
HREF="node15.html">Note on using macros to parametrise omap</A>
</UL>
<!--End of Table of Child-Links-->
<HR>
<!--Navigation Panel-->
<A NAME="tex2html178"
HREF="node15.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next"
SRC="/usr/local/lib/latex2html/icons.gif/next_motif.gif"></A>
<A NAME="tex2html175"
HREF="graphcode.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
SRC="/usr/local/lib/latex2html/icons.gif/up_motif.gif"></A>
<A NAME="tex2html169"
HREF="node13.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
SRC="/usr/local/lib/latex2html/icons.gif/previous_motif.gif"></A>
<A NAME="tex2html177"
HREF="node19.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index"
SRC="/usr/local/lib/latex2html/icons.gif/index_motif.gif"></A>
<BR>
<B> Next:</B> <A NAME="tex2html179"
HREF="node15.html">Note on using macros</A>
<B> Up:</B> <A NAME="tex2html176"
HREF="graphcode.html">Graphcode Documentation</A>
<B> Previous:</B> <A NAME="tex2html170"
HREF="node13.html">Ptrlist</A>
<!--End of Navigation Panel-->
<ADDRESS>
<I>Russell Standish</I>
<BR><I>2007-03-13</I>
</ADDRESS>
</BODY>
</HTML>