35 void Resize(uint64_t numBits);
40 void SetBit(
const uint64_t bitIndex);
42 void ClearBit(
const uint64_t bitIndex);
44 bool IsSet(
const uint64_t bitIndex)
const;
46 void MoveBit(
const uint64_t from,
const uint64_t to);
88 SizeT const numWords = (
SizeT)((numBits + 63) / 64);
101 this->
Resize(bitIndex + 1);
110 this->
Resize(bitIndex + 1);
111 this->
words[bitIndex / 64] |= (1ULL << (bitIndex % 64));
120 if (bitIndex / 64 >= (uint64_t)this->
words.
Size())
124 this->
words[bitIndex / 64] &= ~(1ULL << (bitIndex % 64));
133 if (bitIndex / 64 >= (uint64_t)this->
words.
Size())
137 return (this->
words[bitIndex / 64] >> (bitIndex % 64)) & 1ULL;
146 bool const set = this->
IsSet(from);
162 if (this->
words[i] != 0)
176 if (section >= (uint64_t)this->
words.
Size())
180 return this->
words[section] == 0;
198 if (section >= (uint64_t)this->
words.
Size())
202 uint64_t
const word = this->
words[section];
208 uint64_t remaining = word;
209 while ((remaining & 1ULL) == 0)
214 return (
IndexT)(section * 64 + (uint64_t)bit);
Nebula's dynamic array class.
Definition array.h:61
void Clear()
clear array (calls destructors)
Definition array.h:1288
void Resize(SizeT num)
Set size. Grows array if num is greater than capacity. Calls destroy on all objects at index > num!
Definition array.h:1711
const SizeT Size() const
get number of elements in array
Definition array.h:934
~BitArray()
destructor
Definition bitarray.h:78
bool SectionIsNull(const uint64_t section) const
true when a whole 64 bit section is empty
Definition bitarray.h:174
void MoveBit(const uint64_t from, const uint64_t to)
move a bit from one index to another. The source is cleared and the target gets the value
Definition bitarray.h:144
void EnsureBit(uint64_t bitIndex)
make a bit addressable, growing the array when it is outside
Definition bitarray.h:99
BitArray()
constructor
Definition bitarray.h:70
Util::Array< uint64_t > words
Definition bitarray.h:63
bool IsNull() const
true when no bit is set
Definition bitarray.h:158
void Resize(uint64_t numBits)
resize to a number of bits. Growing keeps the bits which are already set, shrinking is not supported
Definition bitarray.h:86
SizeT NumSections() const
number of 64 bit sections which are allocated
Definition bitarray.h:187
void Reset()
clear all bits and release the storage
Definition bitarray.h:233
void ClearBit(const uint64_t bitIndex)
clear a bit by index. Does nothing when the index is outside the array
Definition bitarray.h:118
bool IsSet(const uint64_t bitIndex) const
check a bit by index. False when the index is outside the array
Definition bitarray.h:131
IndexT FirstSetBitInSection(const uint64_t section) const
the index of the first set bit in a section, or InvalidIndex when the section is empty
Definition bitarray.h:196
void Clear()
clear all bits. The allocated words are kept
Definition bitarray.h:221
void SetBit(const uint64_t bitIndex)
set a bit by index, growing the array when the index is outside it
Definition bitarray.h:108
A quad tree designed to return regions of free 2D space.
Definition Random.cs:4
int SizeT
Definition types.h:42
int IndexT
Definition types.h:41