Open 3D Engine Atom Gem API Reference  24.09
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::StableDynamicArray< T, ElementsPerPage, Allocator > Class Template Reference

#include <StableDynamicArray.h>

Classes

class  const_iterator
 Forward const iterator for StableDynamicArray. More...
 
class  iterator
 Forward iterator for StableDynamicArray. More...
 
struct  IteratorRange
 
struct  Page
 Private class used by StableDynamicArray to manage the arrays of data. More...
 
class  pageIterator
 Forward iterator for an individual page in StableDynamicArray. More...
 

Public Types

using ParallelRanges = AZStd::vector< IteratorRange >
 
using Handle = StableDynamicArrayHandle< T >
 
using WeakHandle = StableDynamicArrayWeakHandle< T >
 

Public Member Functions

 StableDynamicArray (allocator_type allocator)
 
Handle insert (const value_type &value)
 Reserves and constructs an item of type T and returns a handle to it.
 
Handle insert (value_type &&value)
 Reserves and constructs an item of type T and returns a handle to it.
 
template<class ... Args>
Handle emplace (Args &&... args)
 Reserves and constructs an item of type T with provided args and returns a handle to it.
 
void erase (Handle &handle)
 Destructs and frees the memory associated with a handle, then invalidates the handle.
 
size_t size () const
 Returns the number of items in this container.
 
ParallelRanges GetParallelRanges ()
 
void DefragmentHandle (Handle &handle)
 
void ReleaseEmptyPages ()
 Release any empty pages that may exist to free up memory.
 
StableDynamicArrayMetrics GetMetrics ()
 
iterator begin ()
 Returns a forward iterator to the start of the array.
 
const_iterator cbegin () const
 
iterator end ()
 Returns an iterator representing the end of the array.
 
const_iterator cend () const
 
size_t GetPageIndex (const Handle &handle) const
 Returns the page index for the given handle.
 
template<class ... Args>
auto emplace (Args &&... args) -> Handle
 

Detailed Description

template<typename T, size_t ElementsPerPage = 512, class Allocator = AZStd::allocator>
class AZ::StableDynamicArray< T, ElementsPerPage, Allocator >

A StableDynamicArray uses a variable number of arrays to store data. Basically this container is a list of arrays, with some information to track usage within those arrays, some optimization to keep jumping through the list to a minimum, and a forward iterator to traverse the whole container. This container produces better cache locality when iterating on elements (vs a list) and keeps appending/removing cost low by reusing empty slots. Resizing is also contained to allocating new arrays. It will always place new items at the front-most slot of the first array with available space. DefragmentHandle() can be called to reorganize data to reduce the amount of empty slots.


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