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 
120  bool getValue(keytype key, valuetype *value);
121 
124  dictionarynode<keytype,valuetype> *getNode(keytype key);
125 
130  valuetype getValue(keytype key);
131 
135  bool remove(keytype key);
136 
139  bool remove(dictionarynode<keytype,valuetype> *node);
140 
146  linkedlist<keytype> *getKeys();
147 
150 
153 
155  void clear();
156 
158  void print();
159 
160  #include <rudiments/private/dictionary.h>
161 };
162 
163 
164 // ideally I'd use typdefs for these but older compilers can't handle them
165 #define namevaluepairsnode dictionarynode< char *, char * >
166 #define namevaluepairs dictionary< char *, char * >
167 #define constnamevaluepairsnode dictionarynode< const char *, const char * >
168 #define constnamevaluepairs dictionary< const char *, const char * >
169 
170 #include <rudiments/private/dictionaryinlines.h>
171 
172 #endif
void print() const
Definition: avltree.h:77
void setValue(valuetype value)
Definition: linkedlist.h:60
Definition: dictionary.h:12
int32_t compare(keytype testkey) const
virtual ~dictionarynode()
Definition: dictionary.h:63
void setKey(keytype key)
dictionarynode(keytype key, valuetype value)
keytype getKey() const
valuetype getValue() const