|
Apparatus
Version 1.23
ECS data-oriented workflow for Unreal Engine.
|
A memory-efficient bit mask. More...
#include <BitMask.h>
Classes | |
| struct | ConstIterator |
| The bit mask bit iterator. More... | |
| struct | FBitAccessor |
| A special adapter for setting individual bits. More... | |
| struct | Iterator |
| The bit mask bit iterator. More... | |
Public Types | |
| enum | { GroupSizeBits = sizeof(GroupType) * 8 , GroupShift = 6 , GroupBitIndexMask = GroupSizeBits - 1 , bitsCountLUTSize = 256 , InlineGroupsCount = 4 } |
| typedef uint64 | GroupType |
| The type of the bit group elements. | |
Public Member Functions | |
| int32 | GroupsNum () const |
| Get the number of available bit groups. | |
| int32 | BitsNum () const |
| Get the number of available (allocated) bits. | |
| bool | At (const int32 Index) const |
| Get the bit flag at the specified index. | |
| bool | operator[] (const int32 Index) const |
| Get a bit element by its index. | |
| FBitAccessor | operator[] (const int32 Index) |
| Get a bit element by its index. | |
| void | SetAt (const int32 Index, const bool Value) |
| Set a bit at a specific index. | |
| bool | IsNonZero () const |
| Check if there are any non-zero bits in the mask. | |
| bool | operator== (const FBitMask &Other) const |
| Compare two bit masks for equality. | |
| bool | operator!= (const FBitMask &Other) const |
| Compare two bit masks for inequality. | |
| bool | Identical (const FBitMask *Other, uint32 PortFlags) const |
| Compare two bit masks for equality. | |
| EApparatusStatus | Trim (const bool bAllowShrinking=true) const |
| Trim the meaningless high-order groups. | |
| bool | IsAllZeroes () const |
| Check if all of the bits in the mask are zeroes or none. | |
| int32 | CountNonZeroGroups () const |
| Get the number of meaningful (non-zero) bit groups. | |
| EApparatusStatus | Set (FBitMask &&InBitMask) |
| Move the bit mask to this bit mask. | |
| template<EParadigm Paradigm = EParadigm::Default> | |
| TOutcome< Paradigm > | Set (const FBitMask &InBitMask) |
| Set this bit mask equal to another bit mask. | |
| FBitMask & | operator= (FBitMask &&InBitMask) |
| Move the bit mask. | |
| FBitMask & | operator= (const FBitMask &InBitMask) |
| Set this bit mask equal to another bit mask. | |
| int32 | DifferencesCount (const FBitMask &BitMask) const |
| Get the number of different bits in two masks. | |
| int32 | InclusionsCount (const FBitMask &BitMask) const |
| Get the number of included bits in two masks. | |
| bool | Includes (const FBitMask &BitMask) const |
| Does the mask has all of the bits set in the supplied mask. | |
| bool | IncludesPartially (const FBitMask &BitMask) const |
| Check if the mask has any of the bits set in the supplied mask. | |
| Iterator | begin () |
| ConstIterator | begin () const |
| Iterator | end () |
| ConstIterator | end () const |
| int32 | IndexOf (const bool Bit, const int32 Offset=0) const |
| Get the index of the first matching bit in the mask. | |
| void | EnsureGroupsNum (const int32 InGroupsCount) |
| Ensure a bit group count. | |
| void | EnsureGroupsForBitAt (const int32 BitIndex) |
| Ensure that there is enough bit groups for an index. | |
| int32 | GroupsMax () const |
| Get the current maximum number of bit groups that can be stored without any additional allocations. | |
| int32 | BitsMax () const |
| Get the current maximum number of bits that can be stored without any additional allocations. | |
| void | Reserve (const int32 BitCapacity) |
| Reserve space for a given number of bits. | |
| void | Empty (const int32 Slack=0) |
| Empties the array. | |
| 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. | |
| void | SetMasked (const FBitMask &Mask, const bool State) |
| Set the bits based on a mask. | |
| void | Insert (const int32 Index, const bool Bit) |
| Insert a bit at the specified index. | |
| void | Remove (const bool Bit) |
| Remove the first occurrence of the specified bit from the mask. | |
| void | RemoveAt (const int32 Index) |
| Remove the bit at the specified index. | |
| void | Erase (const int32 Index) |
| Remove an element at the specified index. | |
| template<EParadigm Paradigm = EParadigm::Default> | |
| TOutcome< Paradigm > | Intersect (const FBitMask &InMask) |
| Logically-and the bitmask with a given mask. | |
| FBitMask & | operator&= (const FBitMask &InMask) |
| Conjunct the bitmask with a given mask. | |
| template<EParadigm Paradigm = EParadigm::Default> | |
| TOutcome< Paradigm > | Include (const FBitMask &InMask) |
| Logical-or the bitmask with a an another mask. | |
| FBitMask & | operator|= (const FBitMask &InMask) |
| Disjunct the bitmask with a given mask. | |
| FString | ToString () const |
| Convert the bit mask to a string representation. | |
| uint32 | CalcHash () const |
| Calculate the bit mask hash. | |
| bool | Serialize (FArchive &Archive) |
| Serialize the bit mask. | |
Initialization | |
| FBitMask () | |
| Construct a new empty bit mask. | |
| FBitMask (const FBitMask &InBitMask) | |
| Copy-construct the bit mask. | |
| FBitMask (FBitMask &&InBitMask) | |
| Move-construct the bit mask. | |
| FBitMask (const int32 Capacity) | |
| Initialize a new instance of a mask with a certain bit capacity. | |
| FBitMask (std::initializer_list< bool > list) | |
| Construct a new bit mask with an initializer list. | |
Static Public Attributes | |
| static const GroupType | ZeroGroup {0} |
| A group of all one bits set. | |
| static const GroupType | FirstOneGroup {1} |
| A group with the first bit set. | |
| static const GroupType | LastOneGroup {(((GroupType)1) << (GroupSizeBits - 1))} |
| A group with the last bit set. | |
| static const GroupType | AllOnesGroup {TNumericLimits<GroupType>::Max()} |
| A group of all one bits set. | |
Friends | |
| class | StaticConstructor |
| uint32 | GetTypeHash (const FBitMask &bm) |
| FBitMask | operator& (const FBitMask &MaskA, const FBitMask &MaskB) |
| Logically-conjunct the bits in masks. | |
| FBitMask | operator| (const FBitMask &MaskA, const FBitMask &MaskB) |
| Logically-disjunct the bits in masks. | |
A memory-efficient bit mask.
Please, note that this is not a usual bit array and serves some different purposes.
| typedef uint64 FBitMask::GroupType |
The type of the bit group elements.
| anonymous enum |
|
inline |
Construct a new empty bit mask.
|
inline |
Copy-construct the bit mask.
|
inline |
Move-construct the bit mask.
|
inline |
Initialize a new instance of a mask with a certain bit capacity.
|
inline |
Construct a new bit mask with an initializer list.
|
inline |
Get the bit flag at the specified index.
| Index | The index of the bit to get. If it's out of the number of elements, false is returned. |
|
inline |
|
inline |
|
inline |
Get the current maximum number of bits that can be stored without any additional allocations.
|
inline |
Get the number of available (allocated) bits.
|
inline |
Calculate the bit mask hash.
|
inline |
Get the number of meaningful (non-zero) bit groups.
| int32 FBitMask::DifferencesCount | ( | const FBitMask & | BitMask | ) | const |
Get the number of different bits in two masks.
|
inline |
Empties the array.
It calls the destructors on held flags if needed.
| Slack | The expected usage size in bits after empty operation. |
|
inline |
|
inline |
|
inline |
Ensure that there is enough bit groups for an index.
|
inline |
Ensure a bit group count.
|
inline |
Remove an element at the specified index.
| Index | An index of the element to erase. |
|
inline |
Get the current maximum number of bit groups that can be stored without any additional allocations.
|
inline |
Get the number of available bit groups.
Compare two bit masks for equality.
Editor-friendly method.
| Other | The other bit mask to compare to. |
| PortFlags | The contextual port flags. |
|
inline |
Logical-or the bitmask with a an another mask.
This can actually be slower than FBitMask::operator|= since it provides a status.
| Paradigm | The paradigm to work on. |
| InMask | The mask to include. |
Does the mask has all of the bits set in the supplied mask.
The same as a bitwise A & B == B.
Check if the mask has any of the bits set in the supplied mask.
The same as a bitwise A & B != 0.
| int32 FBitMask::InclusionsCount | ( | const FBitMask & | BitMask | ) | const |
Get the number of included bits in two masks.
| int32 FBitMask::IndexOf | ( | const bool | Bit, |
| const int32 | Offset = 0 |
||
| ) | const |
Get the index of the first matching bit in the mask.
The mask is considered to be zero-limitless, so a falsy bit is always found in the end.
| Bit | The bit state to find. |
| Offset | The offset index to start with. |
INDEX_NONE, if the bit couldn't be found. | void FBitMask::Insert | ( | const int32 | Index, |
| const bool | Bit | ||
| ) |
Insert a bit at the specified index.
|
inline |
Logically-and the bitmask with a given mask.
| Paradigm | The paradigm to work under. |
| InMask | The mask to intersect with. |
|
inline |
Check if all of the bits in the mask are zeroes or none.
|
inline |
Check if there are any non-zero bits in the mask.
Compare two bit masks for inequality.
Conjunct the bitmask with a given mask.
Set this bit mask equal to another bit mask.
Compare two bit masks for equality.
|
inline |
Get a bit element by its index.
|
inline |
Get a bit element by its index.
Constant version.
Disjunct the bitmask with a given mask.
| void FBitMask::Remove | ( | const bool | Bit | ) |
Remove the first occurrence of the specified bit from the mask.
| void FBitMask::RemoveAt | ( | const int32 | Index | ) |
Remove the bit at the specified index.
| Index | The index of the bit to remove. |
|
inline |
Reserve space for a given number of bits.
|
inline |
Same as empty, but doesn't change memory allocations, unless the new size is larger than the current array.
| NewSize | The expected usage size in bits after calling this function. |
|
inline |
Serialize the bit mask.
|
inline |
Set this bit mask equal to another bit mask.
| Paradigm | The paradigm to work under. |
| InBitMask | The bit mask to set to. |
|
inline |
Move the bit mask to this bit mask.
|
inline |
Set a bit at a specific index.
Set the bits based on a mask.
| Mask | The mask to use while setting the bits. |
| State | The state to set. |
|
inline |
Convert the bit mask to a string representation.
|
inline |
Trim the meaningless high-order groups.
| bAllowShrinking | Is physical array size allowed to shrunk? |
|
friend |
Logically-conjunct the bits in masks.
| MaskA | The first mask to conjunct. |
| MaskB | The second mask to conjunct. |
Logically-disjunct the bits in masks.
| MaskA | The first mask to disjunct. |
| MaskB | The second mask to disjunct. |
|
friend |
A group of all one bits set.
|
static |
A group with the first bit set.
|
static |
A group with the last bit set.
|
static |
A group of all one bits set.