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

#include <RefCountVector.h>

Classes

class  BaseIterator
 
class  FilteredEnumerable
 
class  IndexEnumerable
 
class  IndexIterator
 
class  MappedEnumerable
 

Public Member Functions

 FRefCountVector ()=default
 
 FRefCountVector (const FRefCountVector &)=default
 
 FRefCountVector (FRefCountVector &&From)
 
FRefCountVectoroperator= (const FRefCountVector &)=default
 
FRefCountVectoroperator= (FRefCountVector &&From)
 
bool IsEmpty () const
 
size_t GetCount () const
 
size_t GetMaxIndex () const
 
bool IsDense () const
 
bool IsValid (int Index) const
 
bool IsValidUnsafe (int Index) const
 
int GetRefCount (int Index) const
 
int GetRawRefCount (int Index) const
 
void Append (const FRefCountVector &Other)
 
int Allocate ()
 
int Increment (int Index, unsigned short IncrementCount=1)
 
void Decrement (int Index, unsigned short DecrementCount=1)
 
bool AllocateAt (int Index)
 
bool AllocateAtUnsafe (int Index)
 
const TDynamicVector< unsigned short > & GetRawRefCounts () const
 
TDynamicVector< unsigned short > & GetRawRefCountsUnsafe ()
 
void SetRefCountUnsafe (int Index, unsigned short ToCount)
 
template<typename IterateFunc , typename AllocateRefCountFunc , typename IncrementRefCountFunc >
void Rebuild (unsigned int Num, IterateFunc &&Iterate, AllocateRefCountFunc &&AllocateRefCount, IncrementRefCountFunc &&IncrementRefCount)
 
void RebuildFreeList ()
 
void Trim (int maxIndex)
 
void Clear ()
 
void InitDense (int Size, uint16 RefCountValue=1)
 
IndexIterator BeginIndices () const
 
IndexIterator EndIndices () const
 
IndexEnumerable Indices () const
 
template<typename ToType >
MappedEnumerable< ToType > MappedIndices (TFunction< ToType(int)> MapFunc) const
 
FilteredEnumerable FilteredIndices (TFunction< bool(int)> FilterFunc) const
 
FString UsageStats () const
 
SIZE_T GetByteCount () const
 
void Serialize (FArchive &Ar, bool bCompactData, bool bUseCompression)
 

Static Public Attributes

static constexpr unsigned short INVALID_REF_COUNT = MAX_uint16
 

Friends

FArchiveoperator<< (FArchive &Ar, FRefCountVector &Vec)
 
bool operator== (const FRefCountVector &Lhs, const FRefCountVector &Rhs)
 
bool operator!= (const FRefCountVector &Lhs, const FRefCountVector &Rhs)
 

Detailed Description

FRefCountVector is used to keep track of which indices in a linear Index list are in use/referenced. A free list is tracked so that unreferenced indices can be re-used.

The enumerator iterates over valid indices (ie where refcount > 0)

Warning
refcounts are 16-bit ints (shorts) so the maximum count is 65536. behavior is undefined if this overflows.
No overflow checking is done in release builds.

Constructor & Destructor Documentation

◆ FRefCountVector() [1/3]

UE::Geometry::FRefCountVector::FRefCountVector ( )
default

◆ FRefCountVector() [2/3]

UE::Geometry::FRefCountVector::FRefCountVector ( const FRefCountVector )
default

◆ FRefCountVector() [3/3]

UE::Geometry::FRefCountVector::FRefCountVector ( FRefCountVector &&  From)
inline

Member Function Documentation

◆ Allocate()

int UE::Geometry::FRefCountVector::Allocate ( )
inline

◆ AllocateAt()

bool UE::Geometry::FRefCountVector::AllocateAt ( int  Index)
inline

allocate at specific Index, which must either be larger than current max Index, or on the free list. If larger, all elements up to this one will be pushed onto free list. otherwise we have to do a linear search through free list. If you are doing many of these, it is likely faster to use AllocateAtUnsafe(), and then RebuildFreeList() after you are done.

◆ AllocateAtUnsafe()

bool UE::Geometry::FRefCountVector::AllocateAtUnsafe ( int  Index)
inline

allocate at specific Index, which must be free or larger than current max Index. However, we do not update free list. So, you probably need to do RebuildFreeList() after calling this.

◆ Append()

void UE::Geometry::FRefCountVector::Append ( const FRefCountVector Other)
inline

◆ BeginIndices()

IndexIterator UE::Geometry::FRefCountVector::BeginIndices ( ) const
inline

◆ Clear()

void UE::Geometry::FRefCountVector::Clear ( )
inline

◆ Decrement()

void UE::Geometry::FRefCountVector::Decrement ( int  Index,
unsigned short  DecrementCount = 1 
)
inline

◆ EndIndices()

IndexIterator UE::Geometry::FRefCountVector::EndIndices ( ) const
inline

◆ FilteredIndices()

FilteredEnumerable UE::Geometry::FRefCountVector::FilteredIndices ( TFunction< bool(int)>  FilterFunc) const
inline

◆ GetByteCount()

SIZE_T UE::Geometry::FRefCountVector::GetByteCount ( ) const
inline

◆ GetCount()

size_t UE::Geometry::FRefCountVector::GetCount ( ) const
inline

◆ GetMaxIndex()

size_t UE::Geometry::FRefCountVector::GetMaxIndex ( ) const
inline

◆ GetRawRefCount()

int UE::Geometry::FRefCountVector::GetRawRefCount ( int  Index) const
inline

◆ GetRawRefCounts()

const TDynamicVector< unsigned short > & UE::Geometry::FRefCountVector::GetRawRefCounts ( ) const
inline

◆ GetRawRefCountsUnsafe()

TDynamicVector< unsigned short > & UE::Geometry::FRefCountVector::GetRawRefCountsUnsafe ( )
inline
Warning
you should not use this!

◆ GetRefCount()

int UE::Geometry::FRefCountVector::GetRefCount ( int  Index) const
inline

◆ Increment()

int UE::Geometry::FRefCountVector::Increment ( int  Index,
unsigned short  IncrementCount = 1 
)
inline

◆ Indices()

IndexEnumerable UE::Geometry::FRefCountVector::Indices ( ) const
inline

returns iteration object over valid indices usage: for (int idx : indices()) { ... }

◆ InitDense()

void UE::Geometry::FRefCountVector::InitDense ( int  Size,
uint16  RefCountValue = 1 
)
inline

◆ IsDense()

bool UE::Geometry::FRefCountVector::IsDense ( ) const
inline

◆ IsEmpty()

bool UE::Geometry::FRefCountVector::IsEmpty ( ) const
inline

◆ IsValid()

bool UE::Geometry::FRefCountVector::IsValid ( int  Index) const
inline

◆ IsValidUnsafe()

bool UE::Geometry::FRefCountVector::IsValidUnsafe ( int  Index) const
inline

◆ MappedIndices()

template<typename ToType >
MappedEnumerable< ToType > UE::Geometry::FRefCountVector::MappedIndices ( TFunction< ToType(int)>  MapFunc) const
inline

returns iteration object over mapping applied to valid indices eg usage: for (FVector3d v : mapped_indices(fn_that_looks_up_mesh_vtx_from_id)) { ... }

◆ operator=() [1/2]

FRefCountVector & UE::Geometry::FRefCountVector::operator= ( const FRefCountVector )
default

◆ operator=() [2/2]

FRefCountVector & UE::Geometry::FRefCountVector::operator= ( FRefCountVector &&  From)
inline

◆ Rebuild()

void UE::Geometry::FRefCountVector::Rebuild ( unsigned int  Num,
IterateFunc &&  Iterate,
AllocateRefCountFunc &&  AllocateRefCount,
IncrementRefCountFunc &&  IncrementRefCount 
)
inline

Rebuilds all reference counts from external source data via callables.

For example, we could rebuild ref counts for vertices by iterating over all triangles via the Iterate callable, and in the process any vertex we encounter for the first time gets a ref count of 1 via the AllocateRefCount callable, and any vertex we encounter repeatedly has its ref count incremented by one via the IncrementRefCount callable.

Parameters
NumNumber of items that get referenced.
IterateCallable that iterates over all referenced items in the external source data.
AllocateRefCountCallable for allocating an item, i.e. an item that is referenced for the first time.
IncrementRefCountCallable for incrementing an item, i.e. an item that has been referenced before.

◆ RebuildFreeList()

void UE::Geometry::FRefCountVector::RebuildFreeList ( )
inline

◆ Serialize()

void UE::Geometry::FRefCountVector::Serialize ( FArchive Ar,
bool  bCompactData,
bool  bUseCompression 
)
inline

Serialize FRefCountVector to an archive.

Parameters
ArArchive to serialize with
bCompactDataOnly serialize unique data and/or recompute redundant data when loading.
bUseCompressionUse compression to serialize data; the resulting size will likely be smaller but serialization will take significantly longer.

◆ SetRefCountUnsafe()

void UE::Geometry::FRefCountVector::SetRefCountUnsafe ( int  Index,
unsigned short  ToCount 
)
inline
Warning
you should not use this!

◆ Trim()

void UE::Geometry::FRefCountVector::Trim ( int  maxIndex)
inline

◆ UsageStats()

FString UE::Geometry::FRefCountVector::UsageStats ( ) const
inline

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( const FRefCountVector Lhs,
const FRefCountVector Rhs 
)
friend

◆ operator<<

FArchive & operator<< ( FArchive Ar,
FRefCountVector Vec 
)
friend

Serialization operator for FRefCountVector.

Parameters
ArArchive to serialize with.
VecVector to serialize.
Returns
Passing down serializing archive.

◆ operator==

bool operator== ( const FRefCountVector Lhs,
const FRefCountVector Rhs 
)
friend

Member Data Documentation

◆ INVALID_REF_COUNT

constexpr unsigned short UE::Geometry::FRefCountVector::INVALID_REF_COUNT = MAX_uint16
staticconstexpr

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