Gaia-ECS v0.9.3
A simple and powerful entity component system
Loading...
Searching...
No Matches
gaia::cnt::sparse_storage< T, PageCapacity, Allocator, typename > Class Template Reference

Array with variable size of elements of type. More...

#include <sparse_storage.h>

Public Types

using value_type = T
 
using reference = T &
 
using const_reference = const T &
 
using pointer = T *
 
using const_pointer = const T *
 
using view_policy = mem::data_view_policy_aos< T >
 
using difference_type = detail::difference_type
 
using size_type = detail::size_type
 
using iterator = sparse_iterator< T, PageCapacity, Allocator >
 
using const_iterator = const_sparse_iterator< T, PageCapacity, Allocator >
 
using page_type = detail::sparse_page< T, PageCapacity, Allocator >
 

Public Member Functions

 sparse_storage (const sparse_storage &other)
 
sparse_storageoperator= (const sparse_storage &other)
 
 sparse_storage (sparse_storage &&other) noexcept
 
sparse_storageoperator= (sparse_storage &&other) noexcept
 
GAIA_NODISCARD decltype(auto) operator[] (sparse_id sid) noexcept
 
GAIA_NODISCARD decltype(auto) operator[] (sparse_id sid) const noexcept
 
GAIA_NODISCARD bool has (sparse_id sid) const
 Checks if an item with a given sparse id.
 
GAIA_NODISCARD bool has (const T &arg) const
 Checks if an item arg exists within the storage.
 
template<typename TType >
decltype(auto) add (TType &&arg)
 Inserts the item arg into the storage.
 
decltype(auto) set (sparse_id sid)
 Update the record at the index sid.
 
void del (sparse_id sid) noexcept
 Removes the item at the index sid from the storage.
 
void del (const T &arg) noexcept
 Removes the item arg from the storage.
 
void clear ()
 Clears the storage.
 
GAIA_NODISCARD size_type size () const noexcept
 Returns the number of items inserted into the storage.
 
GAIA_NODISCARD bool empty () const noexcept
 Checks if the storage is empty (no items inserted)
 
GAIA_NODISCARD decltype(auto) front () noexcept
 
GAIA_NODISCARD decltype(auto) front () const noexcept
 
GAIA_NODISCARD decltype(auto) back () noexcept
 
GAIA_NODISCARD decltype(auto) back () const noexcept
 
GAIA_NODISCARD auto begin () noexcept
 
GAIA_NODISCARD auto begin () const noexcept
 
GAIA_NODISCARD auto cbegin () const noexcept
 
GAIA_NODISCARD auto end () noexcept
 
GAIA_NODISCARD auto end () const noexcept
 
GAIA_NODISCARD auto cend () const noexcept
 
GAIA_NODISCARD bool operator== (const sparse_storage &other) const
 
GAIA_NODISCARD constexpr bool operator!= (const sparse_storage &other) const
 

Detailed Description

template<typename T, uint32_t PageCapacity = 4096, typename Allocator = mem::DefaultAllocatorAdaptor, typename = void>
class gaia::cnt::sparse_storage< T, PageCapacity, Allocator, typename >

Array with variable size of elements of type.

Template Parameters
Tallocated on heap. Allocates enough memory to support
PageCapacityelements. Uses
Allocatorto allocate memory.

Member Function Documentation

◆ add()

template<typename T , uint32_t PageCapacity = 4096, typename Allocator = mem::DefaultAllocatorAdaptor, typename = void>
template<typename TType >
decltype(auto) gaia::cnt::sparse_storage< T, PageCapacity, Allocator, typename >::add ( TType &&  arg)
inline

Inserts the item arg into the storage.

Parameters
argData
Returns
Reference to the inserted record or nothing in case it is has a SoA layout.

◆ del() [1/2]

template<typename T , uint32_t PageCapacity = 4096, typename Allocator = mem::DefaultAllocatorAdaptor, typename = void>
void gaia::cnt::sparse_storage< T, PageCapacity, Allocator, typename >::del ( const T &  arg)
inlinenoexcept

Removes the item arg from the storage.

Parameters
argData

◆ del() [2/2]

template<typename T , uint32_t PageCapacity = 4096, typename Allocator = mem::DefaultAllocatorAdaptor, typename = void>
void gaia::cnt::sparse_storage< T, PageCapacity, Allocator, typename >::del ( sparse_id  sid)
inlinenoexcept

Removes the item at the index sid from the storage.

Parameters
sidSparse id

◆ has() [1/2]

template<typename T , uint32_t PageCapacity = 4096, typename Allocator = mem::DefaultAllocatorAdaptor, typename = void>
GAIA_NODISCARD bool gaia::cnt::sparse_storage< T, PageCapacity, Allocator, typename >::has ( const T &  arg) const
inline

Checks if an item arg exists within the storage.

Parameters
argData

◆ has() [2/2]

template<typename T , uint32_t PageCapacity = 4096, typename Allocator = mem::DefaultAllocatorAdaptor, typename = void>
GAIA_NODISCARD bool gaia::cnt::sparse_storage< T, PageCapacity, Allocator, typename >::has ( sparse_id  sid) const
inline

Checks if an item with a given sparse id.

Parameters
sidexists

◆ set()

template<typename T , uint32_t PageCapacity = 4096, typename Allocator = mem::DefaultAllocatorAdaptor, typename = void>
decltype(auto) gaia::cnt::sparse_storage< T, PageCapacity, Allocator, typename >::set ( sparse_id  sid)
inline

Update the record at the index sid.

Parameters
sidSparse id
Returns
Reference to the inserted record or nothing in case it is has a SoA layout.

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