Rudiments
Public Member Functions
dictionary< keytype, datatype, dictionarynodetype, dictionarylistnodetype, dictionarylisttype > Class Template Reference

List of all members.

Public Member Functions

 dictionary ()
virtual ~dictionary ()
void setData (keytype key, datatype data)
bool getData (keytype key, datatype *data)
bool removeData (keytype key)
dictionarylisttype * getList ()
void clear ()
void print ()

Detailed Description

template<class keytype, class datatype, class dictionarynodetype = dictionarynode<keytype,datatype>, class dictionarylistnodetype = dictionarylistnode<keytype,datatype>, class dictionarylisttype = dictionarylist<keytype,datatype>>
class dictionary< keytype, datatype, dictionarynodetype, dictionarylistnodetype, dictionarylisttype >

The dictionary class allows you to store arbitrary numbers of key/value pairs.

Each dictionary is composed of a list of dictionarynode's. Each dictionarynode contains the key and value.

Internally, the dictionary class uses a linkedlist to store the values though this is potentially inefficient and may change in a future version.


Constructor & Destructor Documentation

template<class keytype, class datatype, class dictionarynodetype = dictionarynode<keytype,datatype>, class dictionarylistnodetype = dictionarylistnode<keytype,datatype>, class dictionarylisttype = dictionarylist<keytype,datatype>>
dictionary< keytype, datatype, dictionarynodetype, dictionarylistnodetype, dictionarylisttype >::dictionary ( )

Creates an empty instance of the dictionary class.

template<class keytype, class datatype, class dictionarynodetype = dictionarynode<keytype,datatype>, class dictionarylistnodetype = dictionarylistnode<keytype,datatype>, class dictionarylisttype = dictionarylist<keytype,datatype>>
virtual dictionary< keytype, datatype, dictionarynodetype, dictionarylistnodetype, dictionarylisttype >::~dictionary ( ) [virtual]

Deletes this instance of the dictionary class and all of its dictionarynodes. Note however, that neither the key nor data stored in each dictionarynode are deleted by this call.


Member Function Documentation

template<class keytype, class datatype, class dictionarynodetype = dictionarynode<keytype,datatype>, class dictionarylistnodetype = dictionarylistnode<keytype,datatype>, class dictionarylisttype = dictionarylist<keytype,datatype>>
void dictionary< keytype, datatype, dictionarynodetype, dictionarylistnodetype, dictionarylisttype >::clear ( )

Deletes all dictionarynodes currently in the dictionary.

template<class keytype, class datatype, class dictionarynodetype = dictionarynode<keytype,datatype>, class dictionarylistnodetype = dictionarylistnode<keytype,datatype>, class dictionarylisttype = dictionarylist<keytype,datatype>>
bool dictionary< keytype, datatype, dictionarynodetype, dictionarylistnodetype, dictionarylisttype >::getData ( keytype  key,
datatype *  data 
)

Sets "data" to the data associated with "key". Returns true on success or false if "key" wasn't found.

template<class keytype, class datatype, class dictionarynodetype = dictionarynode<keytype,datatype>, class dictionarylistnodetype = dictionarylistnode<keytype,datatype>, class dictionarylisttype = dictionarylist<keytype,datatype>>
dictionarylisttype* dictionary< keytype, datatype, dictionarynodetype, dictionarylistnodetype, dictionarylisttype >::getList ( )

Returns the list used internally.

template<class keytype, class datatype, class dictionarynodetype = dictionarynode<keytype,datatype>, class dictionarylistnodetype = dictionarylistnode<keytype,datatype>, class dictionarylisttype = dictionarylist<keytype,datatype>>
void dictionary< keytype, datatype, dictionarynodetype, dictionarylistnodetype, dictionarylisttype >::print ( )

Prints out a representation of the dictionary.

template<class keytype, class datatype, class dictionarynodetype = dictionarynode<keytype,datatype>, class dictionarylistnodetype = dictionarylistnode<keytype,datatype>, class dictionarylisttype = dictionarylist<keytype,datatype>>
bool dictionary< keytype, datatype, dictionarynodetype, dictionarylistnodetype, dictionarylisttype >::removeData ( keytype  key)

Removes the dictionarynode with "key". Returns true on success or false if "key" wasn't found.

template<class keytype, class datatype, class dictionarynodetype = dictionarynode<keytype,datatype>, class dictionarylistnodetype = dictionarylistnode<keytype,datatype>, class dictionarylisttype = dictionarylist<keytype,datatype>>
void dictionary< keytype, datatype, dictionarynodetype, dictionarylistnodetype, dictionarylisttype >::setData ( keytype  key,
datatype  data 
)

Sets the data associated with "key" to "data". If "key" already exists, the data currently accociated with it is replaced with "data".