HDK
|
A thread-safe hash map which stores indexed shared items. More...
#include <UT_IndexedHashSet.h>
Classes | |
class | IdAndRefCount |
class | IdRemapping |
class | keyHasher |
class | unsafe_iterator |
Iterate over items in the map - this is arbitrary order. More... | |
class | unsafe_listiterator |
Public Types | |
typedef UT_ConcurrentHashMap < T, IdAndRefCount > | UT_IndexedHashSetTable |
typedef UT_ConcurrentVector< T > | UT_IndexedHashSetVector |
typedef UT_ConcurrentQueue < UT_IndexedHashSetItemId > | UT_IndexedHashSetHoleQueue |
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_IndexedHashSetItemId). The item can then be retrieved efficiently from the map using the id (UT_IndexedHashSet::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 50 of file UT_IndexedHashSet.h.
typedef UT_ConcurrentQueue<UT_IndexedHashSetItemId> UT_IndexedHashSet< T >::UT_IndexedHashSetHoleQueue |
Definition at line 250 of file UT_IndexedHashSet.h.
typedef UT_ConcurrentHashMap<T, IdAndRefCount> UT_IndexedHashSet< T >::UT_IndexedHashSetTable |
Definition at line 247 of file UT_IndexedHashSet.h.
typedef UT_ConcurrentVector<T> UT_IndexedHashSet< T >::UT_IndexedHashSetVector |
Definition at line 248 of file UT_IndexedHashSet.h.
|
inline |
Each item stored in the map will be given a unique id of type UT_IndexedHashSetItemId. These id's can be used to perform efficient lookup of items in the map.
Definition at line 56 of file UT_IndexedHashSet.h.
|
inline |
Definition at line 59 of file UT_IndexedHashSet.h.
UT_IndexedHashSetItemId UT_IndexedHashSet< T >::add | ( | const T & | key | ) |
Definition at line 202 of file UT_IndexedHashSetImpl.h.
const T * UT_IndexedHashSet< T >::addReference | ( | UT_IndexedHashSetItemId | id, |
int | inc | ||
) |
This may return null if inc is negative and the reference count reaches zero, or if the ID is out of range.
Definition at line 117 of file UT_IndexedHashSetImpl.h.
|
inline |
Definition at line 154 of file UT_IndexedHashSet.h.
|
inline |
Definition at line 387 of file UT_IndexedHashSet.h.
|
inline |
Definition at line 391 of file UT_IndexedHashSet.h.
void UT_IndexedHashSet< T >::clear | ( | void | ) |
bool UT_IndexedHashSet< T >::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.
Definition at line 346 of file UT_IndexedHashSetImpl.h.
|
inline |
Return whether the map is empty.
Definition at line 73 of file UT_IndexedHashSet.h.
|
inline |
Definition at line 389 of file UT_IndexedHashSet.h.
|
inline |
Definition at line 393 of file UT_IndexedHashSet.h.
|
inline |
Return the number of entries in the map.
Definition at line 70 of file UT_IndexedHashSet.h.
exint UT_IndexedHashSet< T >::extractItems | ( | ID_ARRAY & | ids, |
T_ARRAY & | items, | ||
exint | maxitems | ||
) | const |
Definition at line 409 of file UT_IndexedHashSetImpl.h.
exint UT_IndexedHashSet< T >::extractItems | ( | ID_ARRAY & | ids, |
T_ARRAY & | items | ||
) | const |
Definition at line 439 of file UT_IndexedHashSetImpl.h.
exint UT_IndexedHashSet< T >::extractItems | ( | T_ARRAY & | items | ) | const |
Definition at line 462 of file UT_IndexedHashSetImpl.h.
|
inline |
Definition at line 157 of file UT_IndexedHashSet.h.
const T * UT_IndexedHashSet< T >::findItemAndId | ( | const T & | key, |
UT_IndexedHashSetItemId & | id | ||
) | const |
Definition at line 225 of file UT_IndexedHashSetImpl.h.
|
inline |
Definition at line 166 of file UT_IndexedHashSet.h.
|
inline |
Return the maximum possible UT_IndexedHashSetItemId stored in the map. This returns an upper bound and is not exact.
Definition at line 82 of file UT_IndexedHashSet.h.
int64 UT_IndexedHashSet< T >::getMemoryUsage | ( | bool | inclusive | ) | const |
Return approximate memory usage (not including key or item storage)
Definition at line 476 of file UT_IndexedHashSetImpl.h.
|
inline |
Return the "occupancy" of the map.
Definition at line 88 of file UT_IndexedHashSet.h.
const T * UT_IndexedHashSet< T >::getOrderedItem | ( | exint | index, |
UT_IndexedHashSetItemId * | id = nullptr |
||
) | const |
Definition at line 93 of file UT_IndexedHashSetImpl.h.
exint UT_IndexedHashSet< T >::getReferenceCount | ( | UT_IndexedHashSetItemId | id | ) | const |
Definition at line 153 of file UT_IndexedHashSetImpl.h.
exint UT_IndexedHashSet< T >::getReferenceCount | ( | const T & | key | ) | const |
Definition at line 170 of file UT_IndexedHashSetImpl.h.
bool UT_IndexedHashSet< T >::remove | ( | const T & | key | ) |
Definition at line 240 of file UT_IndexedHashSetImpl.h.
bool UT_IndexedHashSet< T >::remove | ( | UT_IndexedHashSetItemId | id | ) |
Definition at line 268 of file UT_IndexedHashSetImpl.h.
void UT_IndexedHashSet< T >::replace | ( | const UT_IndexedHashSet< T > & | src | ) |
Definition at line 47 of file UT_IndexedHashSetImpl.h.
UT_IndexedHashSetItemId UT_IndexedHashSet< T >::replaceItem | ( | UT_IndexedHashSetItemId | id, |
const T & | key | ||
) |
Definition at line 283 of file UT_IndexedHashSetImpl.h.
bool UT_IndexedHashSet< T >::sortItems | ( | const P & | predicate | ) |
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.
Definition at line 381 of file UT_IndexedHashSetImpl.h.