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

#include <functional_adapters.hpp>

Inheritance diagram for helios::utils::ConcatAdapter< Iter >:
helios::utils::FunctionalAdapterBase< ConcatAdapter< 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 ConcatAdapter (Iter first_begin, Iter first_end, Iter second_begin, Iter second_end) noexcept(std::is_nothrow_move_constructible_v< Iter > &&noexcept(std::declval< Iter & >() !=std::declval< Iter & >()))
 Constructs a concat adapter with two iterator ranges.
 
constexpr ConcatAdapter (const ConcatAdapter &) noexcept(std::is_nothrow_copy_constructible_v< Iter >)=default
 
constexpr ConcatAdapter (ConcatAdapter &&) noexcept(std::is_nothrow_move_constructible_v< Iter >)=default
 
constexpr ~ConcatAdapter () noexcept(std::is_nothrow_destructible_v< Iter >)=default
 
constexpr ConcatAdapteroperator= (const ConcatAdapter &) noexcept(std::is_nothrow_copy_assignable_v< Iter >)=default
 
constexpr ConcatAdapteroperator= (ConcatAdapter &&) noexcept(std::is_nothrow_move_assignable_v< Iter >)=default
 
constexpr ConcatAdapteroperator++ () noexcept(noexcept(++std::declval< Iter & >()) &&noexcept(std::declval< Iter & >()==std::declval< Iter & >()) &&noexcept(std::declval< Iter & >() !=std::declval< Iter & >()))
 
constexpr ConcatAdapter operator++ (int) noexcept(std::is_nothrow_copy_constructible_v< ConcatAdapter > &&noexcept(++std::declval< ConcatAdapter & >()))
 
constexpr value_type operator* () const noexcept(noexcept(*std::declval< const Iter & >()))
 
constexpr bool operator== (const ConcatAdapter &other) const noexcept(noexcept(std::declval< const Iter & >()==std::declval< const Iter & >()))
 
constexpr bool operator!= (const ConcatAdapter &other) const noexcept(noexcept(std::declval< const ConcatAdapter & >()==std::declval< const ConcatAdapter & >()))
 
constexpr bool IsAtEnd () const noexcept(noexcept(std::declval< const Iter & >()==std::declval< const Iter & >()))
 Checks if the adapter is at the end.
 
constexpr size_t Size () const noexcept(noexcept(std::declval< Iter & >() !=std::declval< Iter & >()) &&noexcept(++std::declval< Iter & >()))
 Returns the total size of both ranges.
 
constexpr ConcatAdapter begin () const noexcept(std::is_nothrow_copy_constructible_v< ConcatAdapter >)
 
constexpr ConcatAdapter end () const noexcept(std::is_nothrow_copy_constructible_v< ConcatAdapter > &&std::is_nothrow_copy_constructible_v< Iter >)
 
- Public Member Functions inherited from helios::utils::FunctionalAdapterBase< ConcatAdapter< Iter > >
constexpr auto Filter (Pred predicate) const noexcept(noexcept(FilterAdapter< ConcatAdapter< 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< ConcatAdapter< 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< ConcatAdapter< 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< ConcatAdapter< Iter > >(GetDerived().begin(), GetDerived().end(), count)))
 Skips the first count elements.
 
constexpr auto TakeWhile (Pred predicate) const noexcept(noexcept(TakeWhileAdapter< ConcatAdapter< 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< ConcatAdapter< Iter >, Pred >(GetDerived().begin(), GetDerived().end(), std::move(predicate))))
 Skips elements while a predicate is true.
 
constexpr auto Enumerate () const noexcept(noexcept(EnumerateAdapter< ConcatAdapter< Iter > >(GetDerived().begin(), GetDerived().end())))
 Adds an index to each element.
 
constexpr auto Inspect (Func inspector) const noexcept(noexcept(InspectAdapter< ConcatAdapter< 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< ConcatAdapter< Iter > >(GetDerived().begin(), GetDerived().end(), step)))
 Takes every Nth element.
 
constexpr auto Chain (OtherIter begin, OtherIter end) const noexcept(noexcept(ChainAdapter< ConcatAdapter< 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< ConcatAdapter< Iter > >(GetDerived().begin(), GetDerived().end())))
 Reverses the order of elements.
 
constexpr auto Slide (size_t window_size) const noexcept(noexcept(SlideAdapter< ConcatAdapter< Iter > >(GetDerived().begin(), GetDerived().end(), window_size)))
 Creates sliding windows over elements.
 
constexpr auto Stride (size_t stride) const noexcept(noexcept(StrideAdapter< ConcatAdapter< Iter > >(GetDerived().begin(), GetDerived().end(), stride)))
 Takes every Nth element with stride.
 
constexpr auto Zip (OtherIter begin, OtherIter end) const noexcept(noexcept(ZipAdapter< ConcatAdapter< 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< ConcatAdapter< Iter > >
constexpr ConcatAdapter< Iter > & GetDerived () noexcept
 Gets reference to derived class instance.
 
constexpr const ConcatAdapter< Iter > & GetDerived () const noexcept
 Gets const reference to derived class instance.
 

Detailed Description

template<typename Iter>
requires ConcatAdapterRequirements<Iter>
class helios::utils::ConcatAdapter< Iter >

Definition at line 2544 of file functional_adapters.hpp.

Member Typedef Documentation

◆ difference_type

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

◆ iterator_category

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

◆ pointer

◆ reference

◆ value_type

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

Constructor & Destructor Documentation

◆ ConcatAdapter() [1/3]

template<typename Iter >
constexpr helios::utils::ConcatAdapter< Iter >::ConcatAdapter ( Iter  first_begin,
Iter  first_end,
Iter  second_begin,
Iter  second_end 
)
inlineconstexprnoexcept

Constructs a concat adapter with two iterator ranges.

Parameters
first_beginStart of the first iterator range
first_endEnd of the first iterator range
second_beginStart of the second iterator range
second_endEnd of the second iterator range

Definition at line 2559 of file functional_adapters.hpp.

2562 : first_current_(std::move(first_begin)),
2563 first_end_(std::move(first_end)),
2564 second_current_(std::move(second_begin)),
2565 second_end_(std::move(second_end)),
2566 in_first_(first_current_ != first_end_) {}

◆ ConcatAdapter() [2/3]

template<typename Iter >
constexpr helios::utils::ConcatAdapter< Iter >::ConcatAdapter ( const ConcatAdapter< Iter > &  ) const
constexprdefaultnoexcept

◆ ConcatAdapter() [3/3]

template<typename Iter >
constexpr helios::utils::ConcatAdapter< Iter >::ConcatAdapter ( ConcatAdapter< Iter > &&  ) const
constexprdefaultnoexcept

◆ ~ConcatAdapter()

Member Function Documentation

◆ begin()

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

◆ end()

template<typename Iter >
requires ConcatAdapterRequirements<Iter>
constexpr auto helios::utils::ConcatAdapter< Iter >::end ( ) const
constexprnoexcept
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/utils/functional_adapters.hpp.

Definition at line 2685 of file functional_adapters.hpp.

2687 {
2688 auto end_iter = *this;
2689 end_iter.first_current_ = first_end_;
2690 end_iter.second_current_ = second_end_;
2691 end_iter.in_first_ = false;
2692 return end_iter;
2693}

◆ IsAtEnd()

template<typename Iter >
constexpr bool helios::utils::ConcatAdapter< Iter >::IsAtEnd ( ) const
inlineconstexprnoexcept

Checks if the adapter is at the end.

Returns
True if all elements have been consumed
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/utils/functional_adapters.hpp.

Definition at line 2597 of file functional_adapters.hpp.

2598 {
2599 return !in_first_ && (second_current_ == second_end_);
2600 }

◆ operator!=()

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

Definition at line 2588 of file functional_adapters.hpp.

2589 {
2590 return !(*this == other);
2591 }

◆ operator*()

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

Definition at line 2581 of file functional_adapters.hpp.

2581 {
2582 return in_first_ ? *first_current_ : *second_current_;
2583 }

◆ operator++() [1/2]

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

Definition at line 2627 of file functional_adapters.hpp.

2630 {
2631 if (in_first_) {
2632 ++first_current_;
2633 if (first_current_ == first_end_) {
2634 in_first_ = false;
2635 }
2636 } else {
2637 if (second_current_ != second_end_) {
2638 ++second_current_;
2639 }
2640 }
2641 return *this;
2642}

◆ operator++() [2/2]

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

Definition at line 2646 of file functional_adapters.hpp.

2648 {
2649 auto temp = *this;
2650 ++(*this);
2651 return temp;
2652}

◆ operator=() [1/2]

template<typename Iter >
constexpr ConcatAdapter & helios::utils::ConcatAdapter< Iter >::operator= ( ConcatAdapter< Iter > &&  )
constexprdefaultnoexcept

◆ operator=() [2/2]

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

◆ operator==()

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

Definition at line 2656 of file functional_adapters.hpp.

2657 {
2658 // Check if both are at end (in second range and at second_end_)
2659 const bool this_at_end = !in_first_ && (second_current_ == second_end_);
2660 const bool other_at_end = !other.in_first_ && (other.second_current_ == other.second_end_);
2661
2662 if (this_at_end && other_at_end) {
2663 return true;
2664 }
2665
2666 // Otherwise, must be in same range at same position
2667 if (in_first_ != other.in_first_) {
2668 return false;
2669 }
2670
2671 return in_first_ ? (first_current_ == other.first_current_) : (second_current_ == other.second_current_);
2672}

◆ Size()

template<typename Iter >
requires ConcatAdapterRequirements<Iter>
constexpr size_t helios::utils::ConcatAdapter< Iter >::Size ( ) const
constexprnoexcept

Returns the total size of both ranges.

This requires iterating through both ranges to count elements.

Returns
Total number of elements in both ranges
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/utils/functional_adapters.hpp.

Definition at line 2676 of file functional_adapters.hpp.

2677 {
2678 size_t count = std::accumulate(first_current_, first_end_, 0);
2679 count += std::accumulate(second_current_, second_end_, 0);
2680 return count;
2681}