CS::Container::WeakKeyedHash< T, K, ArrayMemoryAlloc, ArrayElementHandler > Class Template Reference
Hash type that allows (certain) changes of key objects. More...
#include <csutil/weakkeyedhash.h>
Classes | |
class | GlobalIterator |
An iterator class for WeakKeyedHash. More... | |
Public Member Functions | |
const T & | Get (const K &key, const T &fallback) |
Get the first element matching the given key, or fallback if there is none. | |
GlobalIterator | GetIterator () |
Return an iterator for the hash, to iterate over all elements. | |
T & | Put (const K &key, const T &value) |
Add an element to the hash table. |
Detailed Description
template<class T, class K, class ArrayMemoryAlloc = CS::Container::ArrayAllocDefault, class ArrayElementHandler = csArraySafeCopyElementHandler< CS::Container::HashElement<T, K> >>
class CS::Container::WeakKeyedHash< T, K, ArrayMemoryAlloc, ArrayElementHandler >
Hash type that allows (certain) changes of key objects.
This hash type works with keys that may be 'invalidated' as a side effect of some other operation - prime example is csWeakRef<> which gets cleared if the referenced object is destroyed. However, apart from invalidation, key objects may not change their values.
The validity of a key is tested by evaluating it to a bool
. Invalid keys should evaluate to false
(conversely, valid keys should evaluate to true
).
Invalid keys, and values associated with them, are occasionally cleaned out as a part of normal operation (element retrieval, element insertion ...), hence it is likely to occur that the value associated with a key that got invalidated will stay allocated for an unknown amount of time.
Definition at line 51 of file weakkeyedhash.h.
Member Function Documentation
const T& CS::Container::WeakKeyedHash< T, K, ArrayMemoryAlloc, ArrayElementHandler >::Get | ( | const K & | key, | |
const T & | fallback | |||
) | [inline] |
Get the first element matching the given key, or fallback if there is none.
Definition at line 61 of file weakkeyedhash.h.
GlobalIterator CS::Container::WeakKeyedHash< T, K, ArrayMemoryAlloc, ArrayElementHandler >::GetIterator | ( | ) | [inline] |
Return an iterator for the hash, to iterate over all elements.
- Warning:
- Modifying the hash (except with DeleteElement()) while you have open iterators will result in undefined behaviour.
Reimplemented from csHash< T, K, ArrayMemoryAlloc, ArrayElementHandler >.
Definition at line 242 of file weakkeyedhash.h.
T& CS::Container::WeakKeyedHash< T, K, ArrayMemoryAlloc, ArrayElementHandler >::Put | ( | const K & | key, | |
const T & | value | |||
) | [inline] |
Add an element to the hash table.
- Remarks:
- If key is already present, does NOT replace the existing value, but merely adds value as an additional value of key. To retrieve all values for a given key, use GetAll(). If you instead want to replace an existing value for key, use PutUnique().
Reimplemented from csHash< T, K, ArrayMemoryAlloc, ArrayElementHandler >.
Definition at line 93 of file weakkeyedhash.h.
The documentation for this class was generated from the following file:
- csutil/weakkeyedhash.h
Generated for Crystal Space 2.0 by doxygen 1.6.1