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 
81  bool removeValue(keytype key);
82 
85 
87  void clear();
88 
90  void print();
91 
92  #include <rudiments/private/dictionary.h>
93 };
94 
95 
96 // ideally I'd use typdefs for these but older compilers can't handle them
97 #define namevaluepairsnode dictionarynode< char *, char * >
98 #define namevaluepairs dictionary< char *, char * >
99 #define constnamevaluepairsnode dictionarynode< const char *, const char * >
100 #define constnamevaluepairs dictionary< const char *, const char * >
101 
102 #include <rudiments/private/dictionaryinlines.h>
103 
104 #endif