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

#include <functional_adapters.hpp>

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

Public Types

using iterator_category = std::forward_iterator_tag
 
using value_type = std::iter_value_t< Iter >
 
using difference_type = std::iter_difference_t< Iter >
 
using pointer = value_type *
 
using reference = value_type
 

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.
 
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 value_type operator* () const noexcept(noexcept(*std::declval< const Iter & >()))
 
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< StepByAdapter< Iter > >(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 Chain (R &range) const noexcept(noexcept(ChainAdapterFromRange(GetDerived(), range)))
 Chains another range after this one.
 
constexpr auto Chain (const R &range) const noexcept(noexcept(ChainAdapterFromRange(GetDerived(), range)))
 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 auto Zip (R &range) const noexcept(noexcept(ZipAdapterFromRange(GetDerived(), range)))
 Zips another range with this one.
 
constexpr auto Zip (const R &range) const noexcept(noexcept(ZipAdapterFromRange(GetDerived(), range)))
 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 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.
 
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 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 Collect () const
 Terminal operation: collects all elements into a vector.
 
constexpr void Into (OutIt out) const
 

Additional Inherited Members

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

Detailed Description

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

Definition at line 1380 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>

◆ iterator_category

template<typename Iter >
using helios::utils::StepByAdapter< Iter >::iterator_category = std::forward_iterator_tag

◆ pointer

◆ reference

◆ value_type

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

Constructor & Destructor Documentation

◆ StepByAdapter() [1/3]

template<typename Iter >
constexpr 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 1394 of file functional_adapters.hpp.

1396 : begin_(std::move(begin)), current_(begin_), end_(std::move(end)), step_(step > 0 ? step : 1) {}
constexpr StepByAdapter end() const noexcept(std::is_nothrow_constructible_v< StepByAdapter, const Iter &, const Iter &, size_t >)
constexpr StepByAdapter begin() const noexcept(std::is_nothrow_copy_constructible_v< StepByAdapter >)

◆ StepByAdapter() [2/3]

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

◆ StepByAdapter() [3/3]

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

◆ ~StepByAdapter()

Member Function Documentation

◆ begin()

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

◆ end()

template<typename Iter >
constexpr StepByAdapter helios::utils::StepByAdapter< Iter >::end ( ) const
inlineconstexprnoexcept
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/utils/functional_adapters.hpp.

Definition at line 1428 of file functional_adapters.hpp.

1429 {
1430 return {end_, end_, step_};
1431 }

◆ operator!=()

template<typename Iter >
constexpr bool helios::utils::StepByAdapter< Iter >::operator!= ( const StepByAdapter< Iter > &  other) const
inlineconstexprnoexcept
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/utils/functional_adapters.hpp.

Definition at line 1419 of file functional_adapters.hpp.

1420 {
1421 return !(*this == other);
1422 }

◆ operator*()

template<typename Iter >
constexpr value_type helios::utils::StepByAdapter< Iter >::operator* ( ) const
inlineconstexprnoexcept

◆ operator++() [1/2]

template<typename Iter >
requires StepByAdapterRequirements<Iter>
constexpr auto helios::utils::StepByAdapter< Iter >::operator++ ( )
constexprnoexcept
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/utils/functional_adapters.hpp.

Definition at line 1442 of file functional_adapters.hpp.

1444 {
1445 for (size_t i = 0; i < step_ && current_ != end_; ++i) {
1446 ++current_;
1447 }
1448 return *this;
1449}

◆ operator++() [2/2]

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

Definition at line 1453 of file functional_adapters.hpp.

1455 {
1456 auto temp = *this;
1457 ++(*this);
1458 return temp;
1459}

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ operator==()

template<typename Iter >
constexpr bool helios::utils::StepByAdapter< Iter >::operator== ( const StepByAdapter< Iter > &  other) const
inlineconstexprnoexcept
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/utils/functional_adapters.hpp.

Definition at line 1414 of file functional_adapters.hpp.

1415 {
1416 return current_ == other.current_;
1417 }