#include <UT_IndexedHashMap.h>

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:
KEY(const KEY &src); // The copy constructor uint hash() const; // A hash method bool isEqual(const KEY &src) const; // A comparison operator
Definition at line 56 of file UT_IndexedHashMap.h.
| typedef void UT_IndexedHashMap::InternalItemT |
Definition at line 60 of file UT_IndexedHashMap.h.
| typedef void UT_IndexedHashMap::InternalKeyT |
Definition at line 59 of file UT_IndexedHashMap.h.
typedef UT_ConcurrentQueue<UT_IndexedHashMapItemId> UT_IndexedHashMap::UT_IndexedHashMapHoleQueue [protected] |
Definition at line 389 of file UT_IndexedHashMap.h.
typedef UT_ConcurrentHashMap<keyContainer, itemContainer *, keyCompare> UT_IndexedHashMap::UT_IndexedHashMapTable [protected] |
Definition at line 386 of file UT_IndexedHashMap.h.
typedef UT_ConcurrentVector<listContainer> UT_IndexedHashMap::UT_IndexedHashMapVector [protected] |
Definition at line 387 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 UT_IndexedHashMap::~UT_IndexedHashMap | ( | ) | [virtual] |
| InternalItemT* UT_IndexedHashMap::_add | ( | const InternalKeyT * | key, | |
| InternalItemT * | item = NULL, |
|||
| UT_IndexedHashMapItemId * | id = NULL | |||
| ) | [protected] |
| InternalItemT* UT_IndexedHashMap::_addReference | ( | UT_IndexedHashMapItemId | id | ) | [protected] |
| exint UT_IndexedHashMap::_extractItems | ( | UT_PtrArray< InternalItemT * > & | items | ) | const [protected] |
| exint UT_IndexedHashMap::_extractItems | ( | UT_ValArray< UT_IndexedHashMapItemId > & | ids, | |
| UT_PtrArray< InternalItemT * > & | items | |||
| ) | const [protected] |
| InternalItemT* UT_IndexedHashMap::_find | ( | const InternalKeyT * | key | ) | const [inline, protected] |
Definition at line 190 of file UT_IndexedHashMap.h.
| exint UT_IndexedHashMap::_findId | ( | const InternalKeyT * | key | ) | const [inline, protected] |
Definition at line 195 of file UT_IndexedHashMap.h.
| InternalItemT* UT_IndexedHashMap::_findItemAndId | ( | const InternalKeyT * | key, | |
| UT_IndexedHashMapItemId & | id | |||
| ) | const [protected] |
| InternalItemT* UT_IndexedHashMap::_get | ( | UT_IndexedHashMapItemId | id | ) | const [protected] |
| const InternalKeyT* UT_IndexedHashMap::_getKey | ( | UT_IndexedHashMapItemId | id | ) | const [protected] |
| bool UT_IndexedHashMap::_remove | ( | UT_IndexedHashMapItemId | id | ) | [protected] |
| bool UT_IndexedHashMap::_remove | ( | const InternalKeyT * | key | ) | [protected] |
| UT_IndexedHashMapItemId UT_IndexedHashMap::_replaceItem | ( | UT_IndexedHashMapItemId | id, | |
| const InternalKeyT * | key, | |||
| InternalItemT * | new_item = NULL | |||
| ) | [protected] |
| virtual bool UT_IndexedHashMap::areKeysEqual | ( | const InternalKeyT * | k1, | |
| const InternalKeyT * | k2 | |||
| ) | const [protected, pure virtual] |
| unsafe_iterator UT_IndexedHashMap::begin | ( | ) | const [inline] |
Definition at line 463 of file UT_IndexedHashMap.h.
| void UT_IndexedHashMap::bumpReferenceCounts | ( | int | dir | ) |
Bump reference counts for all items. Items will be deleted from the map if their reference count goes to 0 (or below). This is true even if dir is 0.
| 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.
This is a no-op if id's are not stored in the map
| virtual InternalKeyT* UT_IndexedHashMap::copyKey | ( | const InternalKeyT * | key | ) | const [protected, pure virtual] |
| virtual void UT_IndexedHashMap::deleteItem | ( | InternalItemT * | item | ) | const [protected, pure virtual] |
| virtual void UT_IndexedHashMap::deleteKey | ( | InternalKeyT * | key | ) | const [protected, pure virtual] |
| bool UT_IndexedHashMap::empty | ( | ) | const [inline] |
| unsafe_iterator UT_IndexedHashMap::end | ( | ) | const [inline] |
Definition at line 465 of file UT_IndexedHashMap.h.
| exint UT_IndexedHashMap::entries | ( | void | ) | const [inline] |
Return the number of entries in the map.
Definition at line 94 of file UT_IndexedHashMap.h.
| UT_IndexedHashMapItemId UT_IndexedHashMap::getItemIdUpperBound | ( | ) | const [inline] |
Return the maximum possible UT_IndexedHashMapItemId stored in the map. This returns an upper bound and is not exact.
Not supported if id's are not stored in the map
Definition at line 106 of file UT_IndexedHashMap.h.
| int64 UT_IndexedHashMap::getMemoryUsage | ( | ) | const |
Return approximate memory usage (not including item storage).
| fpreal UT_IndexedHashMap::getOccupancy | ( | ) | const [inline] |
Return the "occupancy" of the map.
Not supported if id's are not stored in the map
Definition at line 112 of file UT_IndexedHashMap.h.
| virtual uint UT_IndexedHashMap::hash | ( | const InternalKeyT * | key | ) | const [protected, pure virtual] |
| virtual bool UT_IndexedHashMap::isItemLessThan | ( | const InternalItemT * | a, | |
| const InternalItemT * | b | |||
| ) | const [protected, pure virtual] |
| virtual InternalItemT* UT_IndexedHashMap::newItem | ( | const InternalKeyT * | key | ) | const [protected, pure virtual] |
| void UT_IndexedHashMap::setReferenceCounts | ( | int | new_count | ) |
Set reference counts for all items to the value given. Note that unreferenced items will not be deleted from the map.
| 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.
This is a no-op if id's are not stored in the map
friend class itemCompare [friend] |
Definition at line 370 of file UT_IndexedHashMap.h.
friend class itemContainer [friend] |
Definition at line 223 of file UT_IndexedHashMap.h.
friend class keyContainer [friend] |
Definition at line 259 of file UT_IndexedHashMap.h.
1.5.9