Rudiments
|
Inherits dictionarycollection< keytype, valuetype >.
Public Member Functions | |
dictionary () | |
dictionary (bool trackinsertionorder) | |
dictionary (dictionary< keytype, valuetype > &a) | |
dictionary (dictionarycollection< keytype, valuetype > &a) | |
dictionary< keytype, valuetype > & | operator= (dictionary< keytype, valuetype > &a) |
dictionary< keytype, valuetype > & | operator= (dictionarycollection< keytype, valuetype > &a) |
~dictionary () | |
bool | setTrackInsertionOrder (bool trackinsertionorder) |
bool | getTrackInsertionOrder () |
void | setValue (keytype key, valuetype value) |
void | setValues (keytype *keys, valuetype *values) |
void | setValues (keytype const *keys, valuetype const *values) |
void | setValues (keytype *keys, valuetype *values, uint64_t count) |
void | setValues (keytype const *keys, valuetype const *values, uint64_t count) |
void | setValues (dictionary< keytype, valuetype > *dict) |
bool | getValue (keytype key, valuetype *value) |
valuetype | getValue (keytype key) |
bool | getKey (keytype key, keytype *k) |
keytype | getKey (keytype key) |
linkedlist< keytype > * | getKeys () |
uint64_t | getCount () |
bool | remove (keytype key) |
bool | clear () |
Public Member Functions inherited from dictionarycollection< keytype, valuetype > | |
virtual const char * | getType () |
virtual ssize_t | write () |
virtual ssize_t | write (output *out) |
virtual ssize_t | writeJson () |
virtual ssize_t | writeJson (bool indent) |
virtual ssize_t | writeJson (output *out) |
virtual ssize_t | writeJson (output *out, bool indent) |
Public Member Functions inherited from collection | |
collection () | |
collection (collection &c) | |
collection & | operator= (collection &c) |
virtual | ~collection () |
comparator * | getComparator () |
void | setComparator (comparator *newcomp) |
virtual bool | isReadOnly () |
virtual bool | isBlockBased () |
virtual uint64_t | getBlockSize () |
virtual bool | isSequentialAccess () |
virtual void | setManageValues (bool manage) |
virtual bool | getManageValues () |
virtual void | setManageArrayValues (bool manage) |
virtual bool | getManageArrayValues () |
virtual void | setManageKeys (bool manage) |
virtual bool | getManageKeys () |
virtual void | setManageArrayKeys (bool manage) |
virtual bool | getManageArrayKeys () |
Public Member Functions inherited from object | |
virtual | ~object () |
The dictionary class allows you to store arbitrary numbers of key-value pairs.
|
inline |
Creates an empty instance of the dictionary class.
dictionary< keytype, valuetype >::dictionary | ( | bool | trackinsertionorder | ) |
Creates an empty instance of the dictionary class.
If "trackinsertionorder" is true then the order of key insertion is tracked and getKeys() and getList() below return a list of key-value pairs in the order that they were inserted.
If "trackinsertionorder" is false then the order of key insertion is not tracked and getList() and getList() below return alist of key-value pairs in ascending order.
|
inline |
Creates an instance of the dictionary class that is a copy of "a".
|
inline |
Creates an instance of the dictionary class that is a copy of "a".
|
inline |
Deletes this instance of the dictionary class.
The key stored in each pair is only deleted if setManageKeys(true) or setManageArrayKeys(true) has been called.
The value stored in each pair is only deleted if setManageValues(true) or setManageArrayValues(true) has been called.
|
inlinevirtual |
Deletes all key-value pairs currently in the dictionary.
The key stored in each pair is only deleted if setManageValues(true) or setManageArrayValues(true) has been called.
The key stored in each pair is only deleted if setManageKeys(true) or setManageArrayKeys(true) has been called.
The value stored in each pair is only deleted if setManageValues(true) or setManageArrayValues(true) has been called.
Always returns true.
Implements collection.
|
inlinevirtual |
Returns the number of key-value pairs in the dictionary.
Implements collection.
|
inlinevirtual |
Returns the key 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 key of NULL associated with "key".
Implements dictionarycollection< keytype, valuetype >.
|
inlinevirtual |
Sets "k" to the key associated with "key". Returns true on success or false if "key" wasn't found.
Implements dictionarycollection< keytype, valuetype >.
|
inlinevirtual |
Returns a list of the keys in the dictionary.
Implements dictionarycollection< keytype, valuetype >.
|
inlinevirtual |
Returns "true" if insertion order tracking is enabled and false otherwise.
If getTrackInsertionOrder() is true then the order of key insertion is tracked and getKeys() returns a list of keys in the order that they were inserted.
If getTrackInsertionOrder() is false then the order of key insertion is not tracked and getKeys() returns a list of keys in ascending order.
Implements dictionarycollection< keytype, valuetype >.
|
inlinevirtual |
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".
Implements dictionarycollection< keytype, valuetype >.
|
inlinevirtual |
Sets "value" to the value associated with "key". Returns true on success or false if "key" wasn't found.
Implements dictionarycollection< keytype, valuetype >.
|
inline |
Makes this instance of the dictionary class identical to "a".
|
inline |
Makes this instance of the dictionary class identical to "a".
|
inlinevirtual |
Removes the key-value pair associated with "key". Returns true on success or false if "key" wasn't found.
The key stored in the pair is only deleted if setManageKeys(true) or setManageArrayKeys(true) has been called.
The value stored in the pair is only deleted if setManageValues(true) or setManageArrayValues(true) has been called.
Implements dictionarycollection< keytype, valuetype >.
|
inline |
Sets whether tracking of the order of key insertion is enabled or not.
If "trackinsertionorder" is true then the order of key insertion is tracked and getKeys() returns a list of keys in the order that they were inserted.
If "trackinsertionorder" is false then the order of key insertion is not tracked and getKeys() returns a list of keys in ascending order.
Defaults to "true".
Note, this can only be changed when there are no key-value pairs in the dictionary. Eg. before the first call to setValue() or after a call to clear().
Returns true if the call succeeded and false if it failed (eg. because the dictionary contained key-value pairs).
|
inlinevirtual |
Sets the value associated with "key" to "value". If "key" already exists, the value currently accociated with it is replaced with "value".
Implements dictionarycollection< keytype, valuetype >.
|
inline |
Sets the value associated with each key in "dict" to the corresponding value from "dict". If "key" already exists, the value currently accociated with it is replaced with "value".
|
inlinevirtual |
Sets the value associated with each key in the "keys" array to the corresponding value in the "values" array. Assumes that keys is NULL terminated. If "key" already exists, the value currently accociated with it is replaced with "value".
Implements dictionarycollection< keytype, valuetype >.
|
inlinevirtual |
Sets the value associated with each of "count" keys in the "keys" array to the corresponding value in the "values" array. If "key" already exists, the value currently accociated with it is replaced with "value".
Implements dictionarycollection< keytype, valuetype >.
|
inlinevirtual |
Sets the value associated with each key in the "keys" array to the corresponding value in the "values" array. Assumes that keys is NULL terminated. If "key" already exists, the value currently accociated with it is replaced with "value".
Implements dictionarycollection< keytype, valuetype >.
|
inlinevirtual |
Sets the value associated with each of "count" keys in the "keys" array to the corresponding value in the "values" array. If "key" already exists, the value currently accociated with it is replaced with "value".
Implements dictionarycollection< keytype, valuetype >.