Gaia-ECS v0.9.3
A simple and powerful entity component system
Loading...
Searching...
No Matches
gaia::cnt::ilist< TListItem, TItemHandle, TInternalStorage > Struct Template Reference

Implicit list. Rather than with pointers, items. More...

#include <ilist.h>

Public Types

using internal_storage = TInternalStorage
 
using value_type = TListItem
 
using reference = TListItem &
 
using const_reference = const TListItem &
 
using pointer = TListItem *
 
using const_pointer = const TListItem *
 
using difference_type = typename internal_storage::difference_type
 
using size_type = typename internal_storage::size_type
 
using iterator = typename internal_storage::iterator
 
using const_iterator = typename internal_storage::const_iterator
 
using iterator_category = typename internal_storage::iterator_category
 

Public Member Functions

GAIA_NODISCARD pointer data () noexcept
 
GAIA_NODISCARD const_pointer data () const noexcept
 
GAIA_NODISCARD reference operator[] (size_type index)
 
GAIA_NODISCARD const_reference operator[] (size_type index) const
 
void clear ()
 
GAIA_NODISCARD size_type get_next_free_item () const noexcept
 
GAIA_NODISCARD size_type get_free_items () const noexcept
 
GAIA_NODISCARD size_type item_count () const noexcept
 
GAIA_NODISCARD size_type size () const noexcept
 
GAIA_NODISCARD bool empty () const noexcept
 
GAIA_NODISCARD size_type capacity () const noexcept
 
GAIA_NODISCARD iterator begin () noexcept
 
GAIA_NODISCARD const_iterator begin () const noexcept
 
GAIA_NODISCARD const_iterator cbegin () const noexcept
 
GAIA_NODISCARD iterator end () noexcept
 
GAIA_NODISCARD const_iterator end () const noexcept
 
GAIA_NODISCARD const_iterator cend () const noexcept
 
void reserve (size_type cap)
 
GAIA_NODISCARD TItemHandle alloc (void *ctx)
 Allocates a new item in the list.
 
GAIA_NODISCARD TItemHandle alloc ()
 Allocates a new item in the list.
 
TListItem & free (TItemHandle handle)
 Invalidates handle. Every time an item is deallocated its generation is increased by one.
 
void validate () const
 Verifies that the implicit linked list is valid.
 

Public Attributes

internal_storage m_items
 Implicit list items.
 
size_type m_nextFreeIdx = (size_type)-1
 Index of the next item to recycle.
 
size_type m_freeItems = 0
 Number of items to recycle.
 

Detailed Description

template<typename TListItem, typename TItemHandle, typename TInternalStorage = darray_ilist_storage<TListItem>>
struct gaia::cnt::ilist< TListItem, TItemHandle, TInternalStorage >

Implicit list. Rather than with pointers, items.

Template Parameters
TListItemare linked together through an internal indexing mechanism. To the outside world they are presented as
TItemHandle.All items are stored in a container instance of the type
TInternalStorage.
TListItemneeds to expose slot metadata through ilist_item_traits<TListItem> and expose a constructor that initializes the slot index and generation.

Member Function Documentation

◆ alloc() [1/2]

template<typename TListItem , typename TItemHandle , typename TInternalStorage = darray_ilist_storage<TListItem>>
GAIA_NODISCARD TItemHandle gaia::cnt::ilist< TListItem, TItemHandle, TInternalStorage >::alloc ( )
inline

Allocates a new item in the list.

Returns
Handle to the new item

◆ alloc() [2/2]

template<typename TListItem , typename TItemHandle , typename TInternalStorage = darray_ilist_storage<TListItem>>
GAIA_NODISCARD TItemHandle gaia::cnt::ilist< TListItem, TItemHandle, TInternalStorage >::alloc ( void *  ctx)
inline

Allocates a new item in the list.

Returns
Handle to the new item

◆ free()

template<typename TListItem , typename TItemHandle , typename TInternalStorage = darray_ilist_storage<TListItem>>
TListItem & gaia::cnt::ilist< TListItem, TItemHandle, TInternalStorage >::free ( TItemHandle  handle)
inline

Invalidates handle. Every time an item is deallocated its generation is increased by one.

Parameters
handleHandle

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