44 void cycle(
exint shift_offset);
47 void setSize(
exint new_size);
57 const BlockType *
data()
const {
return myBits; }
59 exint numBitsSet()
const;
60 exint numBitsClear()
const;
62 bool allBitsSet()
const;
63 bool allBitsClear()
const;
65 inline bool getBit(
exint index)
const;
67 inline bool setBit(
exint index,
bool value);
68 inline bool toggleBit(
exint index);
70 inline bool getBitFast(
exint index)
const;
71 inline void setBitFast(
exint index,
bool value);
72 inline void toggleBitFast(
exint index);
74 void setBits(
exint index,
exint nbits,
bool value);
77 void setAllBits(
bool value);
81 int save(std::ostream &os,
bool binary =
false)
const;
90 exint iterateInit()
const;
101 exint findFirstBit()
const;
102 exint findLastBit()
const;
116 {
return !(*
this == in_map); }
125 int64 mem = inclusive ?
sizeof(*this) : 0;
126 mem += myWordCount*
sizeof(BlockType);
130 uint computeHash()
const;
134 public std::iterator<std::forward_iterator_tag, exint>
156 return myArray == i.myArray
157 && myIndex == i.myIndex
158 && mySize == i.mySize;
162 return !(*
this == i);
166 return myIndex >= mySize;
175 myIndex = myArray->iterateInit();
182 myIndex = myArray->iterateNext(myIndex);
189 , mySize(array->size())
209 static const int myBitsPerWord =
sizeof(BlockType)*8;
210 static const int myWordShift =
SYS_LOG2F(myBitsPerWord);
211 static const int myWordMask = (1 << myWordShift) - 1;
219 void swapBlocks32(BlockType *blocks,
exint nb_blocks)
const;
226 return (bit >> myWordShift);
230 static inline BlockType
233 return (BlockType(1) << (bit & myWordMask));
238 numWords(
exint size_in_bits)
240 return (size_in_bits + (myBitsPerWord - 1)) / myBitsPerWord;
243 void outTo(std::ostream &os)
const;
267 word = myBits + indexWord(index);
268 return ((*word & indexBit(index)) != 0);
284 word = myBits + indexWord(index);
285 mask = indexBit(index);
286 previous = *word &
mask;
288 if( value ) *word |=
mask;
291 return (previous != 0);
307 word = myBits + indexWord(index);
308 mask = indexBit(index);
309 previous = *word &
mask;
313 return (previous != 0);
320 BlockType word = myBits[indexWord(index)];
321 int bit = index & myWordMask;
322 return (word >> bit) & BlockType(1);
329 BlockType &word = myBits[indexWord(index)];
330 int bit = index & myWordMask;
331 word = (BlockType(value) << bit) | (word & ~(BlockType(1) << bit));
338 BlockType &word = myBits[indexWord(index)];
339 int bit = index & myWordMask;
340 word ^= (BlockType(1) << bit);
344 UT_BitArray::iterateFromWord(
uint64 word_index)
const
346 for (; word_index < myWordCount; word_index++)
348 if (myBits[word_index])
350 exint bit_index = SYSfirstBitSet(myBits[word_index]);
352 return bit_index + (word_index << myWordShift);
363 return iterateFromWord(0);
371 return iterateFromWord(0);
374 if (current_bit >= (myBitCount - 1))
377 int bit_index = current_bit & myWordMask;
378 exint word_index = current_bit >> myWordShift;
379 BlockType *word = &myBits[word_index];
381 bit_index = SYSnextBitSet(*word, bit_index);
385 return bit_index + (word_index << myWordShift);
389 return iterateFromWord(word_index);
int64 getMemoryUsage(bool inclusive=true) const
GLboolean GLboolean GLboolean b
GLenum GLuint GLsizei bufsize
bool getBit(exint index) const
#define SYS_DEPRECATED(__V__)
bool getBitFast(exint index) const
bool toggleBit(exint index)
const GLuint GLenum const void * binary
exint iterateNext(exint current_bit) const
void swap(T &lhs, T &rhs)
bool operator!=(const iterator &i) const
bool operator[](exint index) const
unsigned long long uint64
std::enable_if< UT_EnableBitMask< T >::enable, T & >::type operator&=(T &lhs, T rhs)
OIIO_FORCEINLINE vbool4 insert(const vbool4 &a, bool val)
Helper: substitute val for a[i].
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
void toggleBitFast(exint index)
bool operator==(const iterator &i) const
void setBitFast(exint index, bool value)
Iterate over bits that are turned on.
const BlockType * data() const
friend std::ostream & operator<<(std::ostream &os, const UT_BitArray &map)
bool setBit(exint index, bool value)
void iterateInit(exint &i) const
bool operator!=(const UT_BitArray &in_map) const
ImageBuf OIIO_API resize(const ImageBuf &src, string_view filtername="", float filterwidth=0.0f, ROI roi={}, int nthreads=0)
exint getBit() const
Get the current iteration state.
UT_API size_t format(char *buffer, size_t bufsize, const UT_BitArray &b)
Overload for custom formatting of a UT_BitArray. with UTformat.
std::enable_if< UT_EnableBitMask< T >::enable, T & >::type operator^=(T &lhs, T rhs)
exint iterateInit() const
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 bool intersects(const Box< Vec3< T >> &b, const Line3< T > &r, Vec3< T > &ip) IMATH_NOEXCEPT
OIIO_FORCEINLINE const vint4 & operator-=(vint4 &a, const vint4 &b)
bool operator()(exint index) const
std::enable_if< UT_EnableBitMask< T >::enable, T & >::type operator|=(T &lhs, T rhs)