pl-nk v0.4.5
Plonk|Plink|Plank are a set of cross-platform C/C++ frameworks for audio software development
Public Member Functions | Static Public Member Functions
Dictionary< ValueType, KeyType > Class Template Reference

A dictionary class for storing key/value pairs. More...

Inherits SmartPointerContainer< SmartPointerType, enableWeak >.

List of all members.

Public Member Functions

 Dictionary () throw ()
 Creates an empty dictionary.
Dictionaryoperator= (Dictionary const &other) throw ()
 Assignment operator.
 Dictionary (KeyValuePairArrayType const &pairs) throw ()
 Creates a dictionary initialise with an array of key/value pairs.
const ObjectArray< ValueType > & getValues () const throw ()
 Returns the array of values.
const ObjectArray< KeyType > & getKeys () const throw ()
 Returns the array of keys.
KeyValuePairArrayType getPairs () const throw ()
 Returns an array of the key/value pairs.
ValueType put (KeyType const &key, ValueType const &value) throw ()
 Put an item into the dicionary associated with the specified key.
ValueType & at (KeyType const &key) throw ()
 Return a value at the specified key.
const ValueType & at (KeyType const &key) const throw ()
 Return a value at the specified key.
ValueType & operator[] (KeyType const &key) throw ()
 Return a value at the specified key.
const ValueType & operator[] (KeyType const &key) const throw ()
 Return a value at the specified key.
ValueType remove (KeyType const &key) throw ()
 Remove and return an item at the specified key.
const KeyType & keyForValue (ValueType const &value) const
 Return the key for a particular value.
KeyType & key (const int index) throw ()
 Get a key at a particular index.
ValueType & value (const int index) throw ()
 Get a value at a particular index.
const KeyType & key (const int index) const throw ()
 Get a key at a particular index.
const ValueType & value (const int index) const throw ()
 Get a value at a particular index.
int length () const throw ()
 Get the number of items stored in the dictionary.
int size () const throw ()
 Get the number of items stored in the dictionary.

Static Public Member Functions

static Dictionary fromWeak (Weak const &weak) throw ()
 Get a weakly linked copy of this object.

Detailed Description

template<class ValueType, class KeyType>
class Dictionary< ValueType, KeyType >

A dictionary class for storing key/value pairs.

Similar to std::map. Holds objects against a key. Items are stored in an array and accessed via their key. By default the key is a Text string but can be any appropriate type.


Constructor & Destructor Documentation

template<class ValueType, class KeyType>
Dictionary< ValueType, KeyType >::Dictionary ( ) throw () [inline]

Creates an empty dictionary.

template<class ValueType, class KeyType>
Dictionary< ValueType, KeyType >::Dictionary ( KeyValuePairArrayType const &  pairs) throw () [inline]

Creates a dictionary initialise with an array of key/value pairs.


Member Function Documentation

template<class ValueType, class KeyType>
ValueType& Dictionary< ValueType, KeyType >::at ( KeyType const &  key) throw () [inline]

Return a value at the specified key.

If the key is not found then a "null" version of the value is returned.

template<class ValueType, class KeyType>
const ValueType& Dictionary< ValueType, KeyType >::at ( KeyType const &  key) const throw () [inline]

Return a value at the specified key.

If the key is not found then a "null" version of the value is returned.

template<class ValueType, class KeyType>
static Dictionary Dictionary< ValueType, KeyType >::fromWeak ( Weak const &  weak) throw () [inline, static]

Get a weakly linked copy of this object.

This will return a blank/empty/null object of this type if the original has already been deleted.

template<class ValueType, class KeyType>
const ObjectArray<KeyType>& Dictionary< ValueType, KeyType >::getKeys ( ) const throw () [inline]

Returns the array of keys.

template<class ValueType, class KeyType>
KeyValuePairArrayType Dictionary< ValueType, KeyType >::getPairs ( ) const throw () [inline]

Returns an array of the key/value pairs.

template<class ValueType, class KeyType>
const ObjectArray<ValueType>& Dictionary< ValueType, KeyType >::getValues ( ) const throw () [inline]

Returns the array of values.

template<class ValueType, class KeyType>
KeyType& Dictionary< ValueType, KeyType >::key ( const int  index) throw () [inline]

Get a key at a particular index.

template<class ValueType, class KeyType>
const KeyType& Dictionary< ValueType, KeyType >::key ( const int  index) const throw () [inline]

Get a key at a particular index.

template<class ValueType, class KeyType>
const KeyType& Dictionary< ValueType, KeyType >::keyForValue ( ValueType const &  value) const [inline]

Return the key for a particular value.

template<class ValueType, class KeyType>
int Dictionary< ValueType, KeyType >::length ( ) const throw () [inline]

Get the number of items stored in the dictionary.

template<class ValueType, class KeyType>
Dictionary& Dictionary< ValueType, KeyType >::operator= ( Dictionary< ValueType, KeyType > const &  other) throw () [inline]

Assignment operator.

template<class ValueType, class KeyType>
ValueType& Dictionary< ValueType, KeyType >::operator[] ( KeyType const &  key) throw () [inline]

Return a value at the specified key.

If the key is not found then a "null" version of the value is returned.

template<class ValueType, class KeyType>
const ValueType& Dictionary< ValueType, KeyType >::operator[] ( KeyType const &  key) const throw () [inline]

Return a value at the specified key.

If the key is not found then a "null" version of the value is returned.

template<class ValueType, class KeyType>
ValueType Dictionary< ValueType, KeyType >::put ( KeyType const &  key,
ValueType const &  value 
) throw () [inline]

Put an item into the dicionary associated with the specified key.

If an item is already stored agains that key the old value is returned. Otherwise a "null" version of the value is returned. In many case you will not need to use the return value.

template<class ValueType, class KeyType>
ValueType Dictionary< ValueType, KeyType >::remove ( KeyType const &  key) throw () [inline]

Remove and return an item at the specified key.

If the key is not found then a "null" version of the value is returned.

template<class ValueType, class KeyType>
int Dictionary< ValueType, KeyType >::size ( ) const throw () [inline]

Get the number of items stored in the dictionary.

template<class ValueType, class KeyType>
ValueType& Dictionary< ValueType, KeyType >::value ( const int  index) throw () [inline]

Get a value at a particular index.

template<class ValueType, class KeyType>
const ValueType& Dictionary< ValueType, KeyType >::value ( const int  index) const throw () [inline]

Get a value at a particular index.


The documentation for this class was generated from the following file:
 All Classes Functions Typedefs Enumerations Enumerator Properties