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();
109 if (prev >= 0 && prev < myIdMap.
entries())
110 return myIdMap(prev);
124 myIdMap(prev) = curr;
168 return isValidId(
id) ? &myList[
id] :
nullptr;
171 bool remove(
const T &key);
176 template<
typename ID_ARRAY,
typename T_ARRAY>
179 exint maxitems)
const;
180 template<
typename ID_ARRAY,
typename T_ARRAY>
182 T_ARRAY &items)
const;
183 template<
typename T_ARRAY>
197 , myRefCount(refcount)
202 , myRefCount(
src.myRefCount)
207 , myRefCount(src.myRefCount)
246 typedef UT_ConcurrentHashMap<T, IdAndRefCount>
249 typedef UT_ConcurrentQueue<UT_IndexedHashSetItemId>
265 , myIterator(src.myIterator)
274 const T &getKey()
const
275 {
return *myIterator; }
280 exint getItemShareCount()
const
281 {
return myMap->myMap[*myIterator].getRef(); }
286 bool atEnd()
const {
return myCurr >= mySize; }
293 }
while (myCurr < mySize && UT_IndexedHashSet::isValidKey(*myIterator));
298 if (atEnd() && it.atEnd())
300 return myMap == it.myMap &&
301 mySize == it.mySize &&
305 {
return !(*
this == it); }
310 , myIterator(map.myList.begin())
316 typename UT_IndexedHashSetVector::const_iterator myIterator;
317 exint mySize, myCurr;
332 , myIterator(src.myIterator)
341 {
return myIterator->first; }
344 {
return myIterator->second.getId(); }
347 {
return myIterator->second.getRef();}
352 bool atEnd()
const {
return myCurr >= mySize; }
358 UT_ASSERT_P(myCurr >= mySize || myIterator != myMap->myMap.end());
367 return myMap == it.myMap &&
371 {
return !(*
this == it); }
376 , myIterator(map.myMap.
begin())
382 typename UT_IndexedHashSetTable::const_iterator myIterator;
383 exint mySize, myCurr;
388 {
return unsafe_iterator(*
this); }
389 unsafe_iterator
end()
const
390 {
return unsafe_iterator(); }
392 {
return unsafe_listiterator(*
this); }
394 {
return unsafe_listiterator(); }
400 int getListSize()
const
405 {
return id >= 0 &&
id < getListSize(); }
409 static bool isValidKey(
const T &key);
413 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
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)