Rudiments
dictionary.h
1 // Copyright (c) 2003 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:
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 
163  bool remove(dictionarynode<keytype,valuetype> *node);
164 
170  linkedlist<keytype> *getKeys();
171 
174 
177 
181  void clear();
182 
186  void clearAndDelete();
187 
191  void clearAndArrayDelete();
192 
196  void clearAndDeleteKeys();
197 
201  void clearAndArrayDeleteKeys();
202 
206  void clearAndDeleteValues();
207 
211  void clearAndArrayDeleteValues();
212 
216  void clearAndDeleteKeysAndArrayDeleteValues();
217 
221  void clearAndArrayDeleteKeysAndDeleteValues();
222 
224  void print();
225 
226  #include <rudiments/private/dictionary.h>
227 };
228 
229 
230 // ideally I'd use typdefs for these but older compilers can't handle them
231 #define namevaluepairsnode dictionarynode< char *, char * >
232 #define namevaluepairs dictionary< char *, char * >
233 #define constnamevaluepairsnode dictionarynode< const char *, const char * >
234 #define constnamevaluepairs dictionary< const char *, const char * >
235 
236 #include <rudiments/private/dictionaryinlines.h>
237 
238 #endif
void print() const
valuetype getValue() const
Definition: avltree.h:77
void setValue(valuetype value)
Definition: linkedlist.h:60
Definition: dictionary.h:12
virtual ~dictionarynode()
Definition: dictionary.h:63
int32_t compare(keytype testkey) const
void setKey(keytype key)
dictionarynode(keytype key, valuetype value)
keytype getKey() const