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

#include <functional_adapters.hpp>

Inheritance diagram for helios::utils::InspectAdapter< Iter, Func >:
helios::utils::FunctionalAdapterBase< InspectAdapter< Iter, Func > >

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

Detailed Description

template<typename Iter, typename Func>
requires InspectAdapterRequirements<Iter, Func>
class helios::utils::InspectAdapter< Iter, Func >

Definition at line 1272 of file functional_adapters.hpp.

Member Typedef Documentation

◆ difference_type

template<typename Iter , typename Func >
using helios::utils::InspectAdapter< Iter, Func >::difference_type = std::iter_difference_t<Iter>

◆ iterator_category

template<typename Iter , typename Func >
using helios::utils::InspectAdapter< Iter, Func >::iterator_category = std::forward_iterator_tag

◆ pointer

template<typename Iter , typename Func >
using helios::utils::InspectAdapter< Iter, Func >::pointer = value_type*

◆ reference

template<typename Iter , typename Func >
using helios::utils::InspectAdapter< Iter, Func >::reference = value_type

◆ value_type

template<typename Iter , typename Func >
using helios::utils::InspectAdapter< Iter, Func >::value_type = std::iter_value_t<Iter>

Constructor & Destructor Documentation

◆ InspectAdapter() [1/3]

template<typename Iter , typename Func >
constexpr helios::utils::InspectAdapter< Iter, Func >::InspectAdapter ( Iter  begin,
Iter  end,
Func  inspector 
)
inlineconstexprnoexcept

Constructs an inspect adapter with the given iterator range and inspector function.

Parameters
beginStart of the iterator range
endEnd of the iterator range
inspectorFunction to call for each element

Definition at line 1286 of file functional_adapters.hpp.

1289 : begin_(std::move(begin)), current_(begin_), end_(std::move(end)), inspector_(std::move(inspector)) {}
constexpr InspectAdapter begin() const noexcept(std::is_nothrow_copy_constructible_v< InspectAdapter >)
constexpr InspectAdapter end() const noexcept(std::is_nothrow_constructible_v< InspectAdapter, const Iter &, const Iter &, const Func & >)

◆ InspectAdapter() [2/3]

template<typename Iter , typename Func >
constexpr helios::utils::InspectAdapter< Iter, Func >::InspectAdapter ( const InspectAdapter< Iter, Func > &  ) const &&
constexprdefaultnoexcept

◆ InspectAdapter() [3/3]

template<typename Iter , typename Func >
constexpr helios::utils::InspectAdapter< Iter, Func >::InspectAdapter ( InspectAdapter< Iter, Func > &&  ) const &&
constexprdefaultnoexcept

◆ ~InspectAdapter()

template<typename Iter , typename Func >
constexpr helios::utils::InspectAdapter< Iter, Func >::~InspectAdapter ( ) &&
constexprdefaultnoexcept

Member Function Documentation

◆ begin()

template<typename Iter , typename Func >
constexpr InspectAdapter helios::utils::InspectAdapter< Iter, Func >::begin ( ) const
inlineconstexprnoexcept

◆ end()

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

Definition at line 1324 of file functional_adapters.hpp.

1325 {
1326 return {end_, end_, inspector_};
1327 }

◆ operator!=()

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

Definition at line 1315 of file functional_adapters.hpp.

1316 {
1317 return !(*this == other);
1318 }

◆ operator*()

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

Definition at line 1355 of file functional_adapters.hpp.

1357 {
1358 auto value = *current_;
1359 if constexpr (std::invocable<Func, decltype(value)>) {
1360 inspector_(value);
1361 } else {
1362 std::apply(inspector_, value);
1363 }
1364 return value;
1365}

◆ operator++() [1/2]

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

Definition at line 1338 of file functional_adapters.hpp.

1338 {
1339 ++current_;
1340 return *this;
1341}

◆ operator++() [2/2]

template<typename Iter , typename Func >
requires InspectAdapterRequirements<Iter, Func>
constexpr auto helios::utils::InspectAdapter< Iter, Func >::operator++ ( int  )
constexprnoexcept

Definition at line 1345 of file functional_adapters.hpp.

1347 {
1348 auto temp = *this;
1349 ++(*this);
1350 return temp;
1351}

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ operator==()

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

Definition at line 1310 of file functional_adapters.hpp.

1311 {
1312 return current_ == other.current_;
1313 }