mirror of
https://github.com/Milxnor/Project-Reboot-3.0.git
synced 2026-01-13 02:42:22 +01:00
a lottt of stuff
This commit is contained in:
52
Project Reboot 3.0/SparseArray.h
Normal file
52
Project Reboot 3.0/SparseArray.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
#include "Array.h"
|
||||
#include "BitArray.h"
|
||||
|
||||
template <typename ElementType>
|
||||
union TSparseArrayElementOrListLink
|
||||
{
|
||||
TSparseArrayElementOrListLink(ElementType& InElement)
|
||||
: ElementData(InElement)
|
||||
{
|
||||
}
|
||||
TSparseArrayElementOrListLink(ElementType&& InElement)
|
||||
: ElementData(InElement)
|
||||
{
|
||||
}
|
||||
|
||||
TSparseArrayElementOrListLink(int32 InPrevFree, int32 InNextFree)
|
||||
: PrevFreeIndex(InPrevFree)
|
||||
, NextFreeIndex(InNextFree)
|
||||
{
|
||||
}
|
||||
|
||||
TSparseArrayElementOrListLink<ElementType> operator=(const TSparseArrayElementOrListLink<ElementType>& Other)
|
||||
{
|
||||
return TSparseArrayElementOrListLink(Other.NextFreeIndex, Other.PrevFreeIndex);
|
||||
}
|
||||
|
||||
/** If the element is allocated, its value is stored here. */
|
||||
ElementType ElementData;
|
||||
|
||||
struct
|
||||
{
|
||||
/** If the element isn't allocated, this is a link to the previous element in the array's free list. */
|
||||
int PrevFreeIndex;
|
||||
|
||||
/** If the element isn't allocated, this is a link to the next element in the array's free list. */
|
||||
int NextFreeIndex;
|
||||
};
|
||||
};
|
||||
|
||||
template <typename ArrayType>
|
||||
class TSparseArray
|
||||
{
|
||||
public:
|
||||
typedef TSparseArrayElementOrListLink<ArrayType> FSparseArrayElement;
|
||||
|
||||
TArray<FSparseArrayElement> Data;
|
||||
TBitArray AllocationFlags;
|
||||
int32 FirstFreeIndex;
|
||||
int32 NumFreeIndices;
|
||||
};
|
||||
Reference in New Issue
Block a user