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 
179  void clear();
180 
182  void print();
183 
184  #include <rudiments/private/dictionary.h>
185 };
186 
187 
188 // ideally I'd use typdefs for these but older compilers can't handle them
189 #define namevaluepairsnode dictionarynode< char *, char * >
190 #define namevaluepairs dictionary< char *, char * >
191 #define constnamevaluepairsnode dictionarynode< const char *, const char * >
192 #define constnamevaluepairs dictionary< const char *, const char * >
193 
194 #include <rudiments/private/dictionaryinlines.h>
195 
196 #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