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

#include <functional_adapters.hpp>

Inheritance diagram for helios::utils::FilterAdapter< Iter, Pred >:
helios::utils::FunctionalAdapterBase< FilterAdapter< Iter, Pred > >

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 FilterAdapter (Iter begin, Iter end, Pred predicate) noexcept(std::is_nothrow_copy_constructible_v< Iter > &&std::is_nothrow_move_constructible_v< Iter > &&std::is_nothrow_move_constructible_v< Pred > &&noexcept(AdvanceToValid()))
 Constructs a filter adapter with the given iterator range and predicate.
 
constexpr FilterAdapter (const FilterAdapter &) noexcept(std::is_nothrow_copy_constructible_v< Iter > &&std::is_nothrow_copy_constructible_v< Pred >)=default
 
constexpr FilterAdapter (FilterAdapter &&) noexcept(std::is_nothrow_move_constructible_v< Iter > &&std::is_nothrow_move_constructible_v< Pred >)=default
 
constexpr ~FilterAdapter () noexcept(std::is_nothrow_destructible_v< Iter > &&std::is_nothrow_destructible_v< Pred >)=default
 
constexpr FilterAdapteroperator= (const FilterAdapter &) noexcept(std::is_nothrow_copy_assignable_v< Iter > &&std::is_nothrow_copy_assignable_v< Pred >)=default
 
constexpr FilterAdapteroperator= (FilterAdapter &&) noexcept(std::is_nothrow_move_assignable_v< Iter > &&std::is_nothrow_move_assignable_v< Pred >)=default
 
constexpr FilterAdapteroperator++ () noexcept(noexcept(++std::declval< Iter & >()) &&noexcept(AdvanceToValid()))
 
constexpr FilterAdapter operator++ (int) noexcept(std::is_nothrow_copy_constructible_v< FilterAdapter > &&noexcept(++std::declval< FilterAdapter & >()))
 
constexpr value_type operator* () const noexcept(noexcept(*std::declval< const Iter & >()))
 
constexpr bool operator== (const FilterAdapter &other) const noexcept(noexcept(std::declval< const Iter & >()==std::declval< const Iter & >()))
 
constexpr bool operator!= (const FilterAdapter &other) const noexcept(noexcept(std::declval< const FilterAdapter & >()==std::declval< const FilterAdapter & >()))
 
constexpr bool IsAtEnd () const noexcept(noexcept(std::declval< const Iter & >()==std::declval< const Iter & >()))
 Checks if the iterator has reached the end.
 
constexpr FilterAdapter begin () const noexcept(std::is_nothrow_copy_constructible_v< FilterAdapter >)
 
constexpr FilterAdapter end () const noexcept(std::is_nothrow_constructible_v< FilterAdapter, const Iter &, const Iter &, const Pred & >)
 
- Public Member Functions inherited from helios::utils::FunctionalAdapterBase< FilterAdapter< Iter, Pred > >
constexpr auto Filter (Pred predicate) const noexcept(noexcept(FilterAdapter< FilterAdapter< Iter, Pred >, 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< FilterAdapter< Iter, Pred >, 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< FilterAdapter< Iter, Pred > >(GetDerived().begin(), GetDerived().end(), count)))
 Limits the number of elements to at most count.
 
constexpr auto Skip (size_t count) const noexcept(noexcept(SkipAdapter< FilterAdapter< Iter, Pred > >(GetDerived().begin(), GetDerived().end(), count)))
 Skips the first count elements.
 
constexpr auto TakeWhile (Pred predicate) const noexcept(noexcept(TakeWhileAdapter< FilterAdapter< Iter, Pred >, Pred >(GetDerived().begin(), GetDerived().end(), std::move(predicate))))
 Takes elements while a predicate is true.
 
constexpr auto SkipWhile (Pred predicate) const noexcept(noexcept(SkipWhileAdapter< FilterAdapter< Iter, Pred >, Pred >(GetDerived().begin(), GetDerived().end(), std::move(predicate))))
 Skips elements while a predicate is true.
 
constexpr auto Enumerate () const noexcept(noexcept(EnumerateAdapter< FilterAdapter< Iter, Pred > >(GetDerived().begin(), GetDerived().end())))
 Adds an index to each element.
 
constexpr auto Inspect (Func inspector) const noexcept(noexcept(InspectAdapter< FilterAdapter< Iter, Pred >, Func >(GetDerived().begin(), GetDerived().end(), std::move(inspector))))
 Observes each element without modifying it.
 
constexpr auto StepBy (size_t step) const noexcept(noexcept(StepByAdapter< FilterAdapter< Iter, Pred > >(GetDerived().begin(), GetDerived().end(), step)))
 Takes every Nth element.
 
constexpr auto Chain (OtherIter begin, OtherIter end) const noexcept(noexcept(ChainAdapter< FilterAdapter< Iter, Pred >, 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< FilterAdapter< Iter, Pred > >(GetDerived().begin(), GetDerived().end())))
 Reverses the order of elements.
 
constexpr auto Slide (size_t window_size) const noexcept(noexcept(SlideAdapter< FilterAdapter< Iter, Pred > >(GetDerived().begin(), GetDerived().end(), window_size)))
 Creates sliding windows over elements.
 
constexpr auto Stride (size_t stride) const noexcept(noexcept(StrideAdapter< FilterAdapter< Iter, Pred > >(GetDerived().begin(), GetDerived().end(), stride)))
 Takes every Nth element with stride.
 
constexpr auto Zip (OtherIter begin, OtherIter end) const noexcept(noexcept(ZipAdapter< FilterAdapter< Iter, Pred >, 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< FilterAdapter< Iter, Pred > >
constexpr FilterAdapter< Iter, Pred > & GetDerived () noexcept
 Gets reference to derived class instance.
 
constexpr const FilterAdapter< Iter, Pred > & GetDerived () const noexcept
 Gets const reference to derived class instance.
 

Detailed Description

template<typename Iter, typename Pred>
requires FilterAdapterRequirements<Iter, Pred>
class helios::utils::FilterAdapter< Iter, Pred >

Definition at line 398 of file functional_adapters.hpp.

Member Typedef Documentation

◆ difference_type

template<typename Iter , typename Pred >
using helios::utils::FilterAdapter< Iter, Pred >::difference_type = std::iter_difference_t<Iter>

◆ iterator_category

template<typename Iter , typename Pred >
using helios::utils::FilterAdapter< Iter, Pred >::iterator_category = std::forward_iterator_tag

◆ pointer

template<typename Iter , typename Pred >
using helios::utils::FilterAdapter< Iter, Pred >::pointer = value_type*

◆ reference

template<typename Iter , typename Pred >
using helios::utils::FilterAdapter< Iter, Pred >::reference = value_type

◆ value_type

template<typename Iter , typename Pred >
using helios::utils::FilterAdapter< Iter, Pred >::value_type = std::iter_value_t<Iter>

Constructor & Destructor Documentation

◆ FilterAdapter() [1/3]

template<typename Iter , typename Pred >
constexpr helios::utils::FilterAdapter< Iter, Pred >::FilterAdapter ( Iter  begin,
Iter  end,
Pred  predicate 
)
inlineconstexprnoexcept

Constructs a filter adapter with the given iterator range and predicate.

Parameters
beginStart of the iterator range
endEnd of the iterator range
predicateFunction to filter elements

Definition at line 412 of file functional_adapters.hpp.

416 : begin_(std::move(begin)), current_(begin_), end_(std::move(end)), predicate_(std::move(predicate)) {
417 AdvanceToValid();
418 }
constexpr FilterAdapter end() const noexcept(std::is_nothrow_constructible_v< FilterAdapter, const Iter &, const Iter &, const Pred & >)
constexpr FilterAdapter begin() const noexcept(std::is_nothrow_copy_constructible_v< FilterAdapter >)

◆ FilterAdapter() [2/3]

template<typename Iter , typename Pred >
constexpr helios::utils::FilterAdapter< Iter, Pred >::FilterAdapter ( const FilterAdapter< Iter, Pred > &  ) const &&
constexprdefaultnoexcept

◆ FilterAdapter() [3/3]

template<typename Iter , typename Pred >
constexpr helios::utils::FilterAdapter< Iter, Pred >::FilterAdapter ( FilterAdapter< Iter, Pred > &&  ) const &&
constexprdefaultnoexcept

◆ ~FilterAdapter()

template<typename Iter , typename Pred >
constexpr helios::utils::FilterAdapter< Iter, Pred >::~FilterAdapter ( ) &&
constexprdefaultnoexcept

Member Function Documentation

◆ begin()

template<typename Iter , typename Pred >
constexpr FilterAdapter helios::utils::FilterAdapter< Iter, Pred >::begin ( ) const
inlineconstexprnoexcept

◆ end()

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

Definition at line 463 of file functional_adapters.hpp.

464 {
465 return {end_, end_, predicate_};
466 }

◆ IsAtEnd()

template<typename Iter , typename Pred >
constexpr bool helios::utils::FilterAdapter< Iter, Pred >::IsAtEnd ( ) const
inlineconstexprnoexcept

Checks if the iterator has reached the end.

Returns
True if at end, false otherwise
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/utils/functional_adapters.hpp.

Definition at line 454 of file functional_adapters.hpp.

455 {
456 return current_ == end_;
457 }

◆ operator!=()

template<typename Iter , typename Pred >
constexpr bool helios::utils::FilterAdapter< Iter, Pred >::operator!= ( const FilterAdapter< Iter, Pred > &  other) const
inlineconstexprnoexcept

◆ operator*()

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

◆ operator++() [1/2]

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

Definition at line 481 of file functional_adapters.hpp.

482 {
483 ++current_;
484 AdvanceToValid();
485 return *this;
486}

◆ operator++() [2/2]

template<typename Iter , typename Pred >
requires FilterAdapterRequirements<Iter, Pred>
constexpr auto helios::utils::FilterAdapter< Iter, Pred >::operator++ ( int  )
constexprnoexcept

Definition at line 490 of file functional_adapters.hpp.

492 {
493 auto temp = *this;
494 ++(*this);
495 return temp;
496}

◆ operator=() [1/2]

template<typename Iter , typename Pred >
constexpr FilterAdapter & helios::utils::FilterAdapter< Iter, Pred >::operator= ( const FilterAdapter< Iter, Pred > &  ) &&
constexprdefaultnoexcept

◆ operator=() [2/2]

template<typename Iter , typename Pred >
constexpr FilterAdapter & helios::utils::FilterAdapter< Iter, Pred >::operator= ( FilterAdapter< Iter, Pred > &&  ) &&
constexprdefaultnoexcept

◆ operator==()

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

Definition at line 440 of file functional_adapters.hpp.

441 {
442 return current_ == other.current_;
443 }