Rudiments: /home/dmuse/src/rudiments/include/rudiments/dictionary.h Source File

Rudiments

- Main Page
- Classes

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>
12 class dictionarynode {
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
106 linkedlist< dictionarynode<keytype,valuetype> *> *getList();
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
dictionary::clear
void clear()
dictionarynode::print
void print() const
dictionarynode::setValue
void setValue(valuetype value)
dictionary::getKeys
linkedlist< keytype > * getKeys()
linkedlist
Definition: linkedlist.h:60
dictionarynode
Definition: dictionary.h:12
dictionarynode::compare
int32_t compare(keytype testkey) const
dictionary::getValue
bool getValue(keytype key, valuetype *value)
dictionarynode::~dictionarynode
virtual ~dictionarynode()
dictionary
Definition: dictionary.h:57
dictionary::dictionary
dictionary()
dictionary::getList
linkedlist< dictionarynode< keytype, valuetype > * > * getList()
dictionary::detach
dictionarynode< keytype, valuetype > * detach(keytype key)
dictionarynode::setKey
void setKey(keytype key)
dictionary::print
void print()
dictionary::setValue
void setValue(keytype key, valuetype value)
dictionarynode::dictionarynode
dictionarynode(keytype key, valuetype value)
dictionarynode::getKey
keytype getKey() const
dictionary::getNode
dictionarynode< keytype, valuetype > * getNode(keytype key)
dictionary::~dictionary
virtual ~dictionary()
dictionarynode::getValue
valuetype getValue() const