4 #ifndef EXCLUDE_RUDIMENTS_TEMPLATE_IMPLEMENTATIONS
6 #ifdef RUDIMENTS_HAVE_STDLIB_H
11 #include <rudiments/private/rudimentsinlines.h>
13 #ifdef RUDIMENTS_NAMESPACE
17 #define DICTIONARY_TEMPLATE \
18 template <class keytype, class datatype, \
19 class dictionarynodetype, \
20 class dictionarylistnodetype, \
21 class dictionarylisttype>
23 #define DICTIONARY_CLASS \
24 dictionary<keytype,datatype,dictionarynodetype,\
25 dictionarylistnodetype,dictionarylisttype>
28 RUDIMENTS_TEMPLATE_INLINE
29 DICTIONARY_CLASS::dictionary() {
33 RUDIMENTS_TEMPLATE_INLINE
34 DICTIONARY_CLASS::~dictionary() {
35 for (dictionarylistnodetype *node=
36 (dictionarylistnodetype *)dict.getFirstNode();
37 node; node=(dictionarylistnodetype *)node->getNext()) {
38 delete node->getData();
43 RUDIMENTS_TEMPLATE_INLINE
44 void DICTIONARY_CLASS::setData(keytype key, datatype data) {
45 dictionarylistnodetype *node=findNode(key);
47 node->getData()->setData(data);
49 dictionarynodetype *dictnode=
new dictionarynodetype();
50 dictnode->setKey(key);
51 dictnode->setData(data);
52 dict.append(dictnode);
57 RUDIMENTS_TEMPLATE_INLINE
58 bool DICTIONARY_CLASS::getData(keytype key, datatype *data) {
59 dictionarylistnodetype *node=findNode(key);
61 *data=node->getData()->getData();
68 RUDIMENTS_TEMPLATE_INLINE
69 bool DICTIONARY_CLASS::removeData(keytype key) {
70 dictionarylistnodetype *node=findNode(key);
72 return dict.removeNode(node);
78 RUDIMENTS_TEMPLATE_INLINE
79 dictionarylistnodetype *DICTIONARY_CLASS::findNode(keytype key) {
80 for (dictionarylistnodetype *node=
81 (dictionarylistnodetype *)dict.getFirstNode();
82 node; node=(dictionarylistnodetype *)node->getNext()) {
83 if (!node->getData()->compare(key)) {
91 RUDIMENTS_TEMPLATE_INLINE
92 dictionarylisttype *DICTIONARY_CLASS::getList() {
97 RUDIMENTS_TEMPLATE_INLINE
98 void DICTIONARY_CLASS::clear() {
103 RUDIMENTS_TEMPLATE_INLINE
104 void DICTIONARY_CLASS::print() {
105 for (dictionarylistnodetype *node=
106 (dictionarylistnodetype *)dict.getFirstNode();
107 node; node=(dictionarylistnodetype *)node->getNext()) {
108 node->getData()->print();
115 template <
class datatype>
116 RUDIMENTS_TEMPLATE_INLINE
119 template <
class datatype>
120 RUDIMENTS_TEMPLATE_INLINE
123 template <
class datatype>
124 RUDIMENTS_TEMPLATE_INLINE
127 template <
class datatype>
128 RUDIMENTS_TEMPLATE_INLINE
133 template <
class datatype>
134 RUDIMENTS_TEMPLATE_INLINE
137 template <
class datatype>
138 RUDIMENTS_TEMPLATE_INLINE
141 template <
class datatype>
142 RUDIMENTS_TEMPLATE_INLINE
145 template <
class datatype>
146 RUDIMENTS_TEMPLATE_INLINE
151 template <
class datatype>
152 RUDIMENTS_TEMPLATE_INLINE
155 template <
class datatype>
156 RUDIMENTS_TEMPLATE_INLINE
159 template <
class datatype>
160 RUDIMENTS_TEMPLATE_INLINE
163 template <
class datatype>
164 RUDIMENTS_TEMPLATE_INLINE
167 #ifdef RUDIMENTS_NAMESPACE