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 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
|
<html>
<head>
<title>~/src/firstworks/rudiments-0.31/include/rudiments/dictionary.h.html</title>
<meta name="Generator" content="Vim/7.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body bgcolor="#ffffff" text="#000000">
<pre>
<font color="#0000ff">// Copyright (c) 2003 David Muse</font>
<font color="#0000ff">// See the COPYING file for more information.</font>
<font color="#a020f0">#ifndef RUDIMENTS_DICTIONARY_H</font>
<font color="#a020f0">#define RUDIMENTS_DICTIONARY_H</font>
<font color="#a020f0">#include </font><font color="#ff00ff"><rudiments/private/dictionaryincludes.h></font>
<font color="#0000ff">// The dictionary class allows you to store arbitrary numbers of key/value</font>
<font color="#0000ff">// pairs. Since the dictionary class is template-based, you can store</font>
<font color="#0000ff">// arbitrary types of keys and values.</font>
<font color="#0000ff">//</font>
<font color="#0000ff">// Each dictionary is composed of a list of dictionarynode's. Each</font>
<font color="#0000ff">// dictionarynode contains the key and value.</font>
<font color="#a020f0">#ifdef RUDIMENTS_NAMESPACE</font>
<font color="#2e8b57"><b>namespace</b></font> rudiments {
<font color="#a020f0">#endif</font>
<font color="#2e8b57"><b>template</b></font> <<font color="#2e8b57"><b>class</b></font> keytype, <font color="#2e8b57"><b>class</b></font> datatype>
<font color="#2e8b57"><b>class</b></font> dictionarynode {
<font color="#a52a2a"><b>public</b></font>:
dictionarynode();
<font color="#0000ff">// Creates a new dictionary node, initializing the</font>
<font color="#0000ff">// key and data to 0.</font>
<font color="#2e8b57"><b>virtual</b></font> ~dictionarynode();
<font color="#2e8b57"><b>void</b></font> setKey(keytype key);
<font color="#0000ff">// Sets the key stored in the node to "key".</font>
<font color="#2e8b57"><b>void</b></font> setData(datatype data);
<font color="#0000ff">// Sets the data stored in the node to "data".</font>
keytype getKey() <font color="#2e8b57"><b>const</b></font>;
<font color="#0000ff">// Returns the key stored in the node.</font>
datatype getData() <font color="#2e8b57"><b>const</b></font>;
<font color="#0000ff">// Returns the data stored in the node.</font>
<font color="#2e8b57"><b>int</b></font> compare(keytype testkey) <font color="#2e8b57"><b>const</b></font>;
<font color="#0000ff">// Returns -1,0 or 1 if the key stored in the</font>
<font color="#0000ff">// node is less than, equal to or greater than</font>
<font color="#0000ff">// "testkey".</font>
<font color="#2e8b57"><b>void</b></font> print() <font color="#2e8b57"><b>const</b></font>;
<font color="#0000ff">// Prints the key and data stored in the node.</font>
<font color="#a020f0"> #include </font><font color="#ff00ff"><rudiments/private/dictionarynode.h></font>
};
<font color="#2e8b57"><b>template</b></font> <<font color="#2e8b57"><b>class</b></font> keytype, <font color="#2e8b57"><b>class</b></font> datatype>
<font color="#2e8b57"><b>class</b></font> dictionarylistnode :
<font color="#a52a2a"><b>public</b></font> linkedlistnode< dictionarynode<keytype,datatype> * > {};
<font color="#2e8b57"><b>template</b></font> <<font color="#2e8b57"><b>class</b></font> keytype, <font color="#2e8b57"><b>class</b></font> datatype>
<font color="#2e8b57"><b>class</b></font> dictionarylist :
<font color="#a52a2a"><b>public</b></font> linkedlist< dictionarynode<keytype,datatype> *,
dictionarylistnode<keytype,datatype> > {};
<font color="#2e8b57"><b>template</b></font> <<font color="#2e8b57"><b>class</b></font> keytype, <font color="#2e8b57"><b>class</b></font> datatype,
<font color="#2e8b57"><b>class</b></font> dictionarynodetype=dictionarynode<keytype,datatype>,
<font color="#2e8b57"><b>class</b></font> dictionarylistnodetype=dictionarylistnode<keytype,datatype>,
<font color="#2e8b57"><b>class</b></font> dictionarylisttype=dictionarylist<keytype,datatype> >
<font color="#2e8b57"><b>class</b></font> dictionary {
<font color="#a52a2a"><b>public</b></font>:
dictionary();
<font color="#0000ff">// Creates an empty dictionary</font>
<font color="#2e8b57"><b>virtual</b></font> ~dictionary();
<font color="#0000ff">// Deletes the dictionary and all of it's</font>
<font color="#0000ff">// dictionarynodes.</font>
<font color="#2e8b57"><b>void</b></font> setData(keytype key, datatype data);
<font color="#0000ff">// Sets the data associated with "key" to "data".</font>
<font color="#0000ff">// If "key" already exists, the data currently</font>
<font color="#0000ff">// accociated with it is replaced with "data".</font>
<font color="#2e8b57"><b>bool</b></font> getData(keytype key, datatype *data);
<font color="#0000ff">// Sets "data" to the data associated with "key".</font>
<font color="#0000ff">// Returns true on success or false if "key" wasn't</font>
<font color="#0000ff">// found.</font>
<font color="#2e8b57"><b>bool</b></font> removeData(keytype key);
<font color="#0000ff">// Removes the dictionarynode with "key".</font>
<font color="#0000ff">// Returns true on success or false if "key" wasn't</font>
<font color="#0000ff">// found.</font>
dictionarylisttype *getList();
<font color="#0000ff">// Returns the list used internally.</font>
<font color="#2e8b57"><b>void</b></font> clear();
<font color="#0000ff">// Deletes all dictionarynodes currently in the</font>
<font color="#0000ff">// dictionary.</font>
<font color="#2e8b57"><b>void</b></font> print();
<font color="#0000ff">// Prints out a representation of the dictionary.</font>
<font color="#a020f0"> #include </font><font color="#ff00ff"><rudiments/private/dictionary.h></font>
};
<font color="#0000ff">// A set of classes for storing dictionaries who's keys are strings are</font>
<font color="#0000ff">// provided here for convenience.</font>
<font color="#2e8b57"><b>template</b></font> <<font color="#2e8b57"><b>class</b></font> datatype>
<font color="#2e8b57"><b>class</b></font> stringdictionarynode :
<font color="#a52a2a"><b>public</b></font> dictionarynode< <font color="#2e8b57"><b>char</b></font> *,datatype > {
<font color="#a52a2a"><b>public</b></font>:
<font color="#2e8b57"><b>virtual</b></font> ~stringdictionarynode();
};
<font color="#2e8b57"><b>template</b></font> <<font color="#2e8b57"><b>class</b></font> datatype>
<font color="#2e8b57"><b>class</b></font> stringdictionarylistnode :
<font color="#a52a2a"><b>public</b></font> dictionarylistnode< <font color="#2e8b57"><b>char</b></font> *, datatype > {
<font color="#a52a2a"><b>public</b></font>:
<font color="#2e8b57"><b>virtual</b></font> ~stringdictionarylistnode();
};
<font color="#2e8b57"><b>template</b></font> <<font color="#2e8b57"><b>class</b></font> datatype>
<font color="#2e8b57"><b>class</b></font> stringdictionarylist : <font color="#a52a2a"><b>public</b></font> dictionarylist< <font color="#2e8b57"><b>char</b></font> *, datatype > {
<font color="#a52a2a"><b>public</b></font>:
<font color="#2e8b57"><b>virtual</b></font> ~stringdictionarylist();
};
<font color="#2e8b57"><b>template</b></font> <<font color="#2e8b57"><b>class</b></font> datatype>
<font color="#2e8b57"><b>class</b></font> stringdictionary : <font color="#a52a2a"><b>public</b></font> dictionary< <font color="#2e8b57"><b>char</b></font> *, datatype,
stringdictionarynode<datatype>,
stringdictionarylistnode<datatype>,
stringdictionarylist<datatype> > {
<font color="#a52a2a"><b>public</b></font>:
<font color="#2e8b57"><b>virtual</b></font> ~stringdictionary();
};
<font color="#0000ff">// A set of classes for storing dictionaries who's keys are const strings are</font>
<font color="#0000ff">// provided here for convenience.</font>
<font color="#2e8b57"><b>template</b></font> <<font color="#2e8b57"><b>class</b></font> datatype>
<font color="#2e8b57"><b>class</b></font> conststringdictionarynode :
<font color="#a52a2a"><b>public</b></font> dictionarynode< <font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *,datatype > {
<font color="#a52a2a"><b>public</b></font>:
<font color="#2e8b57"><b>virtual</b></font> ~conststringdictionarynode();
};
<font color="#2e8b57"><b>template</b></font> <<font color="#2e8b57"><b>class</b></font> datatype>
<font color="#2e8b57"><b>class</b></font> conststringdictionarylistnode :
<font color="#a52a2a"><b>public</b></font> dictionarylistnode< <font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *, datatype > {
<font color="#a52a2a"><b>public</b></font>:
<font color="#2e8b57"><b>virtual</b></font> ~conststringdictionarylistnode();
};
<font color="#2e8b57"><b>template</b></font> <<font color="#2e8b57"><b>class</b></font> datatype>
<font color="#2e8b57"><b>class</b></font> conststringdictionarylist :
<font color="#a52a2a"><b>public</b></font> dictionarylist< <font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *, datatype > {
<font color="#a52a2a"><b>public</b></font>:
<font color="#2e8b57"><b>virtual</b></font> ~conststringdictionarylist();
};
<font color="#2e8b57"><b>template</b></font> <<font color="#2e8b57"><b>class</b></font> datatype>
<font color="#2e8b57"><b>class</b></font> conststringdictionary : <font color="#a52a2a"><b>public</b></font> dictionary< <font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *, datatype,
conststringdictionarynode<datatype>,
conststringdictionarylistnode<datatype>,
conststringdictionarylist<datatype> > {
<font color="#a52a2a"><b>public</b></font>:
<font color="#2e8b57"><b>virtual</b></font> ~conststringdictionary();
};
<font color="#0000ff">// A set of classes for storing dictionaries who's keys are int32_t integers are</font>
<font color="#0000ff">// provided here for convenience.</font>
<font color="#2e8b57"><b>template</b></font> <<font color="#2e8b57"><b>class</b></font> datatype>
<font color="#2e8b57"><b>class</b></font> numericdictionarynode :
<font color="#a52a2a"><b>public</b></font> dictionarynode< <font color="#2e8b57"><b>int32_t</b></font>, datatype > {
<font color="#a52a2a"><b>public</b></font>:
<font color="#2e8b57"><b>virtual</b></font> ~numericdictionarynode();
};
<font color="#2e8b57"><b>template</b></font> <<font color="#2e8b57"><b>class</b></font> datatype>
<font color="#2e8b57"><b>class</b></font> numericdictionarylistnode :
<font color="#a52a2a"><b>public</b></font> dictionarylistnode< <font color="#2e8b57"><b>int32_t</b></font>, datatype > {
<font color="#a52a2a"><b>public</b></font>:
<font color="#2e8b57"><b>virtual</b></font> ~numericdictionarylistnode();
};
<font color="#2e8b57"><b>template</b></font> <<font color="#2e8b57"><b>class</b></font> datatype>
<font color="#2e8b57"><b>class</b></font> numericdictionarylist : <font color="#a52a2a"><b>public</b></font> dictionarylist< <font color="#2e8b57"><b>int32_t</b></font>, datatype > {
<font color="#a52a2a"><b>public</b></font>:
<font color="#2e8b57"><b>virtual</b></font> ~numericdictionarylist();
};
<font color="#2e8b57"><b>template</b></font> <<font color="#2e8b57"><b>class</b></font> datatype>
<font color="#2e8b57"><b>class</b></font> numericdictionary : <font color="#a52a2a"><b>public</b></font> dictionary< <font color="#2e8b57"><b>int32_t</b></font>, datatype,
numericdictionarynode<datatype>,
numericdictionarylistnode<datatype>,
numericdictionarylist<datatype> > {
<font color="#a52a2a"><b>public</b></font>:
<font color="#2e8b57"><b>virtual</b></font> ~numericdictionary();
};
<font color="#0000ff">// A set of classes for storing dictionaries who's keys and values are both</font>
<font color="#0000ff">// strings are provided here for convenience.</font>
<font color="#2e8b57"><b>typedef</b></font> stringdictionarynode< <font color="#2e8b57"><b>char</b></font> * > namevaluepairsnode;
<font color="#2e8b57"><b>typedef</b></font> stringdictionarylistnode< <font color="#2e8b57"><b>char</b></font> * > namevaluepairslistnode;
<font color="#2e8b57"><b>typedef</b></font> stringdictionarylist< <font color="#2e8b57"><b>char</b></font> * > namevaluepairslist;
<font color="#2e8b57"><b>typedef</b></font> stringdictionary< <font color="#2e8b57"><b>char</b></font> * > namevaluepairs;
<font color="#2e8b57"><b>typedef</b></font> conststringdictionarynode< <font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> * >
constnamevaluepairsnode;
<font color="#2e8b57"><b>typedef</b></font> conststringdictionarylistnode< <font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> * >
constnamevaluepairslistnode;
<font color="#2e8b57"><b>typedef</b></font> conststringdictionarylist< <font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> * >
constnamevaluepairslist;
<font color="#2e8b57"><b>typedef</b></font> conststringdictionary< <font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> * >
constnamevaluepairs;
<font color="#a020f0">#ifdef RUDIMENTS_NAMESPACE</font>
}
<font color="#a020f0">#endif</font>
<font color="#a020f0">#include </font><font color="#ff00ff"><rudiments/private/dictionarynodeinlines.h></font>
<font color="#a020f0">#include </font><font color="#ff00ff"><rudiments/private/dictionaryinlines.h></font>
<font color="#a020f0">#endif</font>
</pre>
</body>
</html>
|