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>
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:
67 
78  dictionary(bool trackinsertionorder);
79 
84  virtual ~dictionary();
85 
106  bool setTrackInsertionOrder(bool trackinsertionorder);
107 
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 
140 
144  bool getValue(keytype key, valuetype *value);
145 
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 
204 
209 
213 
220 
228 
235 
243 
250 
258 
264 
270 
277 
280 
283 
287  void clear();
288 
293 
298 
303 
308 
313 
318 
323 
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
Definition: avltree.h:77
Definition: dictionary.h:63
bool removeAndDeleteKey(dictionarynode< keytype, valuetype > *node)
bool getTrackInsertionOrder()
bool remove(dictionarynode< keytype, valuetype > *node)
bool removeAndArrayDeleteKey(dictionarynode< keytype, valuetype > *node)
bool setTrackInsertionOrder(bool trackinsertionorder)
bool removeAndDelete(keytype key)
bool removeAndArrayDeleteKeyAndDeleteValue(dictionarynode< keytype, valuetype > *node)
bool removeAndDelete(dictionarynode< keytype, valuetype > *node)
void print()
void clearAndDelete()
dictionary(bool trackinsertionorder)
void clear()
bool getValue(keytype key, valuetype *value)
void clearAndArrayDeleteKeysAndDeleteValues()
void clearAndArrayDelete()
bool removeAndArrayDeleteKey(keytype key)
valuetype getValue(keytype key)
bool removeAndArrayDeleteKeyAndDeleteValue(keytype key)
bool removeAndArrayDeleteValue(dictionarynode< keytype, valuetype > *node)
void setValues(keytype *keys, valuetype *values, uint64_t count)
bool removeAndDeleteValue(keytype key)
void setValues(dictionary< keytype, valuetype > *dict)
bool removeAndArrayDelete(dictionarynode< keytype, valuetype > *node)
bool removeAndDeleteValue(dictionarynode< keytype, valuetype > *node)
linkedlist< keytype > * getKeys()
bool removeAndDeleteKeyAndArrayDeleteValue(keytype key)
bool removeAndArrayDeleteValue(keytype key)
void clearAndArrayDeleteKeys()
virtual ~dictionary()
void setValue(keytype key, valuetype value)
dictionarynode< keytype, valuetype > * getNode(keytype key)
linkedlist< dictionarynode< keytype, valuetype > * > * getList()
bool removeAndDeleteKey(keytype key)
void clearAndDeleteValues()
void setValues(keytype *keys, valuetype *values)
void clearAndDeleteKeys()
avltree< dictionarynode< keytype, valuetype > * > * getTree()
void clearAndArrayDeleteValues()
void clearAndDeleteKeysAndArrayDeleteValues()
bool removeAndDeleteKeyAndArrayDeleteValue(dictionarynode< keytype, valuetype > *node)
bool remove(keytype key)
bool removeAndArrayDelete(keytype key)
Definition: dictionary.h:12
void print() const
int32_t compare(keytype testkey) const
virtual ~dictionarynode()
valuetype getValue() const
int32_t compare(dictionarynode< keytype, valuetype > *testnode) const
keytype getKey() const
void setValue(valuetype value)
dictionarynode(keytype key, valuetype value)
void setKey(keytype key)
Definition: linkedlist.h:60