UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UE::Net::FNetBitArray Class Reference

#include <NetBitArray.h>

+ Inheritance diagram for UE::Net::FNetBitArray:

Public Member Functions

 FNetBitArray ()
 
 FNetBitArray (uint32 BitCount)
 
 FNetBitArray (uint32 BitCountIn, const ENoResetNoValidateType)
 
bool operator== (const FNetBitArray &Other) const
 
void Init (uint32 BitCount)
 
void InitAndCopy (const FNetBitArray &Source)
 
void InitAndCopy (const FNetBitArrayView &Source)
 
void Empty ()
 
void SetNumBits (uint32 BitCount)
 
void AddBits (uint32 BitCount)
 
uint32 GetNumBits () const
 
uint32 GetNumWords () const
 
const StorageWordTypeGetDataChecked (uint32 MaxWordIterationCount) const UE_LIFETIMEBOUND
 
StorageWordTypeGetDataChecked (uint32 MaxWordIterationCount) UE_LIFETIMEBOUND
 
const StorageWordTypeGetData () const UE_LIFETIMEBOUND
 
StorageWordTypeGetData () UE_LIFETIMEBOUND
 
StorageWordType GetWord (uint32 WordIndex) const UE_LIFETIMEBOUND
 
StorageWordTypeGetWord (uint32 WordIndex) UE_LIFETIMEBOUND
 
void Reset ()
 
void ClearAllBits ()
 
void SetAllBits ()
 
bool IsBitSet (uint32 Index) const
 
bool IsAnyBitSet () const
 
bool IsAnyBitSet (uint32 StartIndex, uint32 Count) const
 
bool IsNoBitSet () const
 
void SetBit (uint32 Index)
 
void SetBitValue (uint32 Index, bool bValue)
 
void SetBits (uint32 StartIndex, uint32 Count)
 
void ClearBits (uint32 StartIndex, uint32 Count)
 
void ClearBit (uint32 Index)
 
void OrBitValue (uint32 Index, bool bValue)
 
void AndBitValue (uint32 Index, bool bValue)
 
bool GetBit (uint32 Index) const
 
uint32 FindFirstZero () const
 
uint32 FindFirstOne () const
 
uint32 FindFirstZero (uint32 StartIndex) const
 
uint32 FindFirstOne (uint32 StartIndex) const
 
uint32 FindLastZero () const
 
uint32 FindLastOne () const
 
NETCORE_API FString ToString () const
 
uint32 GetSetBitIndices (uint32 StartIndex, uint32 Count, uint32 *OutIndices, uint32 OutIndicesCapacity) const
 
uint32 CountSetBits (uint32 StartIndex=0, uint32 Count=~0U) const
 
void Copy (const FNetBitArray &Other)
 
void Copy (const FNetBitArrayView &Other)
 
template<typename WordOpFunctor >
void Set (const FNetBitArray &First, WordOpFunctor &&WordOp, const FNetBitArray &Second)
 
template<typename WordOpFunctor >
void Combine (const FNetBitArray &Other, WordOpFunctor &&WordOp)
 
template<typename WordOpFunctor1 , typename WordOpFunctor2 >
void CombineMultiple (WordOpFunctor1 &&Op, const FNetBitArray &ArrayA, WordOpFunctor2 &&Op2, const FNetBitArray &ArrayB)
 
template<typename T >
void ForAllSetBits (T &&Functor) const
 
template<typename T >
void ForAllSetBitsInRange (const uint32 StartBit, const uint32 EndBit, T &&Functor) const
 
template<typename T >
void ForAllUnsetBits (T &&Functor) const
 
Private::FNetBitArrayRangedForConstIterator begin () const
 
Private::FNetBitArrayRangedForConstIterator end () const
 

Static Public Member Functions

template<typename T , typename V >
static void ForAllSetBits (const FNetBitArray &A, const FNetBitArray &B, T &&WordOpFunctor, V &&Functor)
 
template<typename WordOpFunctor1 , typename WordOpFunctor2 , typename UserFunctor >
static void ForAllSetBitsMultiple (const FNetBitArray &A, WordOpFunctor1 &&Op1, const FNetBitArray &B, WordOpFunctor2 &&Op2, const FNetBitArray &C, UserFunctor &&Functor)
 
template<typename T , typename V >
static void ForAllExclusiveBits (const FNetBitArray &A, const FNetBitArray &B, T &&FunctorA, V &&FunctorB)
 
template<typename T , typename V , typename Predicate >
static void ForAllExclusiveBitsByPredicate (const FNetBitArray &A, const FNetBitArray &B, T &&FunctorA, V &&FunctorB, Predicate &&Pred)
 
- Static Public Member Functions inherited from UE::Net::FNetBitArrayBase
static constexpr StorageWordType AndOp (StorageWordType A, StorageWordType B)
 
static constexpr StorageWordType AndNotOp (StorageWordType A, StorageWordType B)
 
static constexpr StorageWordType OrOp (StorageWordType A, StorageWordType B)
 
static constexpr StorageWordType XorOp (StorageWordType A, StorageWordType B)
 
static uint32 RoundUpToMaxWordBitCount (uint32 Value)
 

Additional Inherited Members

- Public Types inherited from UE::Net::FNetBitArrayBase
enum  ENoResetNoValidateType { NoResetNoValidate }
 
enum  EResetOnInitType { ResetOnInit }
 
typedef uint32 StorageWordType
 
- Static Public Attributes inherited from UE::Net::FNetBitArrayBase
static constexpr uint32 WordBitCount = sizeof(StorageWordType)*8U
 
static constexpr uint32 InvalidIndex = ~0U
 

Detailed Description

Simple bit array with internal storage. Has very little error checking as it is used in performance critical code.

Constructor & Destructor Documentation

◆ FNetBitArray() [1/3]

UE::Net::FNetBitArray::FNetBitArray ( )
inline

Creates an empty NetBitArray.

◆ FNetBitArray() [2/3]

UE::Net::FNetBitArray::FNetBitArray ( uint32  BitCount)
inlineexplicit

Creates an array with size BitCount bits.

◆ FNetBitArray() [3/3]

UE::Net::FNetBitArray::FNetBitArray ( uint32  BitCountIn,
const ENoResetNoValidateType   
)
inlineexplicit

Construct NetBitArray with the given BitCount but doesn't zero the allocated memory. Useful when the entire bit array will be overwritten before being read.

Member Function Documentation

◆ AddBits()

void UE::Net::FNetBitArray::AddBits ( uint32  BitCount)
inline

Grows the size with the specified number of bits. New bits will be cleared.

Parameters
BitCount- The number of bits to add to the array.
See also
SetNumBits

◆ AndBitValue()

void UE::Net::FNetBitArray::AndBitValue ( uint32  Index,
bool  bValue 
)
inline

Do an And operation on the specified index

◆ begin()

Private::FNetBitArrayRangedForConstIterator UE::Net::FNetBitArray::begin ( ) const
inline

DO NOT USE DIRECTLY Range-based for loop support iterating over set bits and returning the index to the set bit.

◆ ClearAllBits()

void UE::Net::FNetBitArray::ClearAllBits ( )
inline

Clear all bits in the array.

◆ ClearBit()

void UE::Net::FNetBitArray::ClearBit ( uint32  Index)
inline

Clear the bit with the specified index

◆ ClearBits()

void UE::Net::FNetBitArray::ClearBits ( uint32  StartIndex,
uint32  Count 
)
inline

Clear the bits in the specified range

◆ Combine()

template<typename WordOpFunctor >
void UE::Net::FNetBitArray::Combine ( const FNetBitArray Other,
WordOpFunctor &&  WordOp 
)
inline

Combine this array with another array using a word operation functor. Bit counts need to match.

Parameters
OtherThe other array to combine with.
WordOpFunctorThe operation to perform for each word to combine. Signature is StorageWordType(StorageWordType ThisWord, StorageWordType OtherWord).
See also
FNetBitArrayHelper::AndOp, FNetBitArrayHelper::AndNotOp, FNetBitArrayHelper::OrOp, FNetBitArrayHelper::XorOp

◆ CombineMultiple()

void UE::Net::FNetBitArray::CombineMultiple ( WordOpFunctor1 &&  Op,
const FNetBitArray ArrayA,
WordOpFunctor2 &&  Op2,
const FNetBitArray ArrayB 
)
inline

Combine this array with the result of a bitwise operation of two other arrays. eg: ThisArray = ThisArray Op (ArrayA Op2 ArrayB)

Parameters
OpOperation to execute on the word of this array and the result of the operation on the two other arrays
ArrayAThe first bit array to execute the other operation on
Op2The operation to execute on the word of the read-only array passed in parameter
ArrayBThe second bit array to execute the other operation on
See also
FNetBitArrayHelper::AndOp, FNetBitArrayHelper::AndNotOp, FNetBitArrayHelper::OrOp, FNetBitArrayHelper::XorOp

◆ Copy() [1/2]

void UE::Net::FNetBitArray::Copy ( const FNetBitArray Other)
inline

Copy bits from other bit array. The other array must have the same bit count.

◆ Copy() [2/2]

void UE::Net::FNetBitArray::Copy ( const FNetBitArrayView Other)
inline

◆ CountSetBits()

uint32 UE::Net::FNetBitArray::CountSetBits ( uint32  StartIndex = 0,
uint32  Count = ~0U 
) const
inline

Counts the number of set bits in this array in the provided range.

◆ Empty()

void UE::Net::FNetBitArray::Empty ( )
inline

Release all memory and set capacity to 0 bits

◆ end()

Private::FNetBitArrayRangedForConstIterator UE::Net::FNetBitArray::end ( ) const
inline

◆ FindFirstOne() [1/2]

uint32 UE::Net::FNetBitArray::FindFirstOne ( ) const
inline

Find first set bit. Returns InvalidIndex if no zero bit was found

◆ FindFirstOne() [2/2]

uint32 UE::Net::FNetBitArray::FindFirstOne ( uint32  StartIndex) const
inline

Find first set bit starting from StartIndex. Returns InvalidIndex if no set bit was found.

◆ FindFirstZero() [1/2]

uint32 UE::Net::FNetBitArray::FindFirstZero ( ) const
inline

Find first zero bit. Returns InvalidIndex if no zero bit was found

◆ FindFirstZero() [2/2]

uint32 UE::Net::FNetBitArray::FindFirstZero ( uint32  StartIndex) const
inline

Find first zero bit starting from StartIndex. Returns InvalidIndex if no zero bit was found.

◆ FindLastOne()

uint32 UE::Net::FNetBitArray::FindLastOne ( ) const
inline

Find last set bit. Returns InvalidIndex if no set bit was found.

◆ FindLastZero()

uint32 UE::Net::FNetBitArray::FindLastZero ( ) const
inline

Find last zero bit. Returns InvalidIndex if no zero bit was found.

◆ ForAllExclusiveBits()

template<typename T , typename V >
void UE::Net::FNetBitArray::ForAllExclusiveBits ( const FNetBitArray A,
const FNetBitArray B,
T &&  FunctorA,
V &&  FunctorB 
)
inlinestatic

Compare two BitArrays bit by bit and invoke FunctorA(BitIndex) for bits set only in array A and invoke FunctorB(BitIndex) for bits set only in array B.

◆ ForAllExclusiveBitsByPredicate()

template<typename T , typename V , typename Predicate >
void UE::Net::FNetBitArray::ForAllExclusiveBitsByPredicate ( const FNetBitArray A,
const FNetBitArray B,
T &&  FunctorA,
V &&  FunctorB,
Predicate &&  Pred 
)
inlinestatic

Compare two BitArrays bit by bit. Where they differ and Predicate(BitIndex) returns true FunctorA(BitIndex) is invoked for bits set only in array A and FunctorB(BitIndex) is invoked for bits set only in array B.

◆ ForAllSetBits() [1/2]

template<typename T , typename V >
void UE::Net::FNetBitArray::ForAllSetBits ( const FNetBitArray A,
const FNetBitArray B,
T &&  WordOpFunctor,
V &&  Functor 
)
inlinestatic

Iterate over all words and execute Functor, with signature void(uint32 BitIndex), for all set bits after executing WordOpFunctor

◆ ForAllSetBits() [2/2]

template<typename T >
void UE::Net::FNetBitArray::ForAllSetBits ( T &&  Functor) const
inline

Iterate over all set bits and invoke functor with signature void(uint32 BitIndex).

◆ ForAllSetBitsInRange()

template<typename T >
void UE::Net::FNetBitArray::ForAllSetBitsInRange ( const uint32  StartBit,
const uint32  EndBit,
T &&  Functor 
) const
inline

Iterate over all set bits and invoke functor with signature void(uint32 BitIndex).

◆ ForAllSetBitsMultiple()

void UE::Net::FNetBitArray::ForAllSetBitsMultiple ( const FNetBitArray A,
WordOpFunctor1 &&  Op1,
const FNetBitArray B,
WordOpFunctor2 &&  Op2,
const FNetBitArray C,
UserFunctor &&  Functor 
)
inlinestatic

Call the functor for every bit still set after the following operation: "A Op1 (B Op2 C)"

◆ ForAllUnsetBits()

template<typename T >
void UE::Net::FNetBitArray::ForAllUnsetBits ( T &&  Functor) const
inline

Iterate over all the zero bits and invoke functor with signature void(uint32 BitIndex).

◆ GetBit()

bool UE::Net::FNetBitArray::GetBit ( uint32  Index) const
inline

Get the bit with the specified index

◆ GetData() [1/2]

const StorageWordType * UE::Net::FNetBitArray::GetData ( ) const
inline

Returns a pointer to the internal storage. It's safer to use GetWord() or GetDataChecked() instead.

◆ GetData() [2/2]

StorageWordType * UE::Net::FNetBitArray::GetData ( )
inline

Returns a pointer to the internal storage. It's safer to use GetWord() or GetDataChecked() instead.

◆ GetDataChecked() [1/2]

const StorageWordType * UE::Net::FNetBitArray::GetDataChecked ( uint32  MaxWordIterationCount) const
inline

Returns a pointer to the internal storage but validates that the array buffer is the expected size. Use this before directly iterating over one or multiple buffers and ensure they all support the max iteration index.

◆ GetDataChecked() [2/2]

StorageWordType * UE::Net::FNetBitArray::GetDataChecked ( uint32  MaxWordIterationCount)
inline

Returns a pointer to the internal storage but validates that the array buffer is the expected size. Use this before directly iterating over one or multiple buffers and ensure they all support the max iteration index.

◆ GetNumBits()

uint32 UE::Net::FNetBitArray::GetNumBits ( ) const
inline

Returns the number of bits

◆ GetNumWords()

uint32 UE::Net::FNetBitArray::GetNumWords ( ) const
inline

Returns the number of words in our storage

◆ GetSetBitIndices()

uint32 UE::Net::FNetBitArray::GetSetBitIndices ( uint32  StartIndex,
uint32  Count,
uint32 OutIndices,
uint32  OutIndicesCapacity 
) const
inline

Retrieves set bits in the provided range and returns how many indices were written to OutIndices. If OutIndices is filled to its capacity the search for set bits will end. OutIndices may be modified beyond the returned count but within the capacity.

Parameters
StartIndexWhich bit index to start searching for set bits.
CountHow many bits to check. The count will be clamped to number of bits in the array so you can pass ~0U to check all bits.
OutIndicesWhere to store the indices of the set bits. Indices with lower numbers will be stored first.
OutIndicesCapacityHow many indices can be stored in OutIndices.
Returns
Number of indices OutIndices was populated with.

◆ GetWord() [1/2]

StorageWordType UE::Net::FNetBitArray::GetWord ( uint32  WordIndex) const
inline

Read an entire word. Useful when you want to read 'WordBitCount(32)' bits at once

◆ GetWord() [2/2]

StorageWordType & UE::Net::FNetBitArray::GetWord ( uint32  WordIndex)
inline

Access an entire word. Useful when you want to write 'WordBitCount(32)' bits at once

◆ Init()

void UE::Net::FNetBitArray::Init ( uint32  BitCount)
inline

Sets a new size and resets the array's contents.

Parameters
BitCount- The number of bits in the array after the operation.

◆ InitAndCopy() [1/2]

void UE::Net::FNetBitArray::InitAndCopy ( const FNetBitArray Source)
inline

Initialize a bit array with another array.

◆ InitAndCopy() [2/2]

void UE::Net::FNetBitArray::InitAndCopy ( const FNetBitArrayView Source)
inline

◆ IsAnyBitSet() [1/2]

bool UE::Net::FNetBitArray::IsAnyBitSet ( ) const
inline

Returns true if any bit is set in the bitset. Note: Padding bits in storage are expected to be zero.

◆ IsAnyBitSet() [2/2]

bool UE::Net::FNetBitArray::IsAnyBitSet ( uint32  StartIndex,
uint32  Count 
) const
inline

Returns true if any bit is set in the specified range. The range will be clamped if needed. Note: Padding bits in storage are expected to be zero.

◆ IsBitSet()

bool UE::Net::FNetBitArray::IsBitSet ( uint32  Index) const
inline

Return if a specified bit is set or not

◆ IsNoBitSet()

bool UE::Net::FNetBitArray::IsNoBitSet ( ) const
inline

Returns true if no bit is set in the bitset. Note: Padding bits in storage are expected to be zero.

◆ operator==()

bool UE::Net::FNetBitArray::operator== ( const FNetBitArray Other) const
inline

Return true if equal including BitCount and padding bits

◆ OrBitValue()

void UE::Net::FNetBitArray::OrBitValue ( uint32  Index,
bool  bValue 
)
inline

Do an Or operation on the specified index

◆ Reset()

void UE::Net::FNetBitArray::Reset ( )
inline

Clear all bits in the array.

◆ Set()

template<typename WordOpFunctor >
void UE::Net::FNetBitArray::Set ( const FNetBitArray First,
WordOpFunctor &&  WordOp,
const FNetBitArray Second 
)
inline

Overwrite this bit array with the result of a word operation from two other arrays

Parameters
FirstThe first bit array to pass in the word operation
WordOpThe operation to perform on the two bit arrays
SecondThe second bit array to pass in the word operation
See also
FNetBitArrayHelper::AndOp, FNetBitArrayHelper::AndNotOp, FNetBitArrayHelper::OrOp, FNetBitArrayHelper::XorOp

◆ SetAllBits()

void UE::Net::FNetBitArray::SetAllBits ( )
inline

Sets all bits in the array, but clears padding bits.

◆ SetBit()

void UE::Net::FNetBitArray::SetBit ( uint32  Index)
inline

Set the bit with the specified index

◆ SetBits()

void UE::Net::FNetBitArray::SetBits ( uint32  StartIndex,
uint32  Count 
)
inline

Set the bit with the specified index to bValue

◆ SetBitValue()

void UE::Net::FNetBitArray::SetBitValue ( uint32  Index,
bool  bValue 
)
inline

Set the bit with the specified index to bValue

◆ SetNumBits()

void UE::Net::FNetBitArray::SetNumBits ( uint32  BitCount)
inline

Sets the number of bits to BitCount. If the array grows the new bits will be cleared. Existing bits will remain intact.

Parameters
BitCount- The number of bits in the array after the operation.

◆ ToString()

FString UE::Net::FNetBitArray::ToString ( ) const

Only prints the amount of set bits in the array.

See also
FNetBitArrayPrinter for more print options

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