Apparatus Version 1.2.1
ECS data-driven workflow for Unreal Engine.
Classes | Public Member Functions | Public Attributes | Friends | List of all members
FBitMask Struct Reference

A memory-efficient bit mask. More...

#include <BitMask.h>

Classes

struct  Iterator
 The bit mask iterator. More...
 

Public Member Functions

int32 Num () const
 The current number of meaningful bits in the mask. More...
 
 FBitMask ()
 Construct a new empty bit mask. More...
 
 FBitMask (const FBitMask &InBitMask)
 Copy-construct the bit mask. More...
 
 FBitMask (FBitMask &&InBitMask)
 Move-construct the bit mask. More...
 
 FBitMask (const int32 Capacity)
 Initialize a new instance of a mask with bit capacity. More...
 
bool At (const int32 Index) const
 Get the bit flag at the specified index. More...
 
bool operator[] (const int32 Index) const
 Get a bit element by its index. More...
 
void SetAt (const int32 Index, const bool Value)
 Set a bit at a specific index. More...
 
bool IsNonZero () const
 Check if there are any non-zero bits in the mask. More...
 
EApparatusStatus Trim () const
 Trim the meaningless high groups. More...
 
bool IsAllZeroes () const
 Check if all of the bits in the mask are zeroes or none. More...
 
int32 CountNonZeroGroups () const
 Get the number of meaningful (non-zero) bit groups. More...
 
EApparatusStatus Set (FBitMask &&InBitMask)
 Move the bit mask to this bit mask. More...
 
EApparatusStatus Set (const FBitMask &InBitMask)
 Set this bit mask equal to another bit mask. More...
 
FBitMaskoperator= (FBitMask &&InBitMask)
 Move the bit mask. More...
 
FBitMaskoperator= (const FBitMask &InBitMask)
 Set this bit mask equal to another bit mask. More...
 
int32 DifferencesCount (const FBitMask &BitMask) const
 Get the number of different bits in two masks. More...
 
int32 InclusionsCount (const FBitMask &BitMask) const
 Get the number of included bits in two masks. More...
 
bool Includes (const FBitMask &BitMask) const
 Does the mask has all of the bits set in the supplied mask. More...
 
bool IncludesPartially (const FBitMask &BitMask) const
 Check if the mask has any of the bits set in the supplied mask. More...
 
bool Contains (const bool bit) const
 Does a bit mask contain the specified bit? More...
 
Iterator begin ()
 
Iterator end ()
 
int32 IndexOf (const bool bit) const
 Get the index of the first matching bit in the mask. More...
 
void EnsureGroupsNum (int32 InGroupsCount)
 Ensure a bit group count. More...
 
void EnsureGroupsForBitAt (const int32 BitIndex)
 Ensure that there is enough bit groups for an index. More...
 
int32 Max () const
 Get the current maximum number of bits that can be stored without any additional allocations. More...
 
void Reserve (const int32 BitCapacity)
 Reserve space for a given number of bits. More...
 
void Add (const bool Bit)
 Add a bit to the end of the mask. More...
 
void Empty (const int32 Slack=0)
 Empties the array. More...
 
void Reset (const int32 NewSize=0)
 Same as empty, but doesn't change memory allocations, unless the new size is larger than the current array. More...
 
void SetMasked (const FBitMask &Mask, const bool State)
 Set the bits based on a mask. More...
 
void CopyTo (bool *Array, int32 Offset) const
 Copy the bits to an array, with a specified offset. More...
 
void Insert (const int32 Index, const bool Bit)
 Insert a bit at the specified index. More...
 
void Remove (const bool Bit)
 Remove the first occurrence of the specified bit from the mask. More...
 
void RemoveAt (const int32 Index)
 Remove the bit at the specified index. More...
 
void Erase (const int32 Index)
 Remove an element at the specified index. More...
 
void CopyTo (TArray< bool > &OutArray, const int32 Offset=0)
 Copy to an array with a supplied offset. More...
 
FBitMaskAndWith (const FBitMask &InMask)
 And the bitmask with a given mask. More...
 
FBitMaskoperator&= (const FBitMask &InMask)
 And the bitmask with a given mask. More...
 
FBitMaskOrWith (const FBitMask &InMask)
 Or the bitmask with a given mask. More...
 
FBitMaskoperator|= (const FBitMask &InMask)
 Or the bitmask with a given mask. More...
 
FString ToString () const
 Convert the bit mask to a string representation. More...
 
uint32 CalcHash () const
 Calculate the bit mask hash. More...
 

Public Attributes

friend Iterator
 

Friends

class StaticConstructor
 
uint32 GetTypeHash (const FBitMask &bm)
 
std::ostream & operator<< (std::ostream &Str, const FBitMask &v)
 
bool operator== (const FBitMask &a, const FBitMask &b)
 
bool operator!= (const FBitMask &a, const FBitMask &b)
 
FBitMask operator& (const FBitMask &a, const FBitMask &b)
 
FBitMask operator| (const FBitMask &a, const FBitMask &b)
 

Detailed Description

A memory-efficient bit mask.

Please, not that this is not a bit array and serves different purposes.

Constructor & Destructor Documentation

◆ FBitMask() [1/4]

FBitMask::FBitMask ( )
inline

Construct a new empty bit mask.

◆ FBitMask() [2/4]

FBitMask::FBitMask ( const FBitMask InBitMask)
inline

Copy-construct the bit mask.

◆ FBitMask() [3/4]

FBitMask::FBitMask ( FBitMask &&  InBitMask)
inline

Move-construct the bit mask.

◆ FBitMask() [4/4]

FBitMask::FBitMask ( const int32  Capacity)
inline

Initialize a new instance of a mask with bit capacity.

Member Function Documentation

◆ Add()

void FBitMask::Add ( const bool  Bit)

Add a bit to the end of the mask.

◆ AndWith()

FBitMask& FBitMask::AndWith ( const FBitMask InMask)
inline

And the bitmask with a given mask.

◆ At()

bool FBitMask::At ( const int32  Index) const
inline

Get the bit flag at the specified index.

Parameters
IndexThe index of the bit to get. If it's out of the number of elements, false is returned.
Returns
The state of the bit at the specified index.

◆ begin()

Iterator FBitMask::begin ( )
inline

◆ CalcHash()

uint32 FBitMask::CalcHash ( ) const
inline

Calculate the bit mask hash.

◆ Contains()

bool FBitMask::Contains ( const bool  bit) const

Does a bit mask contain the specified bit?

◆ CopyTo() [1/2]

void FBitMask::CopyTo ( bool *  Array,
int32  Offset 
) const
inline

Copy the bits to an array, with a specified offset.

◆ CopyTo() [2/2]

void FBitMask::CopyTo ( TArray< bool > &  OutArray,
const int32  Offset = 0 
)
inline

Copy to an array with a supplied offset.

◆ CountNonZeroGroups()

int32 FBitMask::CountNonZeroGroups ( ) const
inline

Get the number of meaningful (non-zero) bit groups.

◆ DifferencesCount()

int32 FBitMask::DifferencesCount ( const FBitMask BitMask) const

Get the number of different bits in two masks.

◆ Empty()

void FBitMask::Empty ( const int32  Slack = 0)
inline

Empties the array.

It calls the destructors on held flags if needed.

Parameters
Slack(Optional) The expected usage size in bits after empty operation. Default is 0.

◆ end()

Iterator FBitMask::end ( )
inline

◆ EnsureGroupsForBitAt()

void FBitMask::EnsureGroupsForBitAt ( const int32  BitIndex)
inline

Ensure that there is enough bit groups for an index.

◆ EnsureGroupsNum()

void FBitMask::EnsureGroupsNum ( int32  InGroupsCount)
inline

Ensure a bit group count.

◆ Erase()

void FBitMask::Erase ( const int32  Index)
inline

Remove an element at the specified index.

Parameters
indexAn index of the element to erase.

◆ Includes()

bool FBitMask::Includes ( const FBitMask BitMask) const
inline

Does the mask has all of the bits set in the supplied mask.

The same as a bitwise A & B == B.

◆ IncludesPartially()

bool FBitMask::IncludesPartially ( const FBitMask BitMask) const
inline

Check if the mask has any of the bits set in the supplied mask.

The same as a bitwise A & B != 0.

◆ InclusionsCount()

int32 FBitMask::InclusionsCount ( const FBitMask BitMask) const

Get the number of included bits in two masks.

◆ IndexOf()

int32 FBitMask::IndexOf ( const bool  bit) const

Get the index of the first matching bit in the mask.

◆ Insert()

void FBitMask::Insert ( const int32  Index,
const bool  Bit 
)

Insert a bit at the specified index.

◆ IsAllZeroes()

bool FBitMask::IsAllZeroes ( ) const
inline

Check if all of the bits in the mask are zeroes or none.

◆ IsNonZero()

bool FBitMask::IsNonZero ( ) const
inline

Check if there are any non-zero bits in the mask.

◆ Max()

int32 FBitMask::Max ( ) const
inline

Get the current maximum number of bits that can be stored without any additional allocations.

◆ Num()

int32 FBitMask::Num ( ) const
inline

The current number of meaningful bits in the mask.

This value doesn't play any role when comparing the masks.

◆ operator&=()

FBitMask& FBitMask::operator&= ( const FBitMask InMask)
inline

And the bitmask with a given mask.

◆ operator=() [1/2]

FBitMask& FBitMask::operator= ( const FBitMask InBitMask)
inline

Set this bit mask equal to another bit mask.

◆ operator=() [2/2]

FBitMask& FBitMask::operator= ( FBitMask &&  InBitMask)
inline

Move the bit mask.

◆ operator[]()

bool FBitMask::operator[] ( const int32  Index) const
inline

Get a bit element by its index.

◆ operator|=()

FBitMask& FBitMask::operator|= ( const FBitMask InMask)
inline

Or the bitmask with a given mask.

◆ OrWith()

FBitMask& FBitMask::OrWith ( const FBitMask InMask)
inline

Or the bitmask with a given mask.

◆ Remove()

void FBitMask::Remove ( const bool  Bit)

Remove the first occurrence of the specified bit from the mask.

◆ RemoveAt()

void FBitMask::RemoveAt ( const int32  Index)

Remove the bit at the specified index.

Parameters
IndexThe index of the bit to remove.

◆ Reserve()

void FBitMask::Reserve ( const int32  BitCapacity)
inline

Reserve space for a given number of bits.

◆ Reset()

void FBitMask::Reset ( const int32  NewSize = 0)
inline

Same as empty, but doesn't change memory allocations, unless the new size is larger than the current array.

Parameters
NewSizeThe expected usage size in bits after calling this function.

◆ Set() [1/2]

EApparatusStatus FBitMask::Set ( const FBitMask InBitMask)
inline

Set this bit mask equal to another bit mask.

◆ Set() [2/2]

EApparatusStatus FBitMask::Set ( FBitMask &&  InBitMask)
inline

Move the bit mask to this bit mask.

◆ SetAt()

void FBitMask::SetAt ( const int32  Index,
const bool  Value 
)
inline

Set a bit at a specific index.

◆ SetMasked()

void FBitMask::SetMasked ( const FBitMask Mask,
const bool  State 
)
inline

Set the bits based on a mask.

Parameters
MaskThe mask to use.
StateThe state to set.

◆ ToString()

FString FBitMask::ToString ( ) const
inline

Convert the bit mask to a string representation.

◆ Trim()

EApparatusStatus FBitMask::Trim ( ) const
inline

Trim the meaningless high groups.

Friends And Related Function Documentation

◆ GetTypeHash

uint32 GetTypeHash ( const FBitMask bm)
friend

◆ operator!=

bool operator!= ( const FBitMask a,
const FBitMask b 
)
friend

◆ operator&

FBitMask operator& ( const FBitMask a,
const FBitMask b 
)
friend

◆ operator<<

std::ostream& operator<< ( std::ostream &  Str,
const FBitMask v 
)
friend

◆ operator==

bool operator== ( const FBitMask a,
const FBitMask b 
)
friend

◆ operator|

FBitMask operator| ( const FBitMask a,
const FBitMask b 
)
friend

◆ StaticConstructor

friend class StaticConstructor
friend

Member Data Documentation

◆ Iterator


The documentation for this struct was generated from the following files: