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

#include <functional_adapters.hpp>

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

Public Types

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

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.
 
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 value_type operator* () const
 
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< EnumerateAdapter< Iter > >(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 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< 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 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< EnumerateAdapter< Iter > >
constexpr EnumerateAdapter< Iter > & GetDerived () noexcept
 Gets reference to derived class instance.
 
constexpr const EnumerateAdapter< Iter > & GetDerived () const noexcept
 Gets const reference to derived class instance.
 

Detailed Description

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

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

◆ iterator_category

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

◆ pointer

◆ reference

◆ value_type

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

Constructor & Destructor Documentation

◆ EnumerateAdapter() [1/3]

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

1186 : begin_(std::move(begin)), current_(begin_), end_(std::move(end)) {}
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 & >)

◆ EnumerateAdapter() [2/3]

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

◆ EnumerateAdapter() [3/3]

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

◆ ~EnumerateAdapter()

Member Function Documentation

◆ begin()

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

◆ end()

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

◆ operator!=()

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

Definition at line 1206 of file functional_adapters.hpp.

1207 {
1208 return !(*this == other);
1209 }

◆ operator*()

template<typename Iter >
requires EnumerateAdapterRequirements<Iter>
constexpr auto helios::utils::EnumerateAdapter< Iter >::operator* ( ) const
constexpr
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/utils/functional_adapters.hpp.

Definition at line 1248 of file functional_adapters.hpp.

1248 {
1249 auto value = *current_;
1250 if constexpr (details::TupleLike<decltype(value)>) {
1251 return std::tuple_cat(std::tuple{index_}, value);
1252 } else {
1253 return std::tuple{index_, value};
1254 }
1255}

◆ operator++() [1/2]

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

Definition at line 1230 of file functional_adapters.hpp.

1230 {
1231 ++current_;
1232 ++index_;
1233 return *this;
1234}

◆ operator++() [2/2]

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

Definition at line 1238 of file functional_adapters.hpp.

1240 {
1241 auto temp = *this;
1242 ++(*this);
1243 return temp;
1244}

◆ operator=() [1/2]

◆ operator=() [2/2]

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

◆ operator==()

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

Definition at line 1201 of file functional_adapters.hpp.

1202 {
1203 return current_ == other.current_;
1204 }