13 #ifndef __UT_IndexedHashSet__
14 #define __UT_IndexedHashSet__
73 bool empty()
const {
return myMap.empty(); }
83 {
return getListSize()-1; }
90 exint lsize = getListSize();
91 exint hsize = myHoles.unsafe_size();
110 if (prev >= 0 && prev < myIdMap.
entries())
111 return myIdMap(prev);
125 myIdMap(prev) = curr;
169 return isValidId(
id) ? &myList[
id] :
nullptr;
172 bool remove(
const T &key);
177 template<
typename ID_ARRAY,
typename T_ARRAY>
180 exint maxitems)
const;
181 template<
typename ID_ARRAY,
typename T_ARRAY>
183 T_ARRAY &items)
const;
184 template<
typename T_ARRAY>
198 , myRefCount(refcount)
203 , myRefCount(
src.myRefCount)
208 , myRefCount(src.myRefCount)
250 typedef UT_ConcurrentQueue<UT_IndexedHashSetItemId>
266 , myIterator(src.myIterator)
275 const T &getKey()
const
276 {
return *myIterator; }
281 exint getItemShareCount()
const
282 {
return myMap->myMap[*myIterator].getRef(); }
287 bool atEnd()
const {
return myCurr >= mySize; }
294 }
while (myCurr < mySize && UT_IndexedHashSet::isValidKey(*myIterator));
299 if (atEnd() && it.atEnd())
301 return myMap == it.myMap &&
302 mySize == it.mySize &&
306 {
return !(*
this == it); }
311 , myIterator(map.myList.begin())
317 typename UT_IndexedHashSetVector::const_iterator myIterator;
318 exint mySize, myCurr;
333 , myIterator(src.myIterator)
342 {
return myIterator->first; }
345 {
return myIterator->second.getId(); }
348 {
return myIterator->second.getRef();}
353 bool atEnd()
const {
return myCurr >= mySize; }
359 UT_ASSERT_P(myCurr >= mySize || myIterator != myMap->myMap.end());
368 return myMap == it.myMap &&
372 {
return !(*
this == it); }
377 , myIterator(map.myMap.
begin())
383 typename UT_IndexedHashSetTable::const_iterator myIterator;
384 exint mySize, myCurr;
389 {
return unsafe_iterator(*
this); }
390 unsafe_iterator
end()
const
391 {
return unsafe_iterator(); }
393 {
return unsafe_listiterator(*
this); }
395 {
return unsafe_listiterator(); }
401 int getListSize()
const
406 {
return id >= 0 &&
id < getListSize(); }
410 static bool isValidKey(
const T &key);
414 static void invalidateKey(
T &key);
exint getItemShareCount() const
unsafe_listiterator beginList() const
unsafe_iterator & operator++()
exint entries() const
Find the number of entries in the map.
bool sortItems(const P &predicate)
unsafe_listiterator endList() const
UT_IndexedHashSetItemId findId(const T &key) const
UT_IndexedHashSetItemId getItemIdUpperBound() const
UT_ConcurrentVector< T > UT_IndexedHashSetVector
void setSizeNoInit(exint newsize)
SYS_FORCE_INLINE exint getRef() const
SYS_FORCE_INLINE void setId(UT_IndexedHashSetItemId id)
SYS_FORCE_INLINE UT_IndexedHashSetItemId getId() const
GLboolean GLboolean GLboolean GLboolean a
UT_IndexedHashSetItemId add(const T &key)
exint UT_IndexedHashSetItemId
Each item in the shared map is assigned a unique id.
A thread-safe hash map which stores indexed shared items.
const T * getOrderedItem(exint index, UT_IndexedHashSetItemId *id=nullptr) const
unsafe_iterator begin() const
bool operator==(const unsafe_iterator &it) const
const T * findItemAndId(const T &key, UT_IndexedHashSetItemId &id) const
bool empty() const
Return whether the map is empty.
static SYS_FORCE_INLINE bool equal(const T &a, const T &b)
SYS_FORCE_INLINE IdAndRefCount(UT_IndexedHashSetItemId id, exint refcount)
void replace(const UT_IndexedHashSet &src)
SYS_FORCE_INLINE IdAndRefCount()
WARNING: This initializes nothing; you must initialize separately.
int64 getMemoryUsage(bool inclusive) const
Return approximate memory usage (not including key or item storage)
fpreal getOccupancy() const
bool operator!=(const unsafe_iterator &it)
unsafe_iterator end() const
exint getReferenceCount(UT_IndexedHashSetItemId id) const
tbb::concurrent_hash_map< K, T, H, A > UT_ConcurrentHashMap
UT_IndexedHashSetItemId getItemId() const
GLboolean GLboolean GLboolean b
SYS_FORCE_INLINE T relaxedLoad() const
exint entries() const
Alias of size(). size() is preferred.
UT_ConcurrentHashMap< T, IdAndRefCount > UT_IndexedHashSetTable
exint extractItems(ID_ARRAY &ids, T_ARRAY &items, exint maxitems) const
bool compactIds(IdRemapping &remapping)
unsafe_iterator(const unsafe_iterator &src)
UT_IndexedHashSetItemId replaceItem(UT_IndexedHashSetItemId id, const T &key)
SYS_FORCE_INLINE IdAndRefCount(IdAndRefCount &&src)
Iterate over items in the map - this is arbitrary order.
SYS_FORCE_INLINE IdAndRefCount(const IdAndRefCount &src)
SYS_FORCE_INLINE const T * addReference(UT_IndexedHashSetItemId id)
void constant(const T &v)
Quickly set the array to a single value.
UT_ConcurrentQueue< UT_IndexedHashSetItemId > UT_IndexedHashSetHoleQueue
SYS_FORCE_INLINE void setRef(int d)
UT_IndexedHashSetItemId newId(UT_IndexedHashSetItemId prev) const
Query the new id associated with the previous id.
const T * addReference(UT_IndexedHashSetItemId id, int inc)
size_t hash_value(const CH_ChannelRef &ref)
static SYS_FORCE_INLINE uint hash(const T &key)
SYS_FORCE_INLINE int bumpRef(int d)