class TBitfield

template<class Allocator = DefaultContainerAllocator>

Dynamically sized field that contains a sequential list of bits.

The bits are compactly stored and allow for quick sequential searches (compared to single or multi-byte type sequential searches).

Public

Constructors

TBitfield<Allocator>

TBitfield<Allocator>(bool value = false, u64 count = 0)

Initializes the bitfield with enough storage for bits and sets them to the initial value of .

TBitfield<Allocator>

TBitfield<Allocator>(const TBitfield<Allocator> &other)

TBitfield<Allocator>

TBitfield<Allocator>(TBitfield<Allocator> &&other)

Methods

~TBitfield<Allocator>

~TBitfield<Allocator>() = default

Add

u64 Add(bool value)

Adds a new bit value to the end of the bitfield and returns the index of the added bit.

Remove

void Remove(u64 index)

Removes a bit at the specified index.

Find

u64 Find(bool value) const

Attempts to find the first non-zero bit in the field.

Returns -1 if all bits are zero or the field is empty.

Count

u64 Count(bool value) const

Counts the number of values in the bit field.

Resize

void Resize(u64 size, bool value = false)

Resizes the bitfield to the specified number of elements, initializing any new elements with .

Reserve

void Reserve(u64 size)

Resizes the internal buffer to the specified size, but doesn't add any new elements.

If existing capacity is equal or larger than the requested size, no operation is performed.

Reset

void Reset(bool value = false)

Resets all the bits in the field to the specified value.

Clear

void Clear(bool free = false)

Removes all the bits from the field.

If is true then the underlying memory buffers will be freed as well.

Size

u64 Size() const

Returns the number of bits in the bitfield.

Capacity

u64 Capacity() const

Returns the total allocated capacity of the bitfield, in number of bits.

Data

const u32 *Data() const

Returns the underlying bitfield data.

Data is always sequential and allocated using 32-bit alignment.

Data

u32 *Data()

Returns the underlying bitfield data.

Begin

Iterator Begin()

Returns a non-const iterator pointing to the first bit in the bitfield.

End

Iterator End()

Returns a non-const interator pointing past the last bit in the bitfield.

Begin

ConstIterator Begin() const

Returns a const iterator pointing to the first bit in the bitfield.

End

ConstIterator End() const

Returns a const interator pointing past the last bit in the bitfield.

begin

Iterator begin()

end

Iterator end()

begin

ConstIterator begin() const

end

ConstIterator end() const

Operators

operator=

TBitfield<Allocator> &operator=(const TBitfield<Allocator> &rhs)

operator=

TBitfield<Allocator> &operator=(TBitfield<Allocator> &&rhs)

operator[]

BitReference operator[](u64 index)

operator[]

BitReferenceConst operator[](u64 index) const

Private

Methods

Realloc

void Realloc(u64 bitCapacity)

Reallocates the internal buffer making enough room for (rounded to a multiple of 32-bits).

Fields

mAllocator

typename Allocator::template ForElementType<u32> mAllocator

mMaxBits

u64 mMaxBits

mNumBits

u64 mNumBits