Rudiments
|
Public Member Functions | |
dictionary () | |
virtual | ~dictionary () |
void | setValue (keytype key, valuetype value) |
bool | getValue (keytype key, valuetype *value) |
dictionarynode< keytype, valuetype > * | getNode (keytype key) |
valuetype | getValue (keytype key) |
bool | remove (keytype key) |
dictionarynode< keytype, valuetype > * | detach (keytype key) |
linkedlist< keytype > * | getKeys () |
linkedlist< dictionarynode< keytype, valuetype > * > * | getList () |
void | clear () |
void | print () |
The dictionary class allows you to store arbitrary numbers of key/value pairs.
Each dictionary is composed of a set of dictionarynodes. Each dictionarynode contains the key and value.
Internally, the dictionary class uses a linkedlist to store the values though this is potentially inefficient though, and may change in a future version.
dictionary< keytype, valuetype >::dictionary | ( | ) |
Creates an empty instance of the dictionary class.
|
virtual |
Deletes this instance of the dictionary class and all of its dictionarynodes. Note however, that neither the key nor value stored in each dictionarynode are deleted by this call.
void dictionary< keytype, valuetype >::clear | ( | ) |
Deletes all dictionarynodes currently in the dictionary.
dictionarynode<keytype,valuetype>* dictionary< keytype, valuetype >::detach | ( | keytype | key | ) |
Detaches the dictionarynode associated with "key". Returns the node on success or NULL if "key" wasn't found.
linkedlist< keytype >* dictionary< keytype, valuetype >::getKeys | ( | ) |
Returns a list of the keys in the dictionary.
Note that the linkedlist returned is allocated internally and returned. The calling program must delete the linkedlist.
linkedlist< dictionarynode<keytype,valuetype> *>* dictionary< keytype, valuetype >::getList | ( | ) |
Returns the list used internally.
dictionarynode<keytype,valuetype>* dictionary< keytype, valuetype >::getNode | ( | keytype | key | ) |
Returns the node associated with "key" or NULL if "key" wasn't found.
bool dictionary< keytype, valuetype >::getValue | ( | keytype | key, |
valuetype * | value | ||
) |
Sets "value" to the value associated with "key". Returns true on success or false if "key" wasn't found.
valuetype dictionary< keytype, valuetype >::getValue | ( | keytype | key | ) |
Returns the value associated with "key" or NULL if "key" wasn't found. Note that there is no way to distinguish between failure to find "key" and a valid value of NULL associated with "key".
void dictionary< keytype, valuetype >::print | ( | ) |
Prints out a representation of the dictionary.
bool dictionary< keytype, valuetype >::remove | ( | keytype | key | ) |
Removes the dictionarynode associated with "key". Returns true on success or false if "key" wasn't found.
void dictionary< keytype, valuetype >::setValue | ( | keytype | key, |
valuetype | value | ||
) |
Sets the value associated with "key" to "value". If "key" already exists, the value currently accociated with it is replaced with "value".