CompactUniqueIndex#
Fully qualified name: omni::graph::exec::unstable::CompactUniqueIndex
-
class CompactUniqueIndex#
Registry of unique indexes with recycling of released indexes.
Call acquireUniqueIndex() to retrieve a unique index. Indexes are “compact”, meaning abandoned indices will be reused. This means that if releaseUniqueIndex() is called with a value of 6, the next call to acquireUniqueIndex() will return 6.
This class is useful for assigning a stable unique index to a set of dynamic items.
This object is not ABI-safe.
- Thread Safety
Methods are not thread safe unless otherwise stated.
Public Types
Public Functions
-
CompactUniqueIndex() noexcept = default#
Constructor.
-
~CompactUniqueIndex() noexcept = default#
Destructor.
-
inline std::size_t acquireUniqueIndex() noexcept#
Returns a unique index.
If releaseUniqueIndex() was previously called, the value passed to it will be returned (i.e. the index will be recycled). Otherwise, a new index is allocated that is one greater than the current max index.
- Thread Safety
This method is not thread safe.
-
inline void releaseUniqueIndex(std::size_t indexToFree) noexcept#
Marks an index as no longer used.
A subsequent call to acquireUniqueIndex() will prefer reusing the index given to this method.
If
indexToFree
was not previously returned by acquireUniqueIndex, undefined behavior will result.- Thread Safety
This method is not thread safe.
-
inline std::size_t size() const noexcept#
Returns the size of the registry.
The maximum number of indices is returned, not the current number of “active” indices. Said differently, if acquireUniqueIndex() is called followed by releaseUniqueIndex(), size() would return 1 not 0.
- Thread Safety
This method is not thread safe.