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

Random-access iterator over the logical sequence stored in a sringbuffer. More...

#include <sringbuffer.h>

Public Types

using value_type = T
 Element value type.
 
using pointer = T *
 Pointer to an element.
 
using reference = T &
 Reference to an element.
 
using difference_type = sringbuffer_detail::difference_type
 Type used for iterator distances.
 
using size_type = sringbuffer_detail::size_type
 Type used for indices and offsets.
 
using iterator = sringbuffer_iterator
 Iterator type.
 
using iterator_category = core::random_access_iterator_tag
 Iterator category tag.
 

Public Member Functions

 sringbuffer_iterator (pointer ptr, sringbuffer_detail::size_type tail, sringbuffer_detail::size_type size, sringbuffer_detail::size_type index)
 Constructs an iterator over a ring-buffer sequence.
 
Toperator* () const
 Dereferences the current logical element.
 
Toperator-> () const
 Accesses the current logical element.
 
iterator operator[] (size_type offset) const
 Accesses storage at a logical offset using the declared iterator result type.
 
iteratoroperator+= (size_type diff)
 Advances by a logical offset.
 
iteratoroperator-= (size_type diff)
 Moves backward by a logical offset.
 
iteratoroperator++ ()
 Advances by one logical position.
 
iterator operator++ (int)
 Advances by one logical position.
 
iteratoroperator-- ()
 Moves backward by one logical position.
 
iterator operator-- (int)
 Moves backward by one logical position.
 
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
 Calculates the logical distance between iterators from the same buffer.
 
GAIA_NODISCARD bool operator== (const iterator &other) const
 Compares logical iterator positions.
 
GAIA_NODISCARD bool operator!= (const iterator &other) const
 Compares logical iterator positions.
 
GAIA_NODISCARD bool operator> (const iterator &other) const
 Compares logical iterator positions.
 
GAIA_NODISCARD bool operator>= (const iterator &other) const
 Compares logical iterator positions.
 
GAIA_NODISCARD bool operator< (const iterator &other) const
 Compares logical iterator positions.
 
GAIA_NODISCARD bool operator<= (const iterator &other) const
 Compares logical iterator positions.
 

Detailed Description

template<typename T, sringbuffer_detail::size_type N>
struct gaia::cnt::sringbuffer_iterator< T, N >

Random-access iterator over the logical sequence stored in a sringbuffer.

Template Parameters
TElement type, optionally const-qualified.
NRing-buffer capacity.

Constructor & Destructor Documentation

◆ sringbuffer_iterator()

template<typename T , sringbuffer_detail::size_type N>
gaia::cnt::sringbuffer_iterator< T, N >::sringbuffer_iterator ( pointer  ptr,
sringbuffer_detail::size_type  tail,
sringbuffer_detail::size_type  size,
sringbuffer_detail::size_type  index 
)
inline

Constructs an iterator over a ring-buffer sequence.

Parameters
ptrAddress of the physical buffer.
tailPhysical index of the logical front element.
sizeNumber of live elements in the buffer.
indexLogical iterator index in the range [0, size].

Member Function Documentation

◆ operator!=()

template<typename T , sringbuffer_detail::size_type N>
GAIA_NODISCARD bool gaia::cnt::sringbuffer_iterator< T, N >::operator!= ( const iterator other) const
inline

Compares logical iterator positions.

Parameters
otherIterator from the same buffer.
Returns
True when the iterators have different logical indices.

◆ operator*()

template<typename T , sringbuffer_detail::size_type N>
T & gaia::cnt::sringbuffer_iterator< T, N >::operator* ( ) const
inline

Dereferences the current logical element.

Returns
Reference to the current element.

◆ operator+()

template<typename T , sringbuffer_detail::size_type N>
iterator gaia::cnt::sringbuffer_iterator< T, N >::operator+ ( size_type  offset) const
inline

Returns an iterator advanced by an offset.

Parameters
offsetNumber of logical positions to advance.
Returns
Offset iterator.

◆ operator++() [1/2]

template<typename T , sringbuffer_detail::size_type N>
iterator & gaia::cnt::sringbuffer_iterator< T, N >::operator++ ( )
inline

Advances by one logical position.

Returns
This iterator after advancement.

◆ operator++() [2/2]

template<typename T , sringbuffer_detail::size_type N>
iterator gaia::cnt::sringbuffer_iterator< T, N >::operator++ ( int  )
inline

Advances by one logical position.

Returns
Iterator value before advancement.

◆ operator+=()

template<typename T , sringbuffer_detail::size_type N>
iterator & gaia::cnt::sringbuffer_iterator< T, N >::operator+= ( size_type  diff)
inline

Advances by a logical offset.

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

◆ operator-() [1/2]

template<typename T , sringbuffer_detail::size_type N>
difference_type gaia::cnt::sringbuffer_iterator< T, N >::operator- ( const iterator other) const
inline

Calculates the logical distance between iterators from the same buffer.

Parameters
otherIterator to subtract.
Returns
Signed logical index difference.

◆ operator-() [2/2]

template<typename T , sringbuffer_detail::size_type N>
iterator gaia::cnt::sringbuffer_iterator< T, N >::operator- ( size_type  offset) const
inline

Returns an iterator moved backward by an offset.

Parameters
offsetNumber of logical positions to move backward.
Returns
Offset iterator.

◆ operator--() [1/2]

template<typename T , sringbuffer_detail::size_type N>
iterator & gaia::cnt::sringbuffer_iterator< T, N >::operator-- ( )
inline

Moves backward by one logical position.

Returns
This iterator after movement.

◆ operator--() [2/2]

template<typename T , sringbuffer_detail::size_type N>
iterator gaia::cnt::sringbuffer_iterator< T, N >::operator-- ( int  )
inline

Moves backward by one logical position.

Returns
Iterator value before movement.

◆ operator-=()

template<typename T , sringbuffer_detail::size_type N>
iterator & gaia::cnt::sringbuffer_iterator< T, N >::operator-= ( size_type  diff)
inline

Moves backward by a logical offset.

Parameters
diffNumber of positions to move backward.
Returns
This iterator after movement.

◆ operator->()

template<typename T , sringbuffer_detail::size_type N>
T * gaia::cnt::sringbuffer_iterator< T, N >::operator-> ( ) const
inline

Accesses the current logical element.

Returns
Pointer to the current element.

◆ operator<()

template<typename T , sringbuffer_detail::size_type N>
GAIA_NODISCARD bool gaia::cnt::sringbuffer_iterator< T, N >::operator< ( const iterator other) const
inline

Compares logical iterator positions.

Parameters
otherIterator from the same buffer.
Returns
True when this iterator precedes other.

◆ operator<=()

template<typename T , sringbuffer_detail::size_type N>
GAIA_NODISCARD bool gaia::cnt::sringbuffer_iterator< T, N >::operator<= ( const iterator other) const
inline

Compares logical iterator positions.

Parameters
otherIterator from the same buffer.
Returns
True when this iterator does not follow other.

◆ operator==()

template<typename T , sringbuffer_detail::size_type N>
GAIA_NODISCARD bool gaia::cnt::sringbuffer_iterator< T, N >::operator== ( const iterator other) const
inline

Compares logical iterator positions.

Parameters
otherIterator from the same buffer.
Returns
True when both iterators have the same logical index.

◆ operator>()

template<typename T , sringbuffer_detail::size_type N>
GAIA_NODISCARD bool gaia::cnt::sringbuffer_iterator< T, N >::operator> ( const iterator other) const
inline

Compares logical iterator positions.

Parameters
otherIterator from the same buffer.
Returns
True when this iterator follows other.

◆ operator>=()

template<typename T , sringbuffer_detail::size_type N>
GAIA_NODISCARD bool gaia::cnt::sringbuffer_iterator< T, N >::operator>= ( const iterator other) const
inline

Compares logical iterator positions.

Parameters
otherIterator from the same buffer.
Returns
True when this iterator does not precede other.

◆ operator[]()

template<typename T , sringbuffer_detail::size_type N>
iterator gaia::cnt::sringbuffer_iterator< T, N >::operator[] ( size_type  offset) const
inline

Accesses storage at a logical offset using the declared iterator result type.

Parameters
offsetLogical offset from the current index.
Returns
Value read from the corresponding physical storage position.

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