1#ifndef ORIGINAL_GENERATORS_H
2#define ORIGINAL_GENERATORS_H
27 template<
typename TYPE>
48 template<
typename TYPE,
typename Callback>
69 template<
typename TYPE,
typename Callback>
90 template<
typename TYPE,
typename Callback>
114 template<
typename T,
typename U>
131 template<
typename TYPE>
150 template<
typename TYPE,
typename Callback>
169 template<
typename TYPE,
typename Callback>
188 template<
typename TYPE,
typename Callback>
207 template<
typename TYPE,
typename Callback>
231 template<
typename T, std::convertible_to<T> U>
252 template<
typename T, std::convertible_to<T> U>
273 template<
typename TYPE>
293 template<
typename TYPE>
313 template<
typename TYPE,
typename Callback>
333 template<
typename TYPE,
typename Callback>
357 template<
typename Callback>
365 template<
typename Generator>
368 template<
typename TYPE,
typename F>
371 template<
typename T,
typename U>
374 template<
typename T,
typename U>
436 template<
typename TYPE,
typename F>
484 template<
typename =
void>
494 template<
typename =
void>
504 template<
typename =
void>
516 template<
typename T,
typename U>
527 template<
typename T,
typename U>
547 template<
typename =
void>
626 template<
typename TYPE,
typename SET = hashSet<TYPE>>
653 template <
typename TYPE,
template <
typename>
typename SERIAL = vector>
666template <
typename TYPE>
671 for (
auto elem : gen)
678template <
typename TYPE,
typename Callback>
683 co_yield c(std::forward<TYPE>(
elem));
687template <
typename TYPE,
typename Callback>
691 for (
auto elem : gen)
693 if (c(std::forward<TYPE>(elem)))
700template <
typename TYPE,
typename Callback>
704 for (
auto elem : gen)
706 if (c(std::forward<TYPE>(elem)))
714template <
typename T,
typename U>
716original::zip(coroutine::generator<T> gen1, coroutine::generator<U> gen2)
718 auto elem1 = gen1.
next();
719 auto elem2 = gen2.next();
720 while (elem1 && elem2)
722 co_yield {std::move(*elem1), std::move(*elem2)};
723 elem1 = std::move(gen1.next());
724 elem2 = std::move(gen2.next());
728template <
typename TYPE>
732 while (
auto val = gen.next())
739template <
typename TYPE,
typename Callback>
743 while (
auto val = gen.next())
745 if (c(std::forward<TYPE>(*val)))
751template <
typename TYPE,
typename Callback>
754 while (
auto val =
gen.next())
756 if (!c(std::forward<TYPE>(*
val)))
762template <
typename TYPE,
typename Callback>
765 while (
auto val =
gen.next())
767 if (c(std::forward<TYPE>(*
val)))
773template <
typename TYPE,
typename Callback>
776 while (
auto val =
gen.next())
778 if (c(std::forward<TYPE>(*
val)))
784template<
typename T, std::convertible_to<T> U>
786original::join(coroutine::generator<T> gen1, coroutine::generator<U> gen2)
788 for (
auto elem : gen1)
792 for (
auto elem : gen2)
794 co_yield static_cast<T
>(elem);
798template <
typename T, std::convertible_to<T> U>
802 for (
auto [elem1, elem2] : gen)
805 co_yield static_cast<T
>(elem2);
809template <
typename TYPE>
814 for (
auto elem : gen)
825template <
typename TYPE>
830 for (
auto elem : gen)
841template <
typename TYPE,
typename Callback>
845 for (
auto elem : gen)
847 if (c(std::forward<TYPE>(elem))){
855template <
typename TYPE,
typename Callback>
860 if (c(std::forward<TYPE>(
elem)))
868template <
typename Callback>
871template <
typename Callback>
872template <
typename Generator>
875 return this->c_(std::forward<Generator>(gen));
878template <
typename TYPE,
typename F>
881 return p(std::move(
gen));
932template <
typename T,
typename U>
940template<
typename T,
typename U>
968 return count(std::move(
gen), std::move(c));
976 return all(std::move(
gen), std::move(c));
984 return none(std::move(
gen), std::move(c));
992 return any(std::move(
gen), std::move(c));
1008 return find(std::move(
gen), std::move(c));
Lazy sequence generator using C++20 coroutines.
Definition coroutines.h:57
alternative< TYPE > next()
Advances generator and gets next value.
Definition coroutines.h:408
Pipe adapter for generator operations to enable fluent chaining.
Definition generators.h:358
friend auto enumerate()
Creates an enumerate pipe operation.
friend auto skip(u_integer n)
Creates a skip pipe operation.
friend auto all(F &&f)
Creates an all-match pipe operation.
friend auto take(u_integer n)
Creates a take pipe operation.
friend auto any(F &&f)
Creates an any-match pipe operation.
friend auto none(F &&f)
Creates a none-match pipe operation.
friend auto flatten()
Creates a flatten pipe operation.
friend auto filters(F &&f)
Creates a filter pipe operation.
friend auto find(F &&f)
Creates an element-finding pipe operation.
friend auto position(F &&f)
Creates a position-finding pipe operation.
friend auto count()
Creates a count pipe operation.
friend auto count(F &&f)
Creates a conditional count pipe operation.
friend auto operator|(coroutine::generator< TYPE > gen, genPipe< F > p)
Pipe operator for generator operations.
friend auto extract(F &&f)
Creates an extract pipe operation.
friend auto transforms(F &&f)
Creates a transform pipe operation.
Unique ownership smart pointer with move semantics.
Definition ownerPtr.h:37
Abstract base class for unique element containers.
Definition set.h:44
virtual bool add(const K_TYPE &e)=0
Adds a new element to the set.
Checks derivation or type identity using std::derived_from.
Definition types.h:472
C++20 coroutine support with generator pattern implementation.
Generic pair container implementation.
Main namespace for the project Original.
Definition algorithms.h:21
SET collect(coroutine::generator< TYPE > gen)
Collects generator elements into a set.
Definition generators.h:628
coroutine::generator< TYPE > skip(coroutine::generator< TYPE > gen, u_integer n)
Skips the first n elements of a generator.
SERIAL< TYPE > list(coroutine::generator< TYPE > gen)
Collects generator elements into a list container.
Definition generators.h:655
bool all(coroutine::generator< TYPE > gen, Callback &&c)
Checks if all elements satisfy a predicate.
Definition generators.h:752
coroutine::generator< TYPE > take(coroutine::generator< TYPE > gen, u_integer n)
Takes the first n elements from a generator.
auto zipWith(coroutine::generator< U > gen2)
Creates a zipWith pipe operation.
Definition generators.h:949
TYPE find(coroutine::generator< TYPE > gen, Callback &&c)
Finds the first element satisfying a predicate.
Definition generators.h:856
coroutine::generator< T > join(coroutine::generator< T > gen1, coroutine::generator< U > gen2)
Joins two generators of compatible types.
coroutine::generator< TYPE > filters(coroutine::generator< TYPE > gen, Callback &&c)
Filters generator elements based on a predicate.
coroutine::generator< TYPE > extract(coroutine::generator< TYPE > gen, Callback &&c)
Extracts elements that do not satisfy a predicate.
u_integer position(coroutine::generator< TYPE > gen, Callback &&c)
Finds the position of the first element satisfying a predicate.
auto enumerate()
Creates an enumerate pipe operation.
Definition generators.h:909
bitSet< ALLOC_ > operator|(const bitSet< ALLOC_ > &lbs, const bitSet< ALLOC_ > &rbs)
Bitwise OR operator for two bitSets.
auto transforms(coroutine::generator< TYPE > gen, Callback &&c) -> coroutine::generator< std::invoke_result_t< Callback, TYPE > >
Transforms generator elements using a callable.
Definition generators.h:679
bool none(coroutine::generator< TYPE > gen, Callback &&c)
Checks if no elements satisfy a predicate.
Definition generators.h:763
coroutine::generator< couple< T, U > > zip(coroutine::generator< T > gen1, coroutine::generator< U > gen2)
Zips two generators into pairs.
auto count()
Creates a count pipe operation.
Definition generators.h:957
bool any(coroutine::generator< TYPE > gen, Callback &&c)
Checks if any element satisfies a predicate.
Definition generators.h:774
auto flatten()
Creates a flatten pipe operation.
Definition generators.h:941
Standard namespace extensions for original::alternative.
Definition allocator.h:351
Implementation of set containers with different underlying data structures.
Dynamic array container with automatic resizing.