CXXIter 0.2
Loading...
Searching...
No Matches
CXXIter::SrcCRef< TContainer > Class Template Reference

CXXIter iterator source that immutably borrows the input item source, and passes immutable references to the items of the source through the iterator. More...

#include <ContainerSources.h>

Inheritance diagram for CXXIter::SrcCRef< TContainer >:
Collaboration diagram for CXXIter::SrcCRef< TContainer >:

Public Member Functions

constexpr SrcCRef (const TContainer &container)
 
- Public Member Functions inherited from CXXIter::IterApi< SrcCRef< TContainer > >
iterator begin ()
 begin() method, part of C++'s iterator interface More...
 
iterator end ()
 end() method, part of C++'s iterator interface More...
 
constexpr SizeHint sizeHint () const
 Get the bounds on the remaining length of this iterator, estimated from the source and all of the chained iterations on it. More...
 
constexpr size_t size () const
 Get this iterator's exact size. More...
 
constexpr IterValue< Itemnext ()
 Get the next element from this iterator (if any), wrapped in a CXXIter::IterValue<>. More...
 
constexpr void advanceBy (size_t n)
 Advance the iterator by n elements. More...
 
constexpr IterValue< ItemnextBack ()
 Get the next element from the back of this iterator (if any), wrapped in a CXXIter::IterValue<>. More...
 
constexpr void forEach (TUseFn useFn)
 Consumer that calls the given function useFn for each of the elements in this iterator. More...
 
constexpr auto collect ()
 Consumer that collects all elements from this iterator in a new container of type TTargetContainer. More...
 
constexpr TTargetContainer collect ()
 Consumer that collects all elements from this iterator in a new container of type TTargetContainer. More...
 
constexpr void collectInto (TTargetContainer &container)
 Consumer that collects all elements from this iterator into the given container. More...
 
constexpr TResult fold (TResult startValue, FoldFn foldFn)
 Consumer that executes the given foldFn for each item in this iterator, to apply to a working value, which is passed on and passed as second argument to the next call to foldFn. More...
 
constexpr bool all (TPredicateFn predicateFn)
 Tests if all elements of this iterator match the given predicateFn. More...
 
constexpr bool all ()
 Tests if all elements of this iterator yield the value true when casted to bool. More...
 
constexpr bool any (TPredicateFn predicateFn)
 Tests if any of the elements of this iterator match the given predicateFn. More...
 
constexpr bool any ()
 Tests if any of the elements of this iterator yield the value true when casted to bool. More...
 
constexpr std::optional< size_t > findIdx (const ItemOwned &searchItem)
 Search for the given searchItem within the items of this iterator, and return the index of the first item from the iterator that is equal to the given searchItem. More...
 
constexpr std::optional< size_t > findIdx (TFindFn findFn)
 Search for the iterator with the given findFn, and return the index of the element from this iterator, for which the findFn returned true the first time. More...
 
constexpr IterValue< Itemfind (TFindFn findFn)
 Searches for an element of this iterator, that satisfies the given findFn predicate. More...
 
constexpr size_t count ()
 Consumer that counts the elements in this iterator. More...
 
constexpr size_t count (TPredicateFn predicateFn)
 Consumer that counts the elements in this iterator, for which the given predicateFn returns true. More...
 
constexpr size_t count (const ItemOwned &countItem)
 Consumer that counts the occurences of countItem within this iterator. More...
 
constexpr TResult sum (TResult startValue=TResult())
 Consumer that calculates the sum of all elements from this iterator. More...
 
std::string stringJoin (const std::string &separator)
 Consumer that concatenates the elements of this iterator to a large std::string , where each element is separated by the specified separator. More...
 
constexpr std::optional< TResult > mean (TResult sumStart=TResult())
 Consumer that calculates the mean of all elements of this iterator. More...
 
constexpr std::optional< TResult > variance ()
 Consumer that calculates the variance of all elements of this iterator. More...
 
constexpr std::optional< TResult > stddev ()
 Consumer that calculates the standard deviation of all elements of this iterator. More...
 
constexpr IterValue< Itemmin ()
 Consumer that yields the smallest element from this iterator. More...
 
constexpr std::optional< size_t > minIdx ()
 Consumer that yields the index of the smallest element within this iterator. More...
 
constexpr IterValue< Itemmax ()
 Consumer that yields the largest element from this iterator. More...
 
constexpr std::optional< size_t > maxIdx ()
 Consumer that yields the index of the largest element within this iterator. More...
 
constexpr IterValue< ItemminBy (TCompValueExtractFn compValueExtractFn)
 Consumer that yields the smallest element from this iterator. Comparison of items is done using the comparison values returned by invoking the given compValueExtractFn on each element. More...
 
constexpr std::optional< size_t > minIdxBy (TCompValueExtractFn compValueExtractFn)
 Consumer that yields the index of the smallest element from this iterator. Comparison of items is done using the comparison values returned by invoking the given compValueExtractFn on each element. More...
 
constexpr IterValue< ItemmaxBy (TMaxValueExtractFn compValueExtractFn)
 Consumer that yields the largest element from this iterator. Comparison of items is done using the comparison values returned by invoking the given compValueExtractFn on each element. More...
 
constexpr std::optional< size_t > maxIdxBy (TMaxValueExtractFn compValueExtractFn)
 Consumer that yields the index of the largest element from this iterator. Comparison of items is done using the comparison values returned by invoking the given TCompValueExtractFn on each element. More...
 
constexpr IterValue< Itemlast ()
 Consumer that yields the last element of this iterator. More...
 
constexpr IterValue< Itemnth (size_t n)
 Return the {n}-th element from this iterator (if available). More...
 
constexpr op::Caster< TSelf, TItemOutput > cast ()
 Constructs a new iterator that casts the elements of this iterator to the type requested by TItemOutput. More...
 
constexpr auto copied ()
 Constructs a new iterator that copies the elements of this iterator. More...
 
constexpr auto indexed ()
 Constructs a new iterator that tags each element of this iterator with the corresponding index, stored in a std::pair. More...
 
constexpr op::FlagLast< TSelf > flagLast ()
 Constructs a new iterator that tags each element with a boolean value specifying whether the element is the last one in the iterator. Boolean and actual iterator element are stored in a std::pair. More...
 
constexpr op::Filter< TSelf, TFilterFn > filter (TFilterFn filterFn)
 Constructs a new iterator that only contains the elements from this iterator, for which the given filterFn returned true. More...
 
constexpr op::Unique< TSelf, TMapFn > unique (TMapFn mapFn)
 Constructs a new iterator that only contains every element of the input iterator only once. More...
 
constexpr auto unique ()
 Constructs a new iterator that only contains every element of the input iterator only once. More...
 
constexpr op::Reverse< TSelf > reverse ()
 Constructs a new iterator that provides the elements of this iterator in reverse order. More...
 
constexpr op::Chunked< TSelf, CHUNK_SIZE > chunked ()
 Create new iterator that collects elements from this iterator in chunks of size up to CHUNK_SIZE, which then constitue the elements of the new iterator. More...
 
constexpr op::ChunkedExact< TSelf, CHUNK_SIZE, STEP_SIZE > chunkedExact ()
 Create new iterator that collects elements from this iterator in exact-sized chunks of CHUNK_SIZE, which then constitue the elements of the new iterator. More...
 
constexpr auto map (TMapFn mapFn)
 Creates an iterator that uses the given mapFn to map each element from this iterator to elements of the new iterator. More...
 
constexpr auto flatMap (TFlatMapFn mapFn)
 Creates an iterator that works like map(), but flattens nested containers. More...
 
constexpr auto flatMap ()
 Creates an iterator that flattens the iterable elements of this iterator. More...
 
constexpr auto generateFrom (TGeneratorFn generatorFn)
 Creates a new iterator containing the items that the given generator produces for each element in this iterator. More...
 
constexpr op::InplaceModifier< TSelf, TModifierFn > modify (TModifierFn modifierFn)
 Allows to inspect and modify each item in-place, that passes through this iterator. More...
 
constexpr auto filterMap (TFilterMapFn filterMapFn)
 Creates a new iterator that filters and maps items from this iterator. More...
 
constexpr op::SkipN< TSelf > skip (size_t cnt)
 Creates an iterator that skips the first cnt elements from this iterator, before it yields the remaining items. More...
 
constexpr op::SkipWhile< TSelf, TSkipPredicate > skipWhile (TSkipPredicate skipPredicate)
 Creates an iterator that skips the first elements of this iterator, for which the given skipPredicate returns true. More...
 
constexpr op::TakeN< TSelf > take (size_t cnt)
 Creates an iterator that yields at most the first cnt elements from this iterator. More...
 
constexpr auto takeWhile (TTakePredicate takePredicate)
 Creates an iterator that yields the first elements of this iterator, for which the given takePredicate returns true. More...
 
constexpr auto stepBy (size_t stepWidth)
 Creates an iterator with the requested stepWidth from this iterator. More...
 
constexpr op::Zipper< TSelf, std::pair, TOtherIterator > zip (TOtherIterator &&otherIterator)
 "Zips up" two CXXIter iterators into a single iterator over pairs from both iterators. More...
 
constexpr op::Zipper< TSelf, std::tuple, TOtherIterators... > zipTuple (TOtherIterators &&... otherIterators)
 "Zips up" an arbitrary amount of CXXIter iterators into a single iterator over std::tuple<> from both iterators. More...
 
constexpr op::Chainer< TSelf, TOtherIterator > chain (TOtherIterator &&otherIterator)
 Chains this iterator with the given otherIterator, resulting in a new iterator that first yields the elements of this iterator, and then the ones from the otherIterator. More...
 
constexpr op::Alternater< TSelf, TOtherIterators... > alternate (TOtherIterators &&... otherIterators)
 Alternating the elements of this iterator with the ones from the other given iterator(s). More...
 
constexpr op::Intersperser< TSelf, TOtherIterator > intersperse (TOtherIterator &&otherIterator)
 Draw elements from the given otherIterator and use the returned elements as separators between the elements of this iterator. More...
 
constexpr auto groupBy (TGroupIdentifierFn groupIdentFn)
 Groups the elements of this iterator according to the values returned by the given groupidentFn. More...
 
constexpr auto sort (TCompareFn compareFn)
 Creates a new iterator that takes the items from this iterator, and passes them on sorted, using the supplied compareFn. More...
 
constexpr auto sort ()
 Creates a new iterator that takes the items from this iterator, and passes them on sorted. More...
 
constexpr auto sortBy (TSortValueExtractFn sortValueExtractFn)
 Creates a new iterator that takes the items from this iterator, and passes them on sorted. More...
 

Friends

struct trait::Iterator< SrcCRef< TContainer > >
 
struct trait::DoubleEndedIterator< SrcCRef< TContainer > >
 
struct trait::ExactSizeIterator< SrcCRef< TContainer > >
 
struct trait::ContiguousMemoryIterator< SrcCRef< TContainer > >
 

Additional Inherited Members

- Public Types inherited from CXXIter::IterApi< SrcCRef< TContainer > >
using Iterator = trait::Iterator< TSelf >
 Type of the trait::Iterator implemenation for this. More...
 
using Item = typename Iterator::Item
 Type of the elements of this iterator. (Can be references) More...
 
using ItemOwned = std::remove_cvref_t< Item >
 Owned Type of the elements of this iterator. (References removed). More...
 

Detailed Description

template<typename TContainer>
requires concepts::SourceContainer<std::remove_cvref_t<TContainer>>
class CXXIter::SrcCRef< TContainer >

CXXIter iterator source that immutably borrows the input item source, and passes immutable references to the items of the source through the iterator.

This guarantees the original source to stay untouched & unmodified.

Definition at line 163 of file ContainerSources.h.

Constructor & Destructor Documentation

◆ SrcCRef()

template<typename TContainer >
constexpr CXXIter::SrcCRef< TContainer >::SrcCRef ( const TContainer &  container)
inlineconstexpr

Definition at line 173 of file ContainerSources.h.

Friends And Related Function Documentation

◆ trait::ContiguousMemoryIterator< SrcCRef< TContainer > >

template<typename TContainer >
friend struct trait::ContiguousMemoryIterator< SrcCRef< TContainer > >
friend

Definition at line 145 of file ContainerSources.h.

◆ trait::DoubleEndedIterator< SrcCRef< TContainer > >

template<typename TContainer >
friend struct trait::DoubleEndedIterator< SrcCRef< TContainer > >
friend

Definition at line 145 of file ContainerSources.h.

◆ trait::ExactSizeIterator< SrcCRef< TContainer > >

template<typename TContainer >
friend struct trait::ExactSizeIterator< SrcCRef< TContainer > >
friend

Definition at line 145 of file ContainerSources.h.

◆ trait::Iterator< SrcCRef< TContainer > >

template<typename TContainer >
friend struct trait::Iterator< SrcCRef< TContainer > >
friend

Definition at line 145 of file ContainerSources.h.


The documentation for this class was generated from the following file: