![]() |
pl-nk v0.4.5
Plonk|Plink|Plank are a set of cross-platform C/C++ frameworks for audio software development
|
A dictionary class for storing key/value pairs. More...
Inherits SmartPointerContainer< SmartPointerType, enableWeak >.
Public Member Functions | |
Dictionary () throw () | |
Creates an empty dictionary. | |
Dictionary & | operator= (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. |
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.
Dictionary< ValueType, KeyType >::Dictionary | ( | ) | throw () [inline] |
Creates an empty dictionary.
Dictionary< ValueType, KeyType >::Dictionary | ( | KeyValuePairArrayType const & | pairs | ) | throw () [inline] |
Creates a dictionary initialise with an array of key/value pairs.
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.
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.
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.
const ObjectArray<KeyType>& Dictionary< ValueType, KeyType >::getKeys | ( | ) | const throw () [inline] |
Returns the array of keys.
KeyValuePairArrayType Dictionary< ValueType, KeyType >::getPairs | ( | ) | const throw () [inline] |
Returns an array of the key/value pairs.
const ObjectArray<ValueType>& Dictionary< ValueType, KeyType >::getValues | ( | ) | const throw () [inline] |
Returns the array of values.
KeyType& Dictionary< ValueType, KeyType >::key | ( | const int | index | ) | throw () [inline] |
Get a key at a particular index.
const KeyType& Dictionary< ValueType, KeyType >::key | ( | const int | index | ) | const throw () [inline] |
Get a key at a particular index.
const KeyType& Dictionary< ValueType, KeyType >::keyForValue | ( | ValueType const & | value | ) | const [inline] |
Return the key for a particular value.
int Dictionary< ValueType, KeyType >::length | ( | ) | const throw () [inline] |
Get the number of items stored in the dictionary.
Dictionary& Dictionary< ValueType, KeyType >::operator= | ( | Dictionary< ValueType, KeyType > const & | other | ) | throw () [inline] |
Assignment operator.
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.
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.
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.
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.
int Dictionary< ValueType, KeyType >::size | ( | ) | const throw () [inline] |
Get the number of items stored in the dictionary.
ValueType& Dictionary< ValueType, KeyType >::value | ( | const int | index | ) | throw () [inline] |
Get a value at a particular index.
const ValueType& Dictionary< ValueType, KeyType >::value | ( | const int | index | ) | const throw () [inline] |
Get a value at a particular index.