Ark Server API (ASA) - Wiki
|
#include <SparseArray.h>
Classes | |
class | FElementCompareClass |
class | TBaseIterator |
class | TConstIterator |
class | TConstSubsetIterator |
class | TIterator |
class | TRangedForConstIterator |
class | TRangedForIterator |
Static Public Member Functions | |
static void | AppendHash (const FPlatformTypeLayoutParameters &LayoutParams, FSHA1 &Hasher) |
Private Types | |
using | ElementType = InElementType |
typedef TSparseArrayElementOrFreeListLink< TAlignedBytes< sizeof(ElementType), alignof(ElementType)> > | FElementOrFreeListLink |
typedef TArray< FElementOrFreeListLink, typename Allocator::ElementAllocator > | DataType |
typedef TBitArray< typename Allocator::BitArrayAllocator > | AllocationBitArrayType |
Static Private Member Functions | |
template<typename SparseArrayType > | |
static FORCEINLINE void | Move (SparseArrayType &ToArray, SparseArrayType &FromArray) |
Private Attributes | |
DataType | Data |
AllocationBitArrayType | AllocationFlags |
int32 | FirstFreeIndex |
int32 | NumFreeIndices |
Friends | |
template<typename , typename > | |
class | TScriptSparseArray |
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).
Definition at line 74 of file SparseArray.h.
|
private |
Definition at line 1118 of file SparseArray.h.
|
private |
Definition at line 1115 of file SparseArray.h.
|
private |
Definition at line 76 of file SparseArray.h.
|
private |
The element type stored is only indirectly related to the element type requested, to avoid instantiating TArray redundantly for compatible types.
Definition at line 1096 of file SparseArray.h.
|
inline |
Destructor.
Definition at line 83 of file SparseArray.h.
|
inline |
Default constructor.
Definition at line 728 of file SparseArray.h.
|
inline |
Move constructor.
Definition at line 734 of file SparseArray.h.
|
inline |
Copy constructor.
Definition at line 740 of file SparseArray.h.
|
inline |
Adds an element to the array.
Definition at line 138 of file SparseArray.h.
|
inline |
Adds an element to the array.
Definition at line 146 of file SparseArray.h.
|
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.
Definition at line 205 of file SparseArray.h.
|
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.
Definition at line 111 of file SparseArray.h.
|
inline |
Definition at line 153 of file SparseArray.h.
|
inline |
Marks an index as allocated, and returns information about the allocation.
Definition at line 90 of file SparseArray.h.
|
inlinestatic |
Definition at line 1208 of file SparseArray.h.
|
inline |
DO NOT USE DIRECTLY STL-like iterators to enable range-based for loop support.
Definition at line 1026 of file SparseArray.h.
|
inline |
Definition at line 1027 of file SparseArray.h.
|
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.
Addr | The address to check. |
Definition at line 862 of file SparseArray.h.
|
inline |
Compacts the allocated elements into a contiguous index range. Returns true if any elements were relocated, false otherwise.
Definition at line 510 of file SparseArray.h.
|
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.
Definition at line 560 of file SparseArray.h.
|
inline |
Definition at line 1173 of file SparseArray.h.
|
inline |
Tracks the container's memory use through an archive.
Definition at line 676 of file SparseArray.h.
|
inline |
Creates a const iterator for the contents of this array
Definition at line 1016 of file SparseArray.h.
|
inline |
Creates an iterator for the contents of this array
Definition at line 1010 of file SparseArray.h.
|
inline |
Constructs a new item at the last freed index of the array.
Args | The arguments to forward to the constructor of the new item. |
Definition at line 219 of file SparseArray.h.
|
inline |
Constructs a new item at a given index of the array.
Index | Index at which the new allocation will be done |
Args | The arguments to forward to the constructor of the new item. |
Definition at line 250 of file SparseArray.h.
|
inline |
Constructs a new item at the lowest free index of the array. This requires a search which can be accelerated with LowestFreeIndexSearchStart.
LowestFreeIndexSearchStart | Where to start the search for a free index. |
Args | The arguments to forward to the constructor of the new item. |
Definition at line 235 of file SparseArray.h.
|
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. |
Definition at line 376 of file SparseArray.h.
|
inline |
Definition at line 1028 of file SparseArray.h.
|
inline |
Definition at line 1029 of file SparseArray.h.
|
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.
Definition at line 670 of file SparseArray.h.
|
inline |
Definition at line 852 of file SparseArray.h.
|
inline |
Inserts an element to the array.
Definition at line 328 of file SparseArray.h.
|
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.
Definition at line 271 of file SparseArray.h.
|
inline |
Definition at line 851 of file SparseArray.h.
|
inline |
Definition at line 682 of file SparseArray.h.
|
inline |
Definition at line 853 of file SparseArray.h.
|
inline |
Definition at line 847 of file SparseArray.h.
|
inlinestaticprivate |
Definition at line 806 of file SparseArray.h.
|
inline |
Definition at line 854 of file SparseArray.h.
|
inline |
Inequality comparison operator. Checks that both arrays have the same elements and element indices; that means that unallocated elements are signifigant!
Definition at line 722 of file SparseArray.h.
|
inline |
Definition at line 1078 of file SparseArray.h.
|
inline |
Concatenation operators
Definition at line 1069 of file SparseArray.h.
|
inline |
Copy assignment operator.
Definition at line 758 of file SparseArray.h.
|
inline |
Move assignment operator.
Definition at line 748 of file SparseArray.h.
|
inline |
Equality comparison operator. Checks that both arrays have the same elements and element indices; that means that unallocated elements are signifigant!
Definition at line 691 of file SparseArray.h.
|
inline |
Definition at line 828 of file SparseArray.h.
|
inline |
Definition at line 834 of file SparseArray.h.
|
inline |
Definition at line 840 of file SparseArray.h.
|
inline |
Removes Count elements from the array, starting from Index.
Definition at line 334 of file SparseArray.h.
|
inline |
Removes Count elements from the array, starting from Index, without destructing them.
Definition at line 349 of file SparseArray.h.
|
inline |
Preallocates enough memory to contain the specified number of elements.
ExpectedNumElements | the total number of elements that the array will have |
Definition at line 420 of file SparseArray.h.
|
inline |
Empties the array, but keep its allocated memory as slack.
Definition at line 396 of file SparseArray.h.
|
inline |
Shrinks the array's storage to avoid slack.
Definition at line 456 of file SparseArray.h.
|
inline |
Sorts the elements assuming < operator is defined for ElementType.
Definition at line 596 of file SparseArray.h.
|
inline |
Sorts the elements using the provided comparison class.
Definition at line 583 of file SparseArray.h.
|
inline |
Sort the free element list so that subsequent allocations will occur in the lowest available position resulting in tighter packing without moving any existing items. This also means that assigned indices no longer depend on the order in which old items were removed, making it easier to use the container when determinism is required (without a container reset).
E.g., call SortFreeList() each frame to make the container assign the same indices when we perform the following operations: Frame1: Add(A) -> [0]; Add(B) -> [1]; Remove(A); Remove(B); (Free list is now {[1],[0],...}) Frame2: Add(A) -> [1]; Add(B) -> [0]; Remove(A); Remove(B); (Free list is now {[0],[1],...})
NOTE: This is operation is currently O(N) with N = GetMaxIndex(). This could be improved for large mostly-full arrays if necessary.
Definition at line 635 of file SparseArray.h.
|
inline |
Stable sorts the elements assuming < operator is defined for ElementType.
Definition at line 616 of file SparseArray.h.
|
inline |
Stable sorts the elements using the provided comparison class.
Definition at line 603 of file SparseArray.h.
|
inline |
Definition at line 1128 of file SparseArray.h.
|
friend |
Definition at line 79 of file SparseArray.h.
|
private |
Definition at line 1119 of file SparseArray.h.
|
private |
Definition at line 1116 of file SparseArray.h.
|
private |
The index of an unallocated element in the array that currently contains the head of the linked list of free elements.
Definition at line 1122 of file SparseArray.h.
|
private |
The number of elements in the free list.
Definition at line 1125 of file SparseArray.h.