11 #ifndef __UT_IndexedHashMapT__
12 #define __UT_IndexedHashMapT__
29 template <
typename KEY>
50 const KEY &
getKey()
const {
return *myKey; }
52 {
return *myKey < *i.myKey; }
70 UT_ASSERT(0 &&
"User must define an allocator for deferred allocation");
77 template <
typename KEY,
typename ITEM>
85 return new ITEM(*(static_cast<const KEY *>(key)));
123 template <
typename KEY,
typename ITEM,
132 {
return static_cast<KEY *
>(key); }
134 {
return static_cast<const KEY *
>(key); }
136 {
return static_cast<ITEM *
>(item); }
138 {
return static_cast<const ITEM *
>(item); }
142 {
return castKEY(key)->hash(); }
147 {
return new KEY(*
castKEY(key)); }
153 return DEFER_ALLOC::newItem(key);
177 int64 mem = inclusive ?
sizeof(*this) : 0;
191 ITEM *
add(
const KEY &key, ITEM *item=NULL,
210 ITEM *
find(
const KEY &key)
const
257 bool remove(
const KEY &key)
282 const KEY &key, ITEM *item=NULL)
SYS_FORCE_INLINE const KEY * castKEY(const InternalKeyT *key) const
UT_IndexedHashMapItemId replaceItem(const KEY &old_key, const KEY &new_key)
UT_IndexedHashMapItemKeyContainer(const UT_IndexedHashMapItemKeyContainer &i)
UT_IndexedHashMapT(bool store_ids=true)
~UT_IndexedHashMapT() override
SYS_FORCE_INLINE KEY * castKEY(InternalKeyT *key) const
InternalItemT * _get(UT_IndexedHashMapItemId id) const
InternalKeyT * copyKey(const InternalKeyT *key) const override
void _replace(const UT_IndexedHashMap &src)
ITEM * find(const KEY &key) const
InternalItemT * _addReference(UT_IndexedHashMapItemId id, int inc)
GLboolean GLboolean GLboolean GLboolean a
UT_IndexedHashMapItemId _replaceItem(UT_IndexedHashMapItemId id, const InternalKeyT *key, InternalItemT *new_item=NULL)
InternalItemT * newItem(const InternalKeyT *key) const override
UT_IndexedHashMapItemId replaceItem(UT_IndexedHashMapItemId id, const KEY &key, ITEM *item=NULL)
static UT_IndexedHashMap::InternalItemT * newItem(const UT_IndexedHashMap::InternalKeyT *key)
Return NULL (don't allow deferred construction).
exint extractItems(UT_Array< UT_IndexedHashMapItemId > &ids, UT_Array< ITEM * > &items) const
exint _extractItems(UT_Array< UT_IndexedHashMapItemId > &ids, UT_Array< InternalItemT * > &items, exint maxitems) const
const KEY & getKey() const
A thread-safe hash map which stores indexed shared items.
void deleteItem(InternalItemT *item) const override
exint extractItems(UT_Array< UT_IndexedHashMapItemId > &ids, UT_Array< ITEM * > &items, exint maxitems) const
ITEM * getOrderedItem(exint index, UT_IndexedHashMapItemId *id=NULL) const
bool isItemLessThan(const InternalItemT *a, const InternalItemT *b) const override
UT_IndexedHashMapItemKeyContainer< UT_IndexedHashMapStringKey > UT_IndexedHashMapStringItem
bool _remove(const InternalKeyT *key)
UT_IndexedHashMapItemKeyContainer & operator=(const UT_IndexedHashMapItemKeyContainer &src)
InternalItemT * _getOrderedItem(exint index, UT_IndexedHashMapItemId *id) const
UT_IndexedHashMapItemKeyContainer(const KEY &k)
int64 getMemoryUsage(bool inclusive) const
Return approximate memory usage (not including key or item storage)
ITEM * addReference(UT_IndexedHashMapItemId id, int inc)
UT_StringHolder UT_IndexedHashMapStringKey
static UT_IndexedHashMap::InternalItemT * newItem(const UT_IndexedHashMap::InternalKeyT *key)
void deleteKey(InternalKeyT *key) const override
exint _findId(const InternalKeyT *key) const
GLboolean GLboolean GLboolean b
bool operator<(const UT_IndexedHashMapItemKeyContainer &i) const
ITEM * operator[](const KEY &k) const
SYS_FORCE_INLINE const ITEM * castITEM(const InternalItemT *item) const
An allocator object which dis-allows deferred allocation of items.
bool areKeysEqual(const InternalKeyT *k1, const InternalKeyT *k2) const override
const InternalKeyT * _getKey(UT_IndexedHashMapItemId id) const
ITEM * operator()(const KEY &k) const
InternalItemT * _add(const InternalKeyT *key, InternalItemT *item=NULL, UT_IndexedHashMapItemId *id=NULL)
void replace(const UT_IndexedHashMapT< KEY, ITEM, DEFER_ALLOC > &src)
Replaces the content of this with the content of src.
SYS_FORCE_INLINE ITEM * castITEM(InternalItemT *item) const
A thread-safe hash map which stores indexed shared items.
ITEM * operator[](UT_IndexedHashMapItemId id) const
ITEM * find(const KEY &key, UT_IndexedHashMapItemId &id) const
uint hash(const InternalKeyT *key) const override
Methods for keys.
UT_IndexedHashMapItemId findId(const KEY &key) const
ITEM * operator()(UT_IndexedHashMapItemId id) const
~UT_IndexedHashMapItemKeyContainer()
InternalItemT * _find(const InternalKeyT *key) const
InternalItemT * _findItemAndId(const InternalKeyT *key, UT_IndexedHashMapItemId &id) const
int64 getMemoryUsage(bool inclusive) const
int UT_IndexedHashMapItemId
Each item in the shared map is assigned a unique id.
const KEY * getKey(UT_IndexedHashMapItemId id) const
exint extractItems(UT_Array< ITEM * > &items) const
ITEM * add(const KEY &key, ITEM *item=NULL, UT_IndexedHashMapItemId *id=NULL)
ITEM * addReference(UT_IndexedHashMapItemId id)