Helios Engine
A modular ECS based data-oriented C++23 game engine framework
Loading...
Searching...
No Matches
helios::utils::EnumerateAdapter< Iter > Class Template Reference

Iterator adapter that adds index information to each element. More...

#include <functional_adapters.hpp>

Inheritance diagram for helios::utils::EnumerateAdapter< Iter >:
helios::utils::FunctionalAdapterBase< EnumerateAdapter< Iter > >

Public Types

using iterator_concept = details::adapter_iterator_concept_t<Iter>
using iterator_category = details::adapter_iterator_category_t<Iter>
using value_type
using reference = value_type
using pointer = void
using difference_type = std::iter_difference_t<Iter>

Public Member Functions

constexpr EnumerateAdapter (Iter begin, Iter end) noexcept(std::is_nothrow_move_constructible_v< Iter > &&std::is_nothrow_copy_constructible_v< Iter >)
 Constructs an enumerate adapter with the given iterator range.
template<ExternalRange R>
requires EnumerateAdapterRequirements<std::ranges::iterator_t<R>>
constexpr EnumerateAdapter (R &range) noexcept(noexcept(EnumerateAdapter(std::ranges::begin(range), std::ranges::end(range))))
 Constructs a enumerate adapter from a range.
template<ExternalRange R>
requires EnumerateAdapterRequirements<std::ranges::iterator_t<const R>>
constexpr EnumerateAdapter (const R &range) noexcept(noexcept(EnumerateAdapter(std::ranges::cbegin(range), std::ranges::cend(range))))
 Constructs a enumerate adapter from a const range.
constexpr EnumerateAdapter (const EnumerateAdapter &)=default
constexpr EnumerateAdapter (EnumerateAdapter &&)=default
constexpr ~EnumerateAdapter ()=default
constexpr EnumerateAdapteroperator= (const EnumerateAdapter &)=default
constexpr EnumerateAdapteroperator= (EnumerateAdapter &&)=default
constexpr EnumerateAdapteroperator++ () noexcept(noexcept(++std::declval< Iter & >()))
constexpr EnumerateAdapter operator++ (int) noexcept(std::is_nothrow_copy_constructible_v< EnumerateAdapter > &&noexcept(++std::declval< EnumerateAdapter & >()))
constexpr reference operator* () const
pointer operator-> () const =delete
constexpr bool operator== (const EnumerateAdapter &other) const noexcept(noexcept(std::declval< const Iter & >()==std::declval< const Iter & >()))
constexpr bool operator!= (const EnumerateAdapter &other) const noexcept(noexcept(std::declval< const EnumerateAdapter & >()==std::declval< const EnumerateAdapter & >()))
constexpr EnumerateAdapter begin () const noexcept(std::is_nothrow_copy_constructible_v< EnumerateAdapter >)
constexpr EnumerateAdapter end () const noexcept(std::is_nothrow_constructible_v< EnumerateAdapter, const Iter &, const Iter & >)
Public Member Functions inherited from helios::utils::FunctionalAdapterBase< EnumerateAdapter< Iter > >
constexpr auto Filter (Pred predicate) const noexcept(noexcept(FilterAdapter< EnumerateAdapter< Iter >, Pred >(GetDerived().begin(), GetDerived().end(), std::move(predicate))))
 Chains another filter operation on top of this iterator.
constexpr auto Map (Func transform) const noexcept(noexcept(MapAdapter< EnumerateAdapter< Iter >, Func >(GetDerived().begin(), GetDerived().end(), std::move(transform))))
 Transforms each element using the given function.
constexpr auto Take (size_t count) const noexcept(noexcept(TakeAdapter< EnumerateAdapter< Iter > >(GetDerived().begin(), GetDerived().end(), count)))
 Limits the number of elements to at most count.
constexpr auto Skip (size_t count) const noexcept(noexcept(SkipAdapter< EnumerateAdapter< Iter > >(GetDerived().begin(), GetDerived().end(), count)))
 Skips the first count elements.
constexpr auto TakeWhile (Pred predicate) const noexcept(noexcept(TakeWhileAdapter< EnumerateAdapter< Iter >, Pred >(GetDerived().begin(), GetDerived().end(), std::move(predicate))))
 Takes elements while a predicate is true.
constexpr auto SkipWhile (Pred predicate) const noexcept(noexcept(SkipWhileAdapter< EnumerateAdapter< Iter >, Pred >(GetDerived().begin(), GetDerived().end(), std::move(predicate))))
 Skips elements while a predicate is true.
constexpr auto Enumerate () const noexcept(noexcept(EnumerateAdapter< Derived >(GetDerived().begin(), GetDerived().end())))
 Adds an index to each element.
constexpr auto Inspect (Func inspector) const noexcept(noexcept(InspectAdapter< EnumerateAdapter< Iter >, Func >(GetDerived().begin(), GetDerived().end(), std::move(inspector))))
 Observes each element without modifying it.
constexpr auto StepBy (size_t step) const noexcept(noexcept(StepByAdapter< EnumerateAdapter< Iter > >(GetDerived().begin(), GetDerived().end(), step)))
 Takes every Nth element.
constexpr auto Chain (OtherIter begin, OtherIter end) const noexcept(noexcept(ChainAdapter< EnumerateAdapter< Iter >, OtherIter >(GetDerived().begin(), GetDerived().end(), std::move(begin), std::move(end))))
 Chains another range after this one.
constexpr auto Reverse () const noexcept(noexcept(ReverseAdapter< EnumerateAdapter< Iter > >(GetDerived().begin(), GetDerived().end())))
 Reverses the order of elements.
constexpr auto Slide (size_t window_size) const noexcept(noexcept(SlideAdapter< EnumerateAdapter< Iter > >(GetDerived().begin(), GetDerived().end(), window_size)))
 Creates sliding windows over elements.
constexpr auto Stride (size_t stride) const noexcept(noexcept(StrideAdapter< EnumerateAdapter< Iter > >(GetDerived().begin(), GetDerived().end(), stride)))
 Takes every Nth element with stride.
constexpr auto Zip (OtherIter begin, OtherIter end) const noexcept(noexcept(ZipAdapter< EnumerateAdapter< Iter >, OtherIter >(GetDerived().begin(), GetDerived().end(), std::move(begin), std::move(end))))
 Zips another range with this one.
constexpr void ForEach (const Action &action) const
 Terminal operation: applies an action to each element.
constexpr T Fold (T init, const Folder &folder) const
 Terminal operation: reduces elements to a single value using a folder function.
constexpr auto Find (const Pred &predicate) const
 Terminal operation: finds the first element satisfying a predicate.
constexpr size_t CountIf (const Pred &predicate) const
 Terminal operation: counts elements satisfying a predicate.
constexpr auto Partition (const Pred &predicate) const
 Terminal operation: partitions elements into two groups based on a predicate.
constexpr auto PartitionWith (const Pred &predicate, Allocator allocator) const
 Terminal operation: partitions elements with a custom allocator.
constexpr auto MaxBy (const KeyFunc &key_func) const
 Terminal operation: finds the element with the maximum value according to a key function.
constexpr auto MinBy (const KeyFunc &key_func) const
 Terminal operation: finds the element with the minimum value according to a key function.
constexpr auto GroupBy (const KeyFunc &key_func) const
 Terminal operation: groups elements by a key function.
constexpr auto GroupByWith (const KeyFunc &key_func, MapAllocator map_allocator, ValueAllocator value_allocator) const
 Terminal operation: groups elements by key with custom allocators.
constexpr auto Collect () const
 Terminal operation: collects all elements into a vector.
constexpr auto CollectWith (Allocator allocator={}) const
 Terminal operation: collects all elements into a vector with a custom allocator.
constexpr void Into (OutIt out) const
 Terminal operation: writes all elements into an output iterator.
constexpr bool Any (const Pred &predicate) const
 Terminal operation: checks if any element satisfies a predicate.
constexpr bool All (const Pred &predicate) const
 Terminal operation: checks if all elements satisfy a predicate.
constexpr bool None (const Pred &predicate) const
 Terminal operation: checks if no elements satisfy a predicate.

Additional Inherited Members

Protected Member Functions inherited from helios::utils::FunctionalAdapterBase< EnumerateAdapter< Iter > >
constexpr EnumerateAdapter< Iter > & GetDerived () noexcept
 Gets reference to derived class instance.

Detailed Description

template<typename Iter>
requires EnumerateAdapterRequirements<Iter>
class helios::utils::EnumerateAdapter< Iter >

Iterator adapter that adds index information to each element.

This adapter yields tuples of (index, value) where index starts at 0 and increments for each element.

Template Parameters
IterUnderlying iterator type
// Enumerate entities with their indices
auto enumerated = query.Enumerate();
for (const auto& [index, _] : enumerated) {
// Use index and components
}

Definition at line 1579 of file functional_adapters.hpp.

Member Typedef Documentation

◆ difference_type

template<typename Iter>
using helios::utils::EnumerateAdapter< Iter >::difference_type = std::iter_difference_t<Iter>

Definition at line 1599 of file functional_adapters.hpp.

◆ iterator_category

template<typename Iter>
using helios::utils::EnumerateAdapter< Iter >::iterator_category = details::adapter_iterator_category_t<Iter>

Definition at line 1594 of file functional_adapters.hpp.

◆ iterator_concept

template<typename Iter>
using helios::utils::EnumerateAdapter< Iter >::iterator_concept = details::adapter_iterator_concept_t<Iter>

Definition at line 1593 of file functional_adapters.hpp.

◆ pointer

template<typename Iter>
using helios::utils::EnumerateAdapter< Iter >::pointer = void

Definition at line 1598 of file functional_adapters.hpp.

◆ reference

template<typename Iter>
using helios::utils::EnumerateAdapter< Iter >::reference = value_type

Definition at line 1597 of file functional_adapters.hpp.

◆ value_type

template<typename Iter>
using helios::utils::EnumerateAdapter< Iter >::value_type
Initial value:
typename MakeEnumeratedValue<std::iter_value_t<Iter>>::type

Definition at line 1595 of file functional_adapters.hpp.

Constructor & Destructor Documentation

◆ EnumerateAdapter() [1/5]

template<typename Iter>
helios::utils::EnumerateAdapter< Iter >::EnumerateAdapter ( Iter begin,
Iter end )
inlineconstexprnoexcept

Constructs an enumerate adapter with the given iterator range.

Parameters
beginStart of the iterator range
endEnd of the iterator range

Definition at line 1606 of file functional_adapters.hpp.

◆ EnumerateAdapter() [2/5]

template<typename Iter>
template<ExternalRange R>
requires EnumerateAdapterRequirements<std::ranges::iterator_t<R>>
helios::utils::EnumerateAdapter< Iter >::EnumerateAdapter ( R & range)
inlineexplicitconstexprnoexcept

Constructs a enumerate adapter from a range.

Template Parameters
RThe type of the input range
Parameters
rangeThe input range to adapt

Definition at line 1618 of file functional_adapters.hpp.

◆ EnumerateAdapter() [3/5]

template<typename Iter>
template<ExternalRange R>
requires EnumerateAdapterRequirements<std::ranges::iterator_t<const R>>
helios::utils::EnumerateAdapter< Iter >::EnumerateAdapter ( const R & range)
inlineexplicitconstexprnoexcept

Constructs a enumerate adapter from a const range.

Template Parameters
RThe type of the input range
Parameters
rangeThe input range to adapt

Definition at line 1629 of file functional_adapters.hpp.

◆ EnumerateAdapter() [4/5]

template<typename Iter>
helios::utils::EnumerateAdapter< Iter >::EnumerateAdapter ( const EnumerateAdapter< Iter > & )
constexprdefault

◆ EnumerateAdapter() [5/5]

template<typename Iter>
helios::utils::EnumerateAdapter< Iter >::EnumerateAdapter ( EnumerateAdapter< Iter > && )
constexprdefault

◆ ~EnumerateAdapter()

template<typename Iter>
helios::utils::EnumerateAdapter< Iter >::~EnumerateAdapter ( )
constexprdefault

Member Function Documentation

◆ begin()

template<typename Iter>
EnumerateAdapter helios::utils::EnumerateAdapter< Iter >::begin ( ) const
inlinenodiscardconstexprnoexcept

Definition at line 1663 of file functional_adapters.hpp.

◆ end()

template<typename Iter>
EnumerateAdapter helios::utils::EnumerateAdapter< Iter >::end ( ) const
inlinenodiscardconstexprnoexcept

Definition at line 1668 of file functional_adapters.hpp.

◆ operator!=()

template<typename Iter>
bool helios::utils::EnumerateAdapter< Iter >::operator!= ( const EnumerateAdapter< Iter > & other) const
inlinenodiscardconstexprnoexcept

Definition at line 1657 of file functional_adapters.hpp.

◆ operator*()

template<typename Iter>
requires EnumerateAdapterRequirements<Iter>
auto helios::utils::EnumerateAdapter< Iter >::operator* ( ) const
nodiscardconstexpr

Definition at line 1709 of file functional_adapters.hpp.

◆ operator++() [1/2]

template<typename Iter>
requires EnumerateAdapterRequirements<Iter>
auto helios::utils::EnumerateAdapter< Iter >::operator++ ( )
constexprnoexcept

Definition at line 1690 of file functional_adapters.hpp.

◆ operator++() [2/2]

template<typename Iter>
requires EnumerateAdapterRequirements<Iter>
auto helios::utils::EnumerateAdapter< Iter >::operator++ ( int )
nodiscardconstexprnoexcept

Definition at line 1699 of file functional_adapters.hpp.

◆ operator->()

template<typename Iter>
pointer helios::utils::EnumerateAdapter< Iter >::operator-> ( ) const
delete

◆ operator=() [1/2]

template<typename Iter>
EnumerateAdapter & helios::utils::EnumerateAdapter< Iter >::operator= ( const EnumerateAdapter< Iter > & )
constexprdefault

◆ operator=() [2/2]

template<typename Iter>
EnumerateAdapter & helios::utils::EnumerateAdapter< Iter >::operator= ( EnumerateAdapter< Iter > && )
constexprdefault

◆ operator==()

template<typename Iter>
bool helios::utils::EnumerateAdapter< Iter >::operator== ( const EnumerateAdapter< Iter > & other) const
inlinenodiscardconstexprnoexcept

Definition at line 1651 of file functional_adapters.hpp.