4 #include <rudiments/stdio.h>
5 #include <rudiments/private/rudimentsinlines.h>
6 #include <rudiments/private/linkedlistutilinlines.h>
8 #define DICTIONARY_TEMPLATE \
9 template <class keytype, class valuetype>
11 #define DICTIONARY_CLASS \
12 dictionary<keytype,valuetype>
15 RUDIMENTS_TEMPLATE_INLINE
16 DICTIONARY_CLASS::dictionary() {
20 RUDIMENTS_TEMPLATE_INLINE
21 DICTIONARY_CLASS::~dictionary() {
26 RUDIMENTS_TEMPLATE_INLINE
27 void DICTIONARY_CLASS::setValue(keytype key, valuetype value) {
37 RUDIMENTS_TEMPLATE_INLINE
38 bool DICTIONARY_CLASS::getValue(keytype key, valuetype *value) {
48 RUDIMENTS_TEMPLATE_INLINE
49 bool DICTIONARY_CLASS::remove(keytype key) {
52 return dict.remove(node);
58 RUDIMENTS_TEMPLATE_INLINE
62 dict.getFirst(); node; node=node->
getNext()) {
63 if (!node->
getValue()->compare(key)) {
71 RUDIMENTS_TEMPLATE_INLINE
77 RUDIMENTS_TEMPLATE_INLINE
78 void DICTIONARY_CLASS::clear() {
80 dict.getFirst(); node; node=node->
getNext()) {
87 RUDIMENTS_TEMPLATE_INLINE
88 void DICTIONARY_CLASS::print() {
90 dict.getFirst(); node; node=node->
getNext()) {
96 #define DICTIONARYNODE_TEMPLATE \
97 template <class keytype, class valuetype>
99 #define DICTIONARYNODE_CLASS \
100 dictionarynode<keytype,valuetype>
102 DICTIONARYNODE_TEMPLATE
103 RUDIMENTS_TEMPLATE_INLINE
104 DICTIONARYNODE_CLASS::dictionarynode(keytype key, valuetype value) {
109 DICTIONARYNODE_TEMPLATE
110 RUDIMENTS_TEMPLATE_INLINE
111 DICTIONARYNODE_CLASS::~dictionarynode() {}
113 DICTIONARYNODE_TEMPLATE
114 RUDIMENTS_TEMPLATE_INLINE
115 void DICTIONARYNODE_CLASS::setKey(keytype key) {
119 DICTIONARYNODE_TEMPLATE
120 RUDIMENTS_TEMPLATE_INLINE
121 void DICTIONARYNODE_CLASS::setValue(valuetype value) {
125 DICTIONARYNODE_TEMPLATE
126 RUDIMENTS_TEMPLATE_INLINE
127 keytype DICTIONARYNODE_CLASS::getKey()
const {
131 DICTIONARYNODE_TEMPLATE
132 RUDIMENTS_TEMPLATE_INLINE
133 valuetype DICTIONARYNODE_CLASS::getValue()
const {
137 DICTIONARYNODE_TEMPLATE
138 RUDIMENTS_TEMPLATE_INLINE
139 int32_t DICTIONARYNODE_CLASS::compare(keytype testkey)
const {
140 return _linkedlistutil_compare(key,testkey);
143 DICTIONARYNODE_TEMPLATE
144 RUDIMENTS_TEMPLATE_INLINE
145 void DICTIONARYNODE_CLASS::print()
const {
146 _linkedlistutil_print(key);
148 _linkedlistutil_print(value);
size_t printf(const char *format,...)
Definition: linkedlist.h:60
valuetype getValue() const
Definition: dictionary.h:12
Definition: linkedlist.h:11
linkedlistnode< valuetype > * getNext()