HDK
|
A thread-safe hash map which stores indexed shared items. More...
#include <UT_IndexedHashMap.h>
Classes | |
class | IdRemapping |
class | itemCompare |
class | itemContainer |
class | keyCompare |
class | keyContainer |
class | listContainer |
class | unsafe_iterator |
Iterate over items in the map - this is arbitrary order. More... | |
class | unsafe_listiterator |
Public Types | |
typedef void | InternalKeyT |
typedef void | InternalItemT |
Public Member Functions | |
UT_IndexedHashMap (bool store_ids) | |
virtual | ~UT_IndexedHashMap () |
void | clear () |
exint | entries () const |
bool | empty () const |
Return whether the map is empty. More... | |
int64 | getMemoryUsage (bool inclusive) const |
Return approximate memory usage (not including key or item storage) More... | |
UT_IndexedHashMapItemId | getItemIdUpperBound () const |
fpreal | getOccupancy () const |
bool | compactIds (IdRemapping &remapping) |
bool | sortItems () |
exint | getReferenceCount (UT_IndexedHashMapItemId id) const |
unsafe_iterator | begin () const |
unsafe_iterator | end () const |
unsafe_listiterator | beginList () const |
unsafe_listiterator | endList () const |
Protected Types | |
typedef UT_ConcurrentHashMap < keyContainer, itemContainer *, keyCompare > | UT_IndexedHashMapTable |
typedef UT_ConcurrentVector < listContainer > | UT_IndexedHashMapVector |
typedef UT_ConcurrentQueue < UT_IndexedHashMapItemId > | UT_IndexedHashMapHoleQueue |
Friends | |
class | itemContainer |
class | keyContainer |
class | itemCompare |
A thread-safe hash map which stores indexed shared items.
Each item in the hash map is reference counted. That is, if objects are added multiple times, only a single object will be stored in the map.
Removing an item from the hash map (by id or key) will decrement the reference count on the item. When no longer referenced, the map will delete the item.
When the map stores 'ids', each item is assigned a unique id (UT_IndexedHashMapItemId). The item can then be retrieved efficiently from the map using the id (UT_IndexedHashMap::get())
Many methods on the map are thread-safe. Some methods are not (and are noted in the comments).
The KEY template parameter needs to have:
Definition at line 47 of file UT_IndexedHashMap.h.
typedef void UT_IndexedHashMap::InternalItemT |
Definition at line 51 of file UT_IndexedHashMap.h.
typedef void UT_IndexedHashMap::InternalKeyT |
Definition at line 50 of file UT_IndexedHashMap.h.
|
protected |
Definition at line 384 of file UT_IndexedHashMap.h.
|
protected |
Definition at line 381 of file UT_IndexedHashMap.h.
|
protected |
Definition at line 382 of file UT_IndexedHashMap.h.
UT_IndexedHashMap::UT_IndexedHashMap | ( | bool | store_ids | ) |
If store_ids
is true, each item stored in the map will be given a unique id of type UT_IndexedHashMapItemId. These id's can be used to perform efficient lookup of items in the map.
If the store_ids
parameter is false, then elements in the shared map will not store id's. The ids for the elements will always be -1 (invalid). The map won't store the structures required for indexed lookup, saving some memory and allowing some operations to be slightly more efficient. Operations which are invalid for maps that don't store id's are noted in the comments).
|
virtual |
|
protected |
Internal implementation using internal types rather than exposed types. None of these methods use the template types and thus are only generated one time (outlined).
|
protected |
Internal implementation using internal types rather than exposed types. None of these methods use the template types and thus are only generated one time (outlined).
|
inlineprotected |
Internal implementation using internal types rather than exposed types. None of these methods use the template types and thus are only generated one time (outlined).
Definition at line 173 of file UT_IndexedHashMap.h.
|
protected |
Internal implementation using internal types rather than exposed types. None of these methods use the template types and thus are only generated one time (outlined).
|
protected |
Internal implementation using internal types rather than exposed types. None of these methods use the template types and thus are only generated one time (outlined).
|
protected |
Internal implementation using internal types rather than exposed types. None of these methods use the template types and thus are only generated one time (outlined).
|
inlineprotected |
Internal implementation using internal types rather than exposed types. None of these methods use the template types and thus are only generated one time (outlined).
Definition at line 176 of file UT_IndexedHashMap.h.
|
inlineprotected |
Internal implementation using internal types rather than exposed types. None of these methods use the template types and thus are only generated one time (outlined).
Definition at line 181 of file UT_IndexedHashMap.h.
|
protected |
Internal implementation using internal types rather than exposed types. None of these methods use the template types and thus are only generated one time (outlined).
|
protected |
Internal implementation using internal types rather than exposed types. None of these methods use the template types and thus are only generated one time (outlined).
|
protected |
Internal implementation using internal types rather than exposed types. None of these methods use the template types and thus are only generated one time (outlined).
|
protected |
Internal implementation using internal types rather than exposed types. None of these methods use the template types and thus are only generated one time (outlined).
|
protected |
Internal implementation using internal types rather than exposed types. None of these methods use the template types and thus are only generated one time (outlined).
|
protected |
Internal implementation using internal types rather than exposed types. None of these methods use the template types and thus are only generated one time (outlined).
|
protected |
Internal implementation using internal types rather than exposed types. None of these methods use the template types and thus are only generated one time (outlined).
|
protected |
Internal implementation using internal types rather than exposed types. None of these methods use the template types and thus are only generated one time (outlined).
|
protectedpure virtual |
Implemented in UT_IndexedHashMapT< KEY, ITEM, DEFER_ALLOC >, UT_IndexedHashMapT< UT_StringHolder, UT_Color >, UT_IndexedHashMapT< MapKey, UT_IndexedHashMapItemKeyContainer, ut_IndexedHashMapDeferItemAlloc >, UT_IndexedHashMapT< UT_IndexedHashMapStringKey, UT_IndexedHashMapStringItem, UT_IndexedHashMapStringAlloc >, and UT_IndexedHashMapT< MapKey, MapItem, MapAlloc >.
|
inline |
Definition at line 515 of file UT_IndexedHashMap.h.
|
inline |
Definition at line 519 of file UT_IndexedHashMap.h.
void UT_IndexedHashMap::clear | ( | ) |
Clear the map
bool UT_IndexedHashMap::compactIds | ( | IdRemapping & | remapping | ) |
Compact the list. This fills out the integer map of old id's and their new id's. If no compaction was done, the function returns false.
|
protectedpure virtual |
Implemented in UT_IndexedHashMapT< KEY, ITEM, DEFER_ALLOC >, UT_IndexedHashMapT< UT_StringHolder, UT_Color >, UT_IndexedHashMapT< MapKey, UT_IndexedHashMapItemKeyContainer, ut_IndexedHashMapDeferItemAlloc >, UT_IndexedHashMapT< UT_IndexedHashMapStringKey, UT_IndexedHashMapStringItem, UT_IndexedHashMapStringAlloc >, and UT_IndexedHashMapT< MapKey, MapItem, MapAlloc >.
|
protectedpure virtual |
Implemented in UT_IndexedHashMapT< KEY, ITEM, DEFER_ALLOC >, UT_IndexedHashMapT< UT_StringHolder, UT_Color >, UT_IndexedHashMapT< MapKey, UT_IndexedHashMapItemKeyContainer, ut_IndexedHashMapDeferItemAlloc >, UT_IndexedHashMapT< UT_IndexedHashMapStringKey, UT_IndexedHashMapStringItem, UT_IndexedHashMapStringAlloc >, and UT_IndexedHashMapT< MapKey, MapItem, MapAlloc >.
|
protectedpure virtual |
Implemented in UT_IndexedHashMapT< KEY, ITEM, DEFER_ALLOC >, UT_IndexedHashMapT< UT_StringHolder, UT_Color >, UT_IndexedHashMapT< MapKey, UT_IndexedHashMapItemKeyContainer, ut_IndexedHashMapDeferItemAlloc >, UT_IndexedHashMapT< UT_IndexedHashMapStringKey, UT_IndexedHashMapStringItem, UT_IndexedHashMapStringAlloc >, and UT_IndexedHashMapT< MapKey, MapItem, MapAlloc >.
|
inline |
Return whether the map is empty.
Definition at line 88 of file UT_IndexedHashMap.h.
|
inline |
Definition at line 517 of file UT_IndexedHashMap.h.
|
inline |
Definition at line 521 of file UT_IndexedHashMap.h.
|
inline |
Return the number of entries in the map.
Definition at line 85 of file UT_IndexedHashMap.h.
|
inline |
Return the maximum possible UT_IndexedHashMapItemId stored in the map. This returns an upper bound and is not exact.
Definition at line 97 of file UT_IndexedHashMap.h.
int64 UT_IndexedHashMap::getMemoryUsage | ( | bool | inclusive | ) | const |
Return approximate memory usage (not including key or item storage)
|
inline |
Return the "occupancy" of the map.
Definition at line 103 of file UT_IndexedHashMap.h.
exint UT_IndexedHashMap::getReferenceCount | ( | UT_IndexedHashMapItemId | id | ) | const |
|
protectedpure virtual |
Implemented in UT_IndexedHashMapT< KEY, ITEM, DEFER_ALLOC >, UT_IndexedHashMapT< UT_StringHolder, UT_Color >, UT_IndexedHashMapT< MapKey, UT_IndexedHashMapItemKeyContainer, ut_IndexedHashMapDeferItemAlloc >, UT_IndexedHashMapT< UT_IndexedHashMapStringKey, UT_IndexedHashMapStringItem, UT_IndexedHashMapStringAlloc >, and UT_IndexedHashMapT< MapKey, MapItem, MapAlloc >.
|
protectedpure virtual |
Implemented in UT_IndexedHashMapT< KEY, ITEM, DEFER_ALLOC >, UT_IndexedHashMapT< UT_StringHolder, UT_Color >, UT_IndexedHashMapT< MapKey, UT_IndexedHashMapItemKeyContainer, ut_IndexedHashMapDeferItemAlloc >, UT_IndexedHashMapT< UT_IndexedHashMapStringKey, UT_IndexedHashMapStringItem, UT_IndexedHashMapStringAlloc >, and UT_IndexedHashMapT< MapKey, MapItem, MapAlloc >.
|
protectedpure virtual |
Implemented in UT_IndexedHashMapT< KEY, ITEM, DEFER_ALLOC >, UT_IndexedHashMapT< UT_StringHolder, UT_Color >, UT_IndexedHashMapT< MapKey, UT_IndexedHashMapItemKeyContainer, ut_IndexedHashMapDeferItemAlloc >, UT_IndexedHashMapT< UT_IndexedHashMapStringKey, UT_IndexedHashMapStringItem, UT_IndexedHashMapStringAlloc >, and UT_IndexedHashMapT< MapKey, MapItem, MapAlloc >.
bool UT_IndexedHashMap::sortItems | ( | ) |
Sort the list of ids based on the comparator. This method only works if the table has been compacted. Returns false if there are no ids or the list is not compacted.
|
friend |
Definition at line 365 of file UT_IndexedHashMap.h.
|
friend |
Definition at line 216 of file UT_IndexedHashMap.h.
|
friend |
Definition at line 252 of file UT_IndexedHashMap.h.