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 | ConstGlobalIterator |
| An iterator class for WeakKeyedHash. More... | |
| class | GlobalIterator |
| An iterator class for WeakKeyedHash. More... | |
Public Member Functions | |
| void | DeleteElement (GlobalIterator &iterator) |
| Delete the element pointed by the iterator. | |
| const T & | Get (const K &key, const T &fallback) |
| Get the first element matching the given key, or fallback if there is none. | |
| T * | GetElementPointer (const K &key) |
| Get a pointer to the first element matching the given key, or 0 if there is none. | |
| ConstGlobalIterator | GetIterator () const |
| Return an iterator for the hash, to iterate over all elements. | |
| GlobalIterator | GetIterator () |
| Return an iterator for the hash, to iterate over all elements. | |
| void | Purge () |
| Check all keys and discard data for invalid keys. | |
| T & | Put (const K &key, const T &value) |
| Add an element to the hash table. | |
| T & | PutUnique (const K &key, const T &value) |
| Add an element to the hash table, overwriting if the key already exists. | |
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
| void CS::Container::WeakKeyedHash< T, K, ArrayMemoryAlloc, ArrayElementHandler >::DeleteElement | ( | GlobalIterator & | iterator | ) | [inline] |
Delete the element pointed by the iterator.
This is safe for this iterator, not for the others.
Reimplemented from csHash< T, K, ArrayMemoryAlloc, ArrayElementHandler >.
Definition at line 336 of file weakkeyedhash.h.
| 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 80 of file weakkeyedhash.h.
| T* CS::Container::WeakKeyedHash< T, K, ArrayMemoryAlloc, ArrayElementHandler >::GetElementPointer | ( | const K & | key | ) | [inline] |
Get a pointer to the first element matching the given key, or 0 if there is none.
Reimplemented from csHash< T, K, ArrayMemoryAlloc, ArrayElementHandler >.
Definition at line 109 of file weakkeyedhash.h.
| ConstGlobalIterator CS::Container::WeakKeyedHash< T, K, ArrayMemoryAlloc, ArrayElementHandler >::GetIterator | ( | ) | const [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 459 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 327 of file weakkeyedhash.h.
| void CS::Container::WeakKeyedHash< T, K, ArrayMemoryAlloc, ArrayElementHandler >::Purge | ( | ) | [inline] |
Check all keys and discard data for invalid keys.
Definition at line 57 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 140 of file weakkeyedhash.h.
| T& CS::Container::WeakKeyedHash< T, K, ArrayMemoryAlloc, ArrayElementHandler >::PutUnique | ( | const K & | key, | |
| const T & | value | |||
| ) | [inline] |
Add an element to the hash table, overwriting if the key already exists.
Reimplemented from csHash< T, K, ArrayMemoryAlloc, ArrayElementHandler >.
Definition at line 171 of file weakkeyedhash.h.
The documentation for this class was generated from the following file:
- csutil/weakkeyedhash.h
Generated for Crystal Space 2.1 by doxygen 1.6.1
