CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::EnumerateIterator< Iterator, Index > Class Template Reference

An iterator type that keeps an index count of the current item. More...

#include <CeresEngine/Foundation/Iterator/Enumerate.hpp>

Public Types

using iterator_category = typename std::iterator_traits< Iterator >::iterator_category
 
using value_type = typename std::iterator_traits< Iterator >::value_type
 
using difference_type = typename std::iterator_traits< Iterator >::difference_type
 
using pointer = typename std::iterator_traits< Iterator >::pointer
 
using reference = typename std::iterator_traits< Iterator >::reference
 

Public Member Functions

 EnumerateIterator (Index index, Iterator &&iterator)
 Creates a new enumerate iterator at the given index positioned at the given it iterator.
 
EnumerateIteratoroperator++ ()
 Increments the iterator. Will also increment the index position.
 
EnumerateIterator operator++ (int)
 Increments the iterator. Will also increment the index position.
 
EnumerateIteratoroperator+ (difference_type offset)
 Advances the iterator by the given offset.
 
EnumerateIteratoroperator-- ()
 Decrements the iterator. Will also decrement the index position.
 
EnumerateIterator operator-- (int)
 Decrements the iterator. Will also decrement the index position.
 
EnumerateIteratoroperator- (difference_type offset)
 Recedes the iterator by the given offset.
 
auto operator* () const noexcept
 Dereferences the iterator and obtain it's value.
 
autooperator-> () const noexcept
 Dereferences the iterator and obtain it's value.
 
bool operator== (const EnumerateIterator &other) const
 
bool operator!= (const EnumerateIterator &other) const
 
bool operator> (const EnumerateIterator &other) const
 
bool operator>= (const EnumerateIterator &other) const
 
bool operator< (const EnumerateIterator &other) const
 
bool operator<= (const EnumerateIterator &other) const
 

Private Attributes

Index mIndex = 0
 The current iteration index.
 
Iterator mIterator
 The current iterator position.
 

Detailed Description

template<typename Iterator, typename Index = std::size_t>
class CeresEngine::EnumerateIterator< Iterator, Index >

An iterator type that keeps an index count of the current item.

Useful when you need both the value and the index of the value when doing for-range loop.

Template Parameters
IteratorThe underlying iterator type.
IndexThe type of the counter index.

Member Typedef Documentation

◆ difference_type

template<typename Iterator , typename Index = std::size_t>
using CeresEngine::EnumerateIterator< Iterator, Index >::difference_type = typename std::iterator_traits<Iterator>::difference_type

◆ iterator_category

template<typename Iterator , typename Index = std::size_t>
using CeresEngine::EnumerateIterator< Iterator, Index >::iterator_category = typename std::iterator_traits<Iterator>::iterator_category

◆ pointer

template<typename Iterator , typename Index = std::size_t>
using CeresEngine::EnumerateIterator< Iterator, Index >::pointer = typename std::iterator_traits<Iterator>::pointer

◆ reference

template<typename Iterator , typename Index = std::size_t>
using CeresEngine::EnumerateIterator< Iterator, Index >::reference = typename std::iterator_traits<Iterator>::reference

◆ value_type

template<typename Iterator , typename Index = std::size_t>
using CeresEngine::EnumerateIterator< Iterator, Index >::value_type = typename std::iterator_traits<Iterator>::value_type

Constructor & Destructor Documentation

◆ EnumerateIterator()

template<typename Iterator , typename Index = std::size_t>
CeresEngine::EnumerateIterator< Iterator, Index >::EnumerateIterator ( Index  index,
Iterator &&  iterator 
)
inline

Creates a new enumerate iterator at the given index positioned at the given it iterator.

Member Function Documentation

◆ operator!=()

◆ operator*()

template<typename Iterator , typename Index = std::size_t>
auto CeresEngine::EnumerateIterator< Iterator, Index >::operator* ( ) const
inlinenoexcept

Dereferences the iterator and obtain it's value.

◆ operator+()

Advances the iterator by the given offset.

◆ operator++() [1/2]

Increments the iterator. Will also increment the index position.

◆ operator++() [2/2]

Increments the iterator. Will also increment the index position.

◆ operator-()

Recedes the iterator by the given offset.

◆ operator--() [1/2]

Decrements the iterator. Will also decrement the index position.

◆ operator--() [2/2]

Decrements the iterator. Will also decrement the index position.

◆ operator->()

template<typename Iterator , typename Index = std::size_t>
auto * CeresEngine::EnumerateIterator< Iterator, Index >::operator-> ( ) const
inlinenoexcept

Dereferences the iterator and obtain it's value.

◆ operator<()

◆ operator<=()

◆ operator==()

◆ operator>()

◆ operator>=()

Member Data Documentation

◆ mIndex

template<typename Iterator , typename Index = std::size_t>
Index CeresEngine::EnumerateIterator< Iterator, Index >::mIndex = 0
private

The current iteration index.

◆ mIterator

template<typename Iterator , typename Index = std::size_t>
Iterator CeresEngine::EnumerateIterator< Iterator, Index >::mIterator
private

The current iterator position.


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