7 #ifndef PXR_EXEC_VDF_MASK_H
8 #define PXR_EXEC_VDF_MASK_H
68 *
this = _GetAllOnes1();
76 _bits = _FindOrInsert(bits);
86 if (bits.GetSize() != 0) {
87 _bits = _FindOrEmplace(std::move(bits));
94 _bits.
swap(rhs._bits);
112 _bits = _FindOrInsert(bits);
120 if (!TF_VERIFY(_bits)) {
126 _bits = _FindOrEmplace(std::move(copy));
132 if (!TF_VERIFY(_bits)) {
136 return _bits->Get().IsSet(index);
144 if (!TF_VERIFY(_bits)) {
150 _bits = _FindOrEmplace(std::move(copy));
163 return _bits->Get().GetSize();
176 if (_bits == mask._bits) {
187 if (_bits == mask._bits) {
201 return _bits->Get().AreAllSet();
211 return _bits->Get().AreAllUnset();
221 return _bits->Get().IsAnySet();
231 return _bits->Get().GetFirstSet();
241 return _bits->Get().GetLastSet();
251 return _bits->Get().GetNumSet();
263 return _bits->Get().AreContiguouslySet();
272 return _bits == rhs._bits;
276 return !(*
this == rhs);
286 return lhs._bits < rhs._bits;
295 if (_bits == rhs._bits) {
314 if (_bits == rhs._bits) {
334 if (!_bits && TF_VERIFY(!rhs._bits)) {
354 if (!_bits && TF_VERIFY(!rhs._bits)) {
360 _bits = _FindOrEmplace(std::move(copy));
377 _bits = _FindOrEmplace(
400 using _BaseIterator = VdfMask::Bits::AllSetView::const_iterator;
412 return _it == rhs._it;
437 return _it.IsAtEnd();
443 _it = _BaseIterator();
459 while (!_it.IsAtEnd() && *_it <
index) {
469 _it(bits->GetAllSetView().
begin())
498 }
else if (size == 1) {
499 return _GetAllOnes1();
530 return std::string();
533 return _bits->Get().GetAsRLEString();
544 return _bits->Get().GetAllocatedSize();
566 return std::hash<_BitsImpl*>()(_bits.
get());
581 struct _AllOnes1Factory
585 return new VdfMask(_AllOnes1Factory());
589 explicit VdfMask(
const _AllOnes1Factory &) {
590 Bits allOnes1Bits(1);
591 allOnes1Bits.SetAll();
592 _bits = _FindOrInsert(allOnes1Bits);
595 static VdfMask _GetAllOnes1() {
609 _BitsImpl(
const _BitsImpl &) =
delete;
610 _BitsImpl&
operator=(
const _BitsImpl &) =
delete;
613 _BitsImpl(_BitsImpl &&) =
delete;
614 _BitsImpl&
operator=(_BitsImpl &&) =
delete;
631 _BitsImpl(_BitsImpl *next,
size_t hash,
VdfMask::Bits &&bits);
641 std::atomic<int> _refCount;
644 std::atomic<uint16_t> _resurrectionCount;
674 static void _EraseBits(_BitsImpl *bits);
689 if (p->_isImmortal) {
701 p->_refCount.fetch_add(1, std::memory_order_relaxed);
706 if (p->_isImmortal) {
715 const int prevRC = p->_refCount.fetch_sub(1, std::memory_order_release);
719 std::atomic_thread_fence(std::memory_order_acquire);
720 VdfMask::_EraseBits(p);
bool operator()(const VdfMask &lhs, const VdfMask &rhs) const
bool IsContiguous() const
VdfMask & operator-=(const VdfMask &rhs)
size_t GetFirstSet() const
void TfDelegatedCountIncrement(VdfMask::_BitsImpl *p) noexcept
size_t GetHash() const
Returns a hash for the mask.
_BaseIterator::value_type value_type
#define PXR_NAMESPACE_OPEN_SCOPE
A VdfMask is placed on connections to specify the data flowing through them.
static VdfMask AllOnes(size_t size)
friend class Vdf_MaskRegistry
bool HasNonEmptyDifference(const TfCompressedBits &rhs) const
VdfMask::Bits const & GetBits() const
Fast, compressed bit array which is capable of performing logical operations without first decompress...
VdfMask operator-(const VdfMask &rhs) const
bool operator!=(const iterator &rhs) const
VdfMask & operator&=(const VdfMask &rhs)
void SetIndex(size_t index)
RawPtrType get() const noexcept
Return the underlying pointer.
bool Overlaps(const VdfMask &mask) const
#define TF_DEV_AXIOM(cond)
VdfMask(VdfMask::Bits &&bits)
void ClearIndex(size_t index)
VDF_API std::ostream & operator<<(std::ostream &os, const VdfMask &mask)
bool operator==(const VdfMask &rhs) const
VdfMask operator^(const VdfMask &rhs) const
VdfMask & operator|=(const VdfMask &rhs)
bool Contains(const VdfMask &mask) const
size_t GetLastSet() const
friend void TfDelegatedCountIncrement(_BitsImpl *p) noexcept
friend VDF_API std::ostream & operator<<(std::ostream &os, const VdfMask &mask)
bool HasNonEmptyIntersection(const TfCompressedBits &rhs) const
friend void TfDelegatedCountDecrement(_BitsImpl *p) noexcept
VdfMask(VdfMask::Bits const &bits)
VdfMask & SetOrAppend(const VdfMask &rhs)
value_type operator*() const
void Swap(VdfMask &rhs) noexcept
static const TfCompressedBits & GetEmpty()
size_t GetMemoryUsage() const
LeafData & operator=(const LeafData &)=delete
#define PXR_NAMESPACE_CLOSE_SCOPE
static VdfMask AllZeros(size_t size)
TfCompressedBits & Complement()
VdfMask & operator^=(const VdfMask &rhs)
VdfMask operator&(const VdfMask &rhs) const
bool operator!=(const VdfMask &rhs) const
bool operator==(const iterator &rhs) const
std::string GetRLEString() const
friend void swap(VdfMask &lhs, VdfMask &rhs) noexcept
size_t operator()(const VdfMask &mask) const
int AdvanceTo(value_type index)
VdfMask operator|(const VdfMask &rhs) const
bool IsSet(size_t index) const
void swap(TfDelegatedCountPtr &other) noexcept
Swap this object's held pointer with other's.
void TfDelegatedCountDecrement(VdfMask::_BitsImpl *p) noexcept