Rudiments

dictionary.h
1 // Copyright (c) 1999-2018 David Muse
2 // See the COPYING file for more information.
3
4 #ifndef RUDIMENTS_DICTIONARY_H
5 #define RUDIMENTS_DICTIONARY_H
6
7 #include <rudiments/private/dictionaryincludes.h>
8
11 template <class keytype, class valuetype>
12 class dictionarynode {
13 public:
16 dictionarynode(keytype key, valuetype value);
17
21 virtual ~dictionarynode();
22
24 void setKey(keytype key);
25
27 void setValue(valuetype value);
28
30 keytype getKey() const;
31
33 valuetype getValue() const;
34
38 int32_t compare(keytype testkey) const;
39
43 int32_t compare(
44 dictionarynode<keytype,valuetype> *testnode) const;
45
48 void print() const;
49
50 #include <rudiments/private/dictionarynode.h>
51 };
52
62 template <class keytype, class valuetype>
63 class dictionary {
64 public:
66 dictionary();
67
78 dictionary(bool trackinsertionorder);
79
84 virtual ~dictionary();
85
106 bool setTrackInsertionOrder(bool trackinsertionorder);
107
110 bool getTrackInsertionOrder();
111
115 void setValue(keytype key, valuetype value);
116
122 void setValues(keytype *keys, valuetype *values);
123 void setValues(keytype const *keys, valuetype const *values);
124
130 void setValues(keytype *keys, valuetype *values,
131 uint64_t count);
132 void setValues(keytype const *keys, valuetype const *values,
133 uint64_t count);
134
139 void setValues(dictionary< keytype, valuetype > *dict);
140
144 bool getValue(keytype key, valuetype *value);
145
148 dictionarynode<keytype,valuetype> *getNode(keytype key);
149
154 valuetype getValue(keytype key);
155
159 bool remove(keytype key);
160
165 bool removeAndDelete(keytype key);
166
172 bool removeAndArrayDelete(keytype key);
173
178 bool removeAndDeleteKey(keytype key);
179
185 bool removeAndArrayDeleteKey(keytype key);
186
191 bool removeAndDeleteValue(keytype key);
192
198 bool removeAndArrayDeleteValue(keytype key);
199
203 bool removeAndDeleteKeyAndArrayDeleteValue(keytype key);
204
208 bool removeAndArrayDeleteKeyAndDeleteValue(keytype key);
209
212 bool remove(dictionarynode<keytype,valuetype> *node);
213
218 bool removeAndDelete(
219 dictionarynode<keytype,valuetype> *node);
220
226 bool removeAndArrayDelete(
227 dictionarynode<keytype,valuetype> *node);
228
233 bool removeAndDeleteKey(
234 dictionarynode<keytype,valuetype> *node);
235
241 bool removeAndArrayDeleteKey(
242 dictionarynode<keytype,valuetype> *node);
243
248 bool removeAndDeleteValue(
249 dictionarynode<keytype,valuetype> *node);
250
256 bool removeAndArrayDeleteValue(
257 dictionarynode<keytype,valuetype> *node);
258
262 bool removeAndDeleteKeyAndArrayDeleteValue(
263 dictionarynode<keytype,valuetype> *node);
264
268 bool removeAndArrayDeleteKeyAndDeleteValue(
269 dictionarynode<keytype,valuetype> *node);
270
276 linkedlist<keytype> *getKeys();
277
279 avltree< dictionarynode<keytype,valuetype> *> *getTree();
280
282 linkedlist< dictionarynode<keytype,valuetype> *> *getList();
283
287 void clear();
288
292 void clearAndDelete();
293
297 void clearAndArrayDelete();
298
302 void clearAndDeleteKeys();
303
307 void clearAndArrayDeleteKeys();
308
312 void clearAndDeleteValues();
313
317 void clearAndArrayDeleteValues();
318
322 void clearAndDeleteKeysAndArrayDeleteValues();
323
327 void clearAndArrayDeleteKeysAndDeleteValues();
328
330 void print();
331
332 #include <rudiments/private/dictionary.h>
333 };
334
335
336 // ideally I'd use typdefs for these but older compilers can't handle them
337 #define namevaluepairsnode dictionarynode< char *, char * >
338 #define namevaluepairs dictionary< char *, char * >
339 #define constnamevaluepairsnode dictionarynode< const char *, const char * >
340 #define constnamevaluepairs dictionary< const char *, const char * >
341
342 #include <rudiments/private/dictionaryinlines.h>
343
344 #endif
avltree
Definition: avltree.h:77
dictionary
Definition: dictionary.h:63
dictionary::removeAndDeleteKey
bool removeAndDeleteKey(dictionarynode< keytype, valuetype > *node)
dictionary::getTrackInsertionOrder
bool getTrackInsertionOrder()
dictionary::remove
bool remove(dictionarynode< keytype, valuetype > *node)
dictionary::removeAndArrayDeleteKey
bool removeAndArrayDeleteKey(dictionarynode< keytype, valuetype > *node)
dictionary::setTrackInsertionOrder
bool setTrackInsertionOrder(bool trackinsertionorder)
dictionary::removeAndDelete
bool removeAndDelete(keytype key)
dictionary::removeAndArrayDeleteKeyAndDeleteValue
bool removeAndArrayDeleteKeyAndDeleteValue(dictionarynode< keytype, valuetype > *node)
dictionary::removeAndDelete
bool removeAndDelete(dictionarynode< keytype, valuetype > *node)
dictionary::print
void print()
dictionary::clearAndDelete
void clearAndDelete()
dictionary::dictionary
dictionary(bool trackinsertionorder)
dictionary::clear
void clear()
dictionary::getValue
bool getValue(keytype key, valuetype *value)
dictionary::clearAndArrayDeleteKeysAndDeleteValues
void clearAndArrayDeleteKeysAndDeleteValues()
dictionary::clearAndArrayDelete
void clearAndArrayDelete()
dictionary::removeAndArrayDeleteKey
bool removeAndArrayDeleteKey(keytype key)
dictionary::getValue
valuetype getValue(keytype key)
dictionary::removeAndArrayDeleteKeyAndDeleteValue
bool removeAndArrayDeleteKeyAndDeleteValue(keytype key)
dictionary::removeAndArrayDeleteValue
bool removeAndArrayDeleteValue(dictionarynode< keytype, valuetype > *node)
dictionary::setValues
void setValues(keytype *keys, valuetype *values, uint64_t count)
dictionary::removeAndDeleteValue
bool removeAndDeleteValue(keytype key)
dictionary::setValues
void setValues(dictionary< keytype, valuetype > *dict)
dictionary::removeAndArrayDelete
bool removeAndArrayDelete(dictionarynode< keytype, valuetype > *node)
dictionary::removeAndDeleteValue
bool removeAndDeleteValue(dictionarynode< keytype, valuetype > *node)
dictionary::getKeys
linkedlist< keytype > * getKeys()
dictionary::removeAndDeleteKeyAndArrayDeleteValue
bool removeAndDeleteKeyAndArrayDeleteValue(keytype key)
dictionary::removeAndArrayDeleteValue
bool removeAndArrayDeleteValue(keytype key)
dictionary::clearAndArrayDeleteKeys
void clearAndArrayDeleteKeys()
dictionary::~dictionary
virtual ~dictionary()
dictionary::setValue
void setValue(keytype key, valuetype value)
dictionary::getNode
dictionarynode< keytype, valuetype > * getNode(keytype key)
dictionary::getList
linkedlist< dictionarynode< keytype, valuetype > * > * getList()
dictionary::removeAndDeleteKey
bool removeAndDeleteKey(keytype key)
dictionary::clearAndDeleteValues
void clearAndDeleteValues()
dictionary::setValues
void setValues(keytype *keys, valuetype *values)
dictionary::clearAndDeleteKeys
void clearAndDeleteKeys()
dictionary::getTree
avltree< dictionarynode< keytype, valuetype > * > * getTree()
dictionary::clearAndArrayDeleteValues
void clearAndArrayDeleteValues()
dictionary::clearAndDeleteKeysAndArrayDeleteValues
void clearAndDeleteKeysAndArrayDeleteValues()
dictionary::removeAndDeleteKeyAndArrayDeleteValue
bool removeAndDeleteKeyAndArrayDeleteValue(dictionarynode< keytype, valuetype > *node)
dictionary::remove
bool remove(keytype key)
dictionary::dictionary
dictionary()
dictionary::removeAndArrayDelete
bool removeAndArrayDelete(keytype key)
dictionarynode
Definition: dictionary.h:12
dictionarynode::print
void print() const
dictionarynode::compare
int32_t compare(keytype testkey) const
dictionarynode::~dictionarynode
virtual ~dictionarynode()
dictionarynode::getValue
valuetype getValue() const
dictionarynode::compare
int32_t compare(dictionarynode< keytype, valuetype > *testnode) const
dictionarynode::getKey
keytype getKey() const
dictionarynode::setValue
void setValue(valuetype value)
dictionarynode::dictionarynode
dictionarynode(keytype key, valuetype value)
dictionarynode::setKey
void setKey(keytype key)
linkedlist
Definition: linkedlist.h:60