engine
 
载入中...
搜索中...
未找到
类 | Public 成员函数 | 友元 | 所有成员列表
TSparseArray< InElementType, Allocator > 模板类 参考

A dynamically sized array where element indices aren't necessarily contiguous. 更多...

#include <SparseArray.h>

类

class  TConstIterator
 Iterates over all allocated elements in a const sparse array. 更多...
 
class  TConstSubsetIterator
 An iterator which only iterates over the elements of the array which correspond to set bits in a separate bit array. 更多...
 
class  TIterator
 Iterates over all allocated elements in a sparse array. 更多...
 

Public 成员函数

int32 Add (const ElementType &Element)
 Adds an element to the array.
 
int32 Add (ElementType &&Element)
 Adds an element to the array.
 
int32 AddAtLowestFreeIndex (const ElementType &Element, int32 &LowestFreeIndexSearchStart)
 Add an element at the lowest free index, instead of the last freed index. 更多...
 
FSparseArrayAllocationInfo AddUninitialized ()
 Allocates space for an element in the array. 更多...
 
FSparseArrayAllocationInfo AllocateIndex (int32 Index)
 Marks an index as allocated, and returns information about the allocation.
 
FORCEINLINE TRangedForIterator begin ()
 DO NOT USE DIRECTLY STL-like iterators to enable range-based for loop support.
 
FORCEINLINE void CheckAddress (const ElementType *Addr) const
 Checks that the specified address is not part of an element within the container. 更多...
 
bool Compact ()
 Compacts the allocated elements into a contiguous index range. 更多...
 
bool CompactStable ()
 Compacts the allocated elements into a contiguous index range. 更多...
 
void CountBytes (FArchive &Ar) const
 Tracks the container's memory use through an archive.
 
TConstIterator CreateConstIterator () const
 Creates a const iterator for the contents of this array
 
TIterator CreateIterator ()
 Creates an iterator for the contents of this array
 
template<typename... ArgsType>
FORCEINLINE int32 Emplace (ArgsType &&... Args)
 Constructs a new item at the last freed index of the array. 更多...
 
template<typename... ArgsType>
FORCEINLINE int32 EmplaceAtLowestFreeIndex (int32 &LowestFreeIndexSearchStart, ArgsType &&... Args)
 Constructs a new item at the lowest free index of the array. 更多...
 
void Empty (int32 ExpectedNumElements=0)
 Removes all elements from the array, potentially leaving space allocated for an expected number of elements about to be added. 更多...
 
uint32 GetAllocatedSize (void) const
 Helper function to return the amount of memory allocated by this container Only returns the size of allocations made directly by the container, not the elements themselves. 更多...
 
void Insert (int32 Index, typename TTypeTraits< ElementType >::ConstInitType Element)
 Inserts an element to the array.
 
FSparseArrayAllocationInfo InsertUninitialized (int32 Index)
 Allocates space for an element in the array at a given index. 更多...
 
TSparseArray & operator+= (const TSparseArray &OtherArray)
 Concatenation operators
 
TSparseArray & operator= (const TSparseArray &InCopy)
 Copy assignment operator.
 
TSparseArray & operator= (TSparseArray &&InCopy)
 Move assignment operator.
 
void RemoveAt (int32 Index, int32 Count=1)
 Removes Count elements from the array, starting from Index.
 
void RemoveAtUninitialized (int32 Index, int32 Count=1)
 Removes Count elements from the array, starting from Index, without destructing them.
 
void Reserve (int32 ExpectedNumElements)
 Preallocates enough memory to contain the specified number of elements. 更多...
 
void Reset ()
 Empties the array, but keep its allocated memory as slack.
 
void Shrink ()
 Shrinks the array's storage to avoid slack.
 
void Sort ()
 Sorts the elements assuming < operator is defined for ElementType.
 
template<typename PREDICATE_CLASS >
void Sort (const PREDICATE_CLASS &Predicate)
 Sorts the elements using the provided comparison class.
 
void StableSort ()
 Stable sorts the elements assuming < operator is defined for ElementType.
 
template<typename PREDICATE_CLASS >
void StableSort (const PREDICATE_CLASS &Predicate)
 Stable sorts the elements using the provided comparison class.
 
 TSparseArray ()
 Default constructor.
 
 TSparseArray (const TSparseArray &InCopy)
 Copy constructor.
 
 TSparseArray (TSparseArray &&InCopy)
 Move constructor.
 
 ~TSparseArray ()
 Destructor.
 

友元

bool operator!= (const TSparseArray &A, const TSparseArray &B)
 Inequality comparison operator. 更多...
 
FArchive & operator<< (FArchive &Ar, TSparseArray &Array)
 Serializer.
 
void operator<< (FStructuredArchive::FSlot Slot, TSparseArray &InArray)
 Structured archive serializer.
 
bool operator== (const TSparseArray &A, const TSparseArray &B)
 Equality comparison operator. 更多...
 

详细描述

template<typename InElementType, typename Allocator>
class TSparseArray< InElementType, Allocator >

A dynamically sized array where element indices aren't necessarily contiguous.

Memory is allocated for all elements in the array's index range, so it doesn't save memory; but it does allow O(1) element removal that doesn't invalidate the indices of subsequent elements. It uses TArray to store the elements, and a TBitArray to store whether each element index is allocated (for fast iteration over allocated elements).

成员函数说明

◆ AddAtLowestFreeIndex()

template<typename InElementType , typename Allocator >
int32 TSparseArray< InElementType, Allocator >::AddAtLowestFreeIndex ( const ElementType &  Element,
int32 &  LowestFreeIndexSearchStart 
)
inline

Add an element at the lowest free index, instead of the last freed index.

This requires a search which can be accelerated with LowestFreeIndexSearchStart.

◆ AddUninitialized()

template<typename InElementType , typename Allocator >
FSparseArrayAllocationInfo TSparseArray< InElementType, Allocator >::AddUninitialized ( )
inline

Allocates space for an element in the array.

The element is not initialized, and you must use the corresponding placement new operator to construct the element in the allocated memory.

◆ CheckAddress()

template<typename InElementType , typename Allocator >
FORCEINLINE void TSparseArray< InElementType, Allocator >::CheckAddress ( const ElementType *  Addr) const
inline

Checks that the specified address is not part of an element within the container.

Used for implementations to check that reference arguments aren't going to be invalidated by possible reallocation.

参数
AddrThe address to check.

◆ Compact()

template<typename InElementType , typename Allocator >
bool TSparseArray< InElementType, Allocator >::Compact ( )
inline

Compacts the allocated elements into a contiguous index range.

Returns true if any elements were relocated, false otherwise.

◆ CompactStable()

template<typename InElementType , typename Allocator >
bool TSparseArray< InElementType, Allocator >::CompactStable ( )
inline

Compacts the allocated elements into a contiguous index range.

Does not change the iteration order of the elements. Returns true if any elements were relocated, false otherwise.

◆ Emplace()

template<typename InElementType , typename Allocator >
template<typename... ArgsType>
FORCEINLINE int32 TSparseArray< InElementType, Allocator >::Emplace ( ArgsType &&...  Args)
inline

Constructs a new item at the last freed index of the array.

参数
ArgsThe arguments to forward to the constructor of the new item.
返回
Index to the new item

◆ EmplaceAtLowestFreeIndex()

template<typename InElementType , typename Allocator >
template<typename... ArgsType>
FORCEINLINE int32 TSparseArray< InElementType, Allocator >::EmplaceAtLowestFreeIndex ( int32 &  LowestFreeIndexSearchStart,
ArgsType &&...  Args 
)
inline

Constructs a new item at the lowest free index of the array.

This requires a search which can be accelerated with LowestFreeIndexSearchStart.

参数
LowestFreeIndexSearchStartWhere to start the search for a free index.
ArgsThe arguments to forward to the constructor of the new item.
返回
Index to the new item

◆ Empty()

template<typename InElementType , typename Allocator >
void TSparseArray< InElementType, Allocator >::Empty ( int32  ExpectedNumElements = 0)
inline

Removes all elements from the array, potentially leaving space allocated for an expected number of elements about to be added.

参数
ExpectedNumElements- The expected number of elements about to be added.

◆ GetAllocatedSize()

template<typename InElementType , typename Allocator >
uint32 TSparseArray< InElementType, Allocator >::GetAllocatedSize ( void  ) const
inline

Helper function to return the amount of memory allocated by this container Only returns the size of allocations made directly by the container, not the elements themselves.

返回
number of bytes allocated by this container

◆ InsertUninitialized()

template<typename InElementType , typename Allocator >
FSparseArrayAllocationInfo TSparseArray< InElementType, Allocator >::InsertUninitialized ( int32  Index)
inline

Allocates space for an element in the array at a given index.

The element is not initialized, and you must use the corresponding placement new operator to construct the element in the allocated memory.

◆ Reserve()

template<typename InElementType , typename Allocator >
void TSparseArray< InElementType, Allocator >::Reserve ( int32  ExpectedNumElements)
inline

Preallocates enough memory to contain the specified number of elements.

参数
ExpectedNumElementsthe total number of elements that the array will have

友元及相关函数文档

◆ operator!=

template<typename InElementType , typename Allocator >
bool operator!= ( const TSparseArray< InElementType, Allocator > &  A,
const TSparseArray< InElementType, Allocator > &  B 
)
friend

Inequality comparison operator.

Checks that both arrays have the same elements and element indices; that means that unallocated elements are signifigant!

◆ operator==

template<typename InElementType , typename Allocator >
bool operator== ( const TSparseArray< InElementType, Allocator > &  A,
const TSparseArray< InElementType, Allocator > &  B 
)
friend

Equality comparison operator.

Checks that both arrays have the same elements and element indices; that means that unallocated elements are signifigant!


该类的文档由以下文件生成: