Gaia-ECS v1.0.0
A simple and powerful entity component system
Loading...
Searching...
No Matches
gaia::cnt::sparse_iterator< T, PageCapacity, Allocator, typename > Struct Template Reference

Mutable random-access iterator over sparse-storage values. More...

#include <sparse_storage.h>

Public Types

using iterator_category = core::random_access_iterator_tag
 Iterator category.
 
using value_type = T
 Stored value type.
 
using pointer = T *
 Pointer to a stored value.
 
using reference = T &
 Reference to a stored value.
 
using difference_type = detail::difference_type
 Type used for iterator distances.
 
using size_type = detail::size_type
 Type used for iterator offsets.
 
using iterator = sparse_iterator
 Iterator type.
 

Public Member Functions

 sparse_iterator (const sparse_id *pDense, page_type *pPages)
 Constructs an iterator for a dense position and sparse-page array.
 
reference operator* () const
 Returns the value at the current position.
 
pointer operator-> () const
 Returns a pointer to the value at the current position.
 
iterator operator[] (size_type offset) const
 Returns an iterator at an offset from the current position.
 
iteratoroperator+= (size_type diff)
 Advances the iterator.
 
iteratoroperator-= (size_type diff)
 Moves the iterator backward.
 
iteratoroperator++ ()
 Advances to the next value.
 
iterator operator++ (int)
 Advances to the next value.
 
iteratoroperator-- ()
 Moves to the previous value.
 
iterator operator-- (int)
 Moves to the previous value.
 
iterator operator+ (size_type offset) const
 Returns an iterator advanced by an offset.
 
iterator operator- (size_type offset) const
 Returns an iterator moved backward by an offset.
 
difference_type operator- (const iterator &other) const
 Returns the distance from another iterator.
 
GAIA_NODISCARD bool operator== (const iterator &other) const
 Checks whether two iterators refer to the same position.
 
GAIA_NODISCARD bool operator!= (const iterator &other) const
 Checks whether two iterators refer to different positions.
 
GAIA_NODISCARD bool operator> (const iterator &other) const
 Checks whether this iterator follows another iterator.
 
GAIA_NODISCARD bool operator>= (const iterator &other) const
 Checks whether this iterator does not precede another iterator.
 
GAIA_NODISCARD bool operator< (const iterator &other) const
 Checks whether this iterator precedes another iterator.
 
GAIA_NODISCARD bool operator<= (const iterator &other) const
 Checks whether this iterator does not follow another iterator.
 

Detailed Description

template<typename T, uint32_t PageCapacity, typename Allocator, typename = void>
struct gaia::cnt::sparse_iterator< T, PageCapacity, Allocator, typename >

Mutable random-access iterator over sparse-storage values.

Template Parameters
TStored value type.
PageCapacityNumber of sparse entries represented by each page.
AllocatorAllocator used by the sparse pages.

Constructor & Destructor Documentation

◆ sparse_iterator()

template<typename T , uint32_t PageCapacity, typename Allocator , typename = void>
gaia::cnt::sparse_iterator< T, PageCapacity, Allocator, typename >::sparse_iterator ( const sparse_id *  pDense,
page_type *  pPages 
)
inline

Constructs an iterator for a dense position and sparse-page array.

Parameters
pDenseDense sparse-id position.
pPagesSparse-page array containing the values.

Member Function Documentation

◆ operator!=()

template<typename T , uint32_t PageCapacity, typename Allocator , typename = void>
GAIA_NODISCARD bool gaia::cnt::sparse_iterator< T, PageCapacity, Allocator, typename >::operator!= ( const iterator other) const
inline

Checks whether two iterators refer to different positions.

Parameters
otherIterator to compare.
Returns
True if the positions differ.

◆ operator*()

template<typename T , uint32_t PageCapacity, typename Allocator , typename = void>
reference gaia::cnt::sparse_iterator< T, PageCapacity, Allocator, typename >::operator* ( ) const
inline

Returns the value at the current position.

Returns
Mutable reference to the current value.

◆ operator+()

template<typename T , uint32_t PageCapacity, typename Allocator , typename = void>
iterator gaia::cnt::sparse_iterator< T, PageCapacity, Allocator, typename >::operator+ ( size_type  offset) const
inline

Returns an iterator advanced by an offset.

Parameters
offsetNumber of positions to advance.
Returns
Advanced iterator.

◆ operator++() [1/2]

template<typename T , uint32_t PageCapacity, typename Allocator , typename = void>
iterator & gaia::cnt::sparse_iterator< T, PageCapacity, Allocator, typename >::operator++ ( )
inline

Advances to the next value.

Returns
This iterator after advancing.

◆ operator++() [2/2]

template<typename T , uint32_t PageCapacity, typename Allocator , typename = void>
iterator gaia::cnt::sparse_iterator< T, PageCapacity, Allocator, typename >::operator++ ( int  )
inline

Advances to the next value.

Returns
Iterator value before advancing.

◆ operator+=()

template<typename T , uint32_t PageCapacity, typename Allocator , typename = void>
iterator & gaia::cnt::sparse_iterator< T, PageCapacity, Allocator, typename >::operator+= ( size_type  diff)
inline

Advances the iterator.

Parameters
diffNumber of positions to advance.
Returns
This iterator after advancing.

◆ operator-() [1/2]

template<typename T , uint32_t PageCapacity, typename Allocator , typename = void>
difference_type gaia::cnt::sparse_iterator< T, PageCapacity, Allocator, typename >::operator- ( const iterator other) const
inline

Returns the distance from another iterator.

Parameters
otherIterator to subtract.
Returns
Number of positions between the iterators.

◆ operator-() [2/2]

template<typename T , uint32_t PageCapacity, typename Allocator , typename = void>
iterator gaia::cnt::sparse_iterator< T, PageCapacity, Allocator, typename >::operator- ( size_type  offset) const
inline

Returns an iterator moved backward by an offset.

Parameters
offsetNumber of positions to retreat.
Returns
Retreated iterator.

◆ operator--() [1/2]

template<typename T , uint32_t PageCapacity, typename Allocator , typename = void>
iterator & gaia::cnt::sparse_iterator< T, PageCapacity, Allocator, typename >::operator-- ( )
inline

Moves to the previous value.

Returns
This iterator after retreating.

◆ operator--() [2/2]

template<typename T , uint32_t PageCapacity, typename Allocator , typename = void>
iterator gaia::cnt::sparse_iterator< T, PageCapacity, Allocator, typename >::operator-- ( int  )
inline

Moves to the previous value.

Returns
Iterator value before retreating.

◆ operator-=()

template<typename T , uint32_t PageCapacity, typename Allocator , typename = void>
iterator & gaia::cnt::sparse_iterator< T, PageCapacity, Allocator, typename >::operator-= ( size_type  diff)
inline

Moves the iterator backward.

Parameters
diffNumber of positions to retreat.
Returns
This iterator after retreating.

◆ operator->()

template<typename T , uint32_t PageCapacity, typename Allocator , typename = void>
pointer gaia::cnt::sparse_iterator< T, PageCapacity, Allocator, typename >::operator-> ( ) const
inline

Returns a pointer to the value at the current position.

Returns
Pointer to the current value.

◆ operator<()

template<typename T , uint32_t PageCapacity, typename Allocator , typename = void>
GAIA_NODISCARD bool gaia::cnt::sparse_iterator< T, PageCapacity, Allocator, typename >::operator< ( const iterator other) const
inline

Checks whether this iterator precedes another iterator.

Parameters
otherIterator to compare.
Returns
True if this position precedes the other position.

◆ operator<=()

template<typename T , uint32_t PageCapacity, typename Allocator , typename = void>
GAIA_NODISCARD bool gaia::cnt::sparse_iterator< T, PageCapacity, Allocator, typename >::operator<= ( const iterator other) const
inline

Checks whether this iterator does not follow another iterator.

Parameters
otherIterator to compare.
Returns
True if this position is at or before the other position.

◆ operator==()

template<typename T , uint32_t PageCapacity, typename Allocator , typename = void>
GAIA_NODISCARD bool gaia::cnt::sparse_iterator< T, PageCapacity, Allocator, typename >::operator== ( const iterator other) const
inline

Checks whether two iterators refer to the same position.

Parameters
otherIterator to compare.
Returns
True if the positions are equal.

◆ operator>()

template<typename T , uint32_t PageCapacity, typename Allocator , typename = void>
GAIA_NODISCARD bool gaia::cnt::sparse_iterator< T, PageCapacity, Allocator, typename >::operator> ( const iterator other) const
inline

Checks whether this iterator follows another iterator.

Parameters
otherIterator to compare.
Returns
True if this position follows the other position.

◆ operator>=()

template<typename T , uint32_t PageCapacity, typename Allocator , typename = void>
GAIA_NODISCARD bool gaia::cnt::sparse_iterator< T, PageCapacity, Allocator, typename >::operator>= ( const iterator other) const
inline

Checks whether this iterator does not precede another iterator.

Parameters
otherIterator to compare.
Returns
True if this position is at or after the other position.

◆ operator[]()

template<typename T , uint32_t PageCapacity, typename Allocator , typename = void>
iterator gaia::cnt::sparse_iterator< T, PageCapacity, Allocator, typename >::operator[] ( size_type  offset) const
inline

Returns an iterator at an offset from the current position.

Parameters
offsetNumber of positions to advance.
Returns
Offset iterator.

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