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

Iterator adapter that steps through elements by a specified stride. More...

#include <functional_adapters.hpp>

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

Public Types

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

Public Member Functions

constexpr StepByAdapter (Iter begin, Iter end, size_t step) noexcept(std::is_nothrow_move_constructible_v< Iter > &&std::is_nothrow_copy_constructible_v< Iter >)
 Constructs a step-by adapter with the given iterator range and step size.
template<ExternalRange R>
requires StepByAdapterRequirements<std::ranges::iterator_t<R>>
constexpr StepByAdapter (R &range, size_t step) noexcept(noexcept(StepByAdapter(std::ranges::begin(range), std::ranges::end(range), step)))
 Constructs a step-by adapter with the given range and step size.
template<ExternalRange R>
requires StepByAdapterRequirements<std::ranges::iterator_t<const R>>
constexpr StepByAdapter (const R &range, size_t step) noexcept(noexcept(StepByAdapter(std::ranges::cbegin(range), std::ranges::cend(range), step)))
 Constructs a step-by adapter with the given const range and step size.
constexpr StepByAdapter (const StepByAdapter &)=default
constexpr StepByAdapter (StepByAdapter &&)=default
constexpr ~StepByAdapter ()=default
constexpr StepByAdapteroperator= (const StepByAdapter &)=default
constexpr StepByAdapteroperator= (StepByAdapter &&)=default
constexpr StepByAdapteroperator++ () noexcept(noexcept(++std::declval< Iter & >()) &&noexcept(std::declval< Iter & >() !=std::declval< Iter & >()))
constexpr StepByAdapter operator++ (int) noexcept(std::is_copy_constructible_v< StepByAdapter > &&noexcept(++std::declval< StepByAdapter & >()))
constexpr reference operator* () const noexcept(noexcept(*std::declval< const Iter & >()))
pointer operator-> () const =delete
constexpr bool operator== (const StepByAdapter &other) const noexcept(noexcept(std::declval< const Iter & >()==std::declval< const Iter & >()))
constexpr bool operator!= (const StepByAdapter &other) const noexcept(noexcept(std::declval< const StepByAdapter & >()==std::declval< const StepByAdapter & >()))
constexpr StepByAdapter begin () const noexcept(std::is_nothrow_copy_constructible_v< StepByAdapter >)
constexpr StepByAdapter end () const noexcept(std::is_nothrow_constructible_v< StepByAdapter, const Iter &, const Iter &, size_t >)
Public Member Functions inherited from helios::utils::FunctionalAdapterBase< StepByAdapter< Iter > >
constexpr auto Filter (Pred predicate) const noexcept(noexcept(FilterAdapter< StepByAdapter< 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< StepByAdapter< 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< StepByAdapter< 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< StepByAdapter< Iter > >(GetDerived().begin(), GetDerived().end(), count)))
 Skips the first count elements.
constexpr auto TakeWhile (Pred predicate) const noexcept(noexcept(TakeWhileAdapter< StepByAdapter< 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< StepByAdapter< Iter >, Pred >(GetDerived().begin(), GetDerived().end(), std::move(predicate))))
 Skips elements while a predicate is true.
constexpr auto Enumerate () const noexcept(noexcept(EnumerateAdapter< StepByAdapter< Iter > >(GetDerived().begin(), GetDerived().end())))
 Adds an index to each element.
constexpr auto Inspect (Func inspector) const noexcept(noexcept(InspectAdapter< StepByAdapter< 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< Derived >(GetDerived().begin(), GetDerived().end(), step)))
 Takes every Nth element.
constexpr auto Chain (OtherIter begin, OtherIter end) const noexcept(noexcept(ChainAdapter< StepByAdapter< 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< StepByAdapter< Iter > >(GetDerived().begin(), GetDerived().end())))
 Reverses the order of elements.
constexpr auto Slide (size_t window_size) const noexcept(noexcept(SlideAdapter< StepByAdapter< Iter > >(GetDerived().begin(), GetDerived().end(), window_size)))
 Creates sliding windows over elements.
constexpr auto Stride (size_t stride) const noexcept(noexcept(StrideAdapter< StepByAdapter< Iter > >(GetDerived().begin(), GetDerived().end(), stride)))
 Takes every Nth element with stride.
constexpr auto Zip (OtherIter begin, OtherIter end) const noexcept(noexcept(ZipAdapter< StepByAdapter< 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< StepByAdapter< Iter > >
constexpr StepByAdapter< Iter > & GetDerived () noexcept
 Gets reference to derived class instance.

Detailed Description

template<typename Iter>
requires StepByAdapterRequirements<Iter>
class helios::utils::StepByAdapter< Iter >

Iterator adapter that steps through elements by a specified stride.

This adapter yields every step-th element from the underlying iterator.

Template Parameters
IterUnderlying iterator type
// Step through entities by 3
auto stepped = query.StepBy(3);

Definition at line 1909 of file functional_adapters.hpp.

Member Typedef Documentation

◆ difference_type

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

Definition at line 1916 of file functional_adapters.hpp.

◆ iterator_category

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

Definition at line 1912 of file functional_adapters.hpp.

◆ iterator_concept

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

Definition at line 1911 of file functional_adapters.hpp.

◆ pointer

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

Definition at line 1915 of file functional_adapters.hpp.

◆ reference

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

Definition at line 1914 of file functional_adapters.hpp.

◆ value_type

template<typename Iter>
using helios::utils::StepByAdapter< Iter >::value_type = std::iter_value_t<Iter>

Definition at line 1913 of file functional_adapters.hpp.

Constructor & Destructor Documentation

◆ StepByAdapter() [1/5]

template<typename Iter>
helios::utils::StepByAdapter< Iter >::StepByAdapter ( Iter begin,
Iter end,
size_t step )
inlineconstexprnoexcept

Constructs a step-by adapter with the given iterator range and step size.

Parameters
beginStart of the iterator range
endEnd of the iterator range
stepNumber of elements to step by

Definition at line 1925 of file functional_adapters.hpp.

◆ StepByAdapter() [2/5]

template<typename Iter>
template<ExternalRange R>
requires StepByAdapterRequirements<std::ranges::iterator_t<R>>
helios::utils::StepByAdapter< Iter >::StepByAdapter ( R & range,
size_t step )
inlineconstexprnoexcept

Constructs a step-by adapter with the given range and step size.

Template Parameters
RThe type of the input range
Parameters
rangeThe input range to adapt
stepNumber of elements to step by

Definition at line 1941 of file functional_adapters.hpp.

◆ StepByAdapter() [3/5]

template<typename Iter>
template<ExternalRange R>
requires StepByAdapterRequirements<std::ranges::iterator_t<const R>>
helios::utils::StepByAdapter< Iter >::StepByAdapter ( const R & range,
size_t step )
inlineconstexprnoexcept

Constructs a step-by adapter with the given const range and step size.

Template Parameters
RThe type of the input range
Parameters
rangeThe input range to adapt
stepNumber of elements to step by

Definition at line 1955 of file functional_adapters.hpp.

◆ StepByAdapter() [4/5]

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

◆ StepByAdapter() [5/5]

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

◆ ~StepByAdapter()

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

Member Function Documentation

◆ begin()

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

Definition at line 1994 of file functional_adapters.hpp.

◆ end()

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

Definition at line 1999 of file functional_adapters.hpp.

◆ operator!=()

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

Definition at line 1988 of file functional_adapters.hpp.

◆ operator*()

template<typename Iter>
reference helios::utils::StepByAdapter< Iter >::operator* ( ) const
inlinenodiscardconstexprnoexcept

Definition at line 1975 of file functional_adapters.hpp.

◆ operator++() [1/2]

template<typename Iter>
requires StepByAdapterRequirements<Iter>
auto helios::utils::StepByAdapter< Iter >::operator++ ( )
constexprnoexcept

Definition at line 2021 of file functional_adapters.hpp.

◆ operator++() [2/2]

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

Definition at line 2033 of file functional_adapters.hpp.

◆ operator->()

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

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ operator==()

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

Definition at line 1982 of file functional_adapters.hpp.