13 #ifndef __UT_IndexedHashSet__
14 #define __UT_IndexedHashSet__
67 bool empty()
const {
return myMap.empty(); }
76 {
return getListSize()-1; }
82 exint lsize = getListSize();
83 exint hsize = myHoles.unsafe_size();
102 if (prev >= 0 && prev < myIdMap.
entries())
103 return myIdMap(prev);
117 myIdMap(prev) = curr;
162 return isValidId(
id) ? &myList[
id] :
nullptr;
165 bool remove(
const T &key);
170 template<
typename ID_ARRAY,
typename T_ARRAY>
173 exint maxitems)
const;
174 template<
typename ID_ARRAY,
typename T_ARRAY>
176 T_ARRAY &items)
const;
177 template<
typename T_ARRAY>
191 , myRefCount(refcount)
196 , myRefCount(
src.myRefCount)
201 , myRefCount(src.myRefCount)
227 typedef UT_ConcurrentQueue<UT_IndexedHashSetItemId>
243 , myIterator(src.myIterator)
252 const T &getKey()
const
253 {
return *myIterator; }
258 exint getItemShareCount()
const
259 {
return myMap->myMap[*myIterator].getRef(); }
264 bool atEnd()
const {
return myCurr >= mySize; }
271 }
while (myCurr < mySize && UT_IndexedHashSet::isValidKey(*myIterator));
276 if (atEnd() && it.atEnd())
278 return myMap == it.myMap &&
279 mySize == it.mySize &&
283 {
return !(*
this == it); }
288 , myIterator(map.myList.begin())
294 typename UT_IndexedHashSetVector::const_iterator myIterator;
295 exint mySize, myCurr;
310 , myIterator(src.myIterator)
319 {
return myIterator->first; }
322 {
return myIterator->second.getId(); }
325 {
return myIterator->second.getRef();}
330 bool atEnd()
const {
return myCurr >= mySize; }
336 UT_ASSERT_P(myCurr >= mySize || myIterator != myMap->myMap.end());
345 return myMap == it.myMap &&
349 {
return !(*
this == it); }
354 , myIterator(map.myMap.
begin())
360 typename UT_IndexedHashSetTable::const_iterator myIterator;
361 exint mySize, myCurr;
366 {
return unsafe_iterator(*
this); }
367 unsafe_iterator
end()
const
368 {
return unsafe_iterator(); }
370 {
return unsafe_listiterator(*
this); }
372 {
return unsafe_listiterator(); }
378 int getListSize()
const
383 {
return id >= 0 &&
id < getListSize(); }
387 static bool isValidKey(
const T &key);
391 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
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.
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
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)
SYS_FORCE_INLINE int bumpRef(int d)