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 
42  void print() const;
43 
44  #include <rudiments/private/dictionarynode.h>
45 };
46 
56 template <class keytype, class valuetype>
57 class dictionary {
58  public:
60  dictionary();
61 
66  virtual ~dictionary();
67 
71  void setValue(keytype key, valuetype value);
72 
76  bool getValue(keytype key, valuetype *value);
77 
80  dictionarynode<keytype,valuetype> *getNode(keytype key);
81 
86  valuetype getValue(keytype key);
87 
91  bool remove(keytype key);
92 
96  dictionarynode<keytype,valuetype> *detach(keytype key);
97 
103  linkedlist< keytype > *getKeys();
104 
107 
109  void clear();
110 
112  void print();
113 
114  #include <rudiments/private/dictionary.h>
115 };
116 
117 
118 // ideally I'd use typdefs for these but older compilers can't handle them
119 #define namevaluepairsnode dictionarynode< char *, char * >
120 #define namevaluepairs dictionary< char *, char * >
121 #define constnamevaluepairsnode dictionarynode< const char *, const char * >
122 #define constnamevaluepairs dictionary< const char *, const char * >
123 
124 #include <rudiments/private/dictionaryinlines.h>
125 
126 #endif
void print() const
void setValue(valuetype value)
Definition: linkedlist.h:60
Definition: dictionary.h:12
int32_t compare(keytype testkey) const
virtual ~dictionarynode()
Definition: dictionary.h:57
void setKey(keytype key)
dictionarynode(keytype key, valuetype value)
keytype getKey() const
valuetype getValue() const