class
TChunkedArray
template<typename Type, u64 PageSize = 1024>A dynamically-growing array that stores elements in fixed-size pages (chunks) rather than a single contiguous buffer.
Growth only allocates a new page — existing data is never copied or moved. This makes it ideal for large arrays that grow incrementally.
Template parameters
Type | Element type. |
|---|---|
PageSize | Number of elements per page. Must be a power of two. |
Public
Constructors
TChunkedArray<Type, PageSize>
TChunkedArray<Type, PageSize>
TChunkedArray<Type, PageSize>
TChunkedArray<Type, PageSize>
TChunkedArray<Type, PageSize>
Methods
~TChunkedArray<Type, PageSize>
Begin
End
Begin
End
RBegin
REnd
RBegin
REnd
Pop
Removes and destructs the last element.
Size
Returns the number of elements.
Empty
Returns true if the array is empty.
Capacity
Returns the current capacity (number of allocated element slots).
Resize
Resizes the array.
New elements are value-initialized. If the new size is smaller, trailing elements are destructed. Pages are not freed (use Shrink() for that).
Resize
Resizes the array, initializing new elements with .
Reserve
Pre-allocates pages to hold at least elements.
Does not change size.
Shrink
Frees any unused trailing pages beyond what is needed for the current size.
Clear
Destructs all elements and frees all pages.
push_back
push_back
pop_back
size
empty
resize
resize
reserve
begin
end
begin
end
rbegin
rend
rbegin
rend
Operators
operator=
operator=
operator[]
Returns a reference to the element at the given index.
No bounds checking.
operator[]
Returns a const reference to the element at the given index.
No bounds checking.
Private
Methods
GetElement
Returns a reference to the element at index (raw, no construction/destruction).
GetElement
EnsureCapacity
Ensures enough pages are allocated to hold at least elements.
FreeAllPages
Frees all page allocations and clears the page array.
Does not destruct elements.
DestructRange
Destructs elements in the range [startIndex, endIndex) using per-page iteration.
CopyConstructRange
Copy-constructs elements from in the range [startIndex, endIndex) into uninitialized memory.
CopyAssignRange
Copy-assigns elements from in the range [startIndex, endIndex) over already-constructed elements.
DefaultConstructRange
Value-initializes (default-constructs) elements in the range [startIndex, endIndex) in uninitialized memory.
FillConstructRange
Copy-constructs elements in the range [startIndex, endIndex) from in uninitialized memory.