template<typename type_t>
class xtd::collections::generic::enumerable_generator< type_t >
Represents an enumerable generator that supports deferred, lazy iteration over a collection of a specified type using C++20 coroutines.
- Definition
template<typename type_t>
Exposes the enumerator, which supports a simple iteration over a collection of a specified type.
Definition ienumerable.hpp:40
- Header
#include <xtd/collections/generic/enumerable_generator>
- Namespace
- xtd::collections::generic
- Library
- xtd.core
- Examples
- The following example demonstrates how to create and consume an xtd::collections::generic::enumerable_generator <type_t> using the co_yield keyword and LINQ pipeline operators.
#include <xtd/xtd>
[[nodiscard]]
auto odd_numbers_generator(
int count = 100,
int min_value = 0,
int max_value = 100) -> enumerable_generator<int> {
for (auto __ : range(count))
co_yield rnd.
next(min_value, max_value) | 1;
}
auto main() -> int {
for (
auto number : odd_numbers_generator().where(_ % 5 == 0).distinct().order_by(_))
}
auto count() const noexcept -> xtd::usize
Definition enumerable.hpp:200
Represents a pseudo-random number generator, a device that produces a sequence of numbers that meet c...
Definition random.hpp:42
virtual auto next() const -> xtd::int32
Returns a nonnegative random number.
auto println(FILE *file) -> void
Writes the current line terminator to the file output stream using the specified format information.
Definition println.hpp:14
|
| using | value_type |
| | Represents the xtd::collections::generic::ienumerable value type.
|
| using | iterator |
| | Represents the iterator of xtd::collections::generic::ienumerable value type.
|
| using | const_iterator |
| | Represents the const iterator of xtd::collections::generic::ienumerable value type.
|
| using | iterator |
| | Represents the iterator of enumerable value type.
|
| using | const_iterator |
| | Represents the const iterator of enumerable value type.
|
| using | enumerable_type |
| | Represents the ienumerable enumerable type.
|
| using | value_type |
| | Represents the ienumerable value type.
|
| using | ienumerable |
| | Represents the ienumerable value type.
|
| using | list |
| | Represents the list value type.
|
| | object ()=default |
| | Create a new instance of the ultimate base class object.
|
| virtual auto | equals (const object &obj) const noexcept -> bool |
| | Determines whether the specified object is equal to the current object.
|
| virtual auto | get_hash_code () const noexcept -> xtd::usize |
| | Serves as a hash function for a particular type.
|
| virtual auto | get_type () const noexcept -> type_object |
| | Gets the type of the current instance.
|
| template<typename object_t> |
| auto | memberwise_clone () const -> xtd::unique_ptr_object< object_t > |
| | Creates a shallow copy of the current object.
|
| virtual auto | begin () const -> const_iterator |
| | Returns an iterator to the first element of the enumerable.
|
| virtual auto | cbegin () const -> const_iterator |
| | Returns an iterator to the first element of the enumerable.
|
| virtual auto | cend () const -> const_iterator |
| | Returns an iterator to the element following the last element of the enumerable.
|
| virtual auto | end () const -> const_iterator |
| | Returns an iterator to the element following the last element of the enumerable.
|
| auto | aggregate (func_t &&funcfunc) const -> type_t |
| | Applies an accumulator function over a sequence.
|
| auto | all (predicate_t &&predicatepredicate) const -> bool |
| | Determines whether all elements of a sequence satisfy a condition.
|
| auto | any () const noexcept -> bool |
| | Determines whether a sequence contains any elements.
|
| auto | append (element_t &&element) const noexcept |
| | Appends a value to the end of the sequence.
|
| auto | as_enumerable () const noexcept |
| | Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
|
| auto | average () const noexcept |
| | Computes the average of a sequence of value_t values.
|
| auto | cast () const noexcept |
| | Casts the elements of an xtd::collections::generic::ienumerable to the specified type.
|
| auto | chunk (xtd::usize size) const |
| | Splits the elements of a sequence into chunks of size at most size.
|
| auto | concat (second_t &&second) const noexcept |
| | Concatenates two sequences.
|
| auto | contains (type_t &&value) const noexcept -> bool |
| | Determines whether a sequence contains a specified element by using the default equality comparer.
|
| auto | count () const noexcept -> xtd::usize |
| | Returns the number of elements in current sequence.
|
| auto | count_by (key_selector_t &&key_selector) const noexcept |
| | Returns the count of elements in the current sequence grouped by key.
|
| auto | default_if_empty () const noexcept |
| | Returns the elements of the specified sequence or the type parameter's default value in a singleton collection if the current sequence is empty.
|
| auto | distinct () const noexcept |
| | Returns distinct elements from a sequence by using the default equality comparer to compare values.
|
| auto | first_or_default (predicate_t &&predicatepredicate, type_t &&default_value) const noexcept -> type_t |
| | Returns the first element of the sequence that satisfies a condition, or a specified default value if no such element is found.
|
|
auto | max (selector_t &&selector) const |
|
auto | min (auto &&selector) const |
| auto | order () const |
| | Sorts the elements of a sequence in ascending order.
|
| auto | order_by (const std::function< type_t(const type_t &)> &key_selector) const |
| | Sorts the elements of a sequence in ascending order according to a key.
|
| auto | order_by_descending (const std::function< key_t(const type_t &)> &key_selector) const |
| | Sorts the elements of a sequence in descending order according to a key.
|
| auto | select (auto &&selector) const |
| | Projects each element of a sequence into a new form.
|
| auto | to_array () const -> xtd::array< type_t > |
| | Creates a xtd::array <type_t> from an xtd::collections::generic::ienumerable <type_t>.
|
| auto | to_list () const -> xtd::collections::generic::list< type_t > |
| | Creates a xtd::collections::generic::list <type_t> from an xtd::collections::generic::ienumerable <type_t>.
|
| auto | where (auto &&predicatepredicate) const |
| | Filters a sequence of values based on a predicate.
|
| template<typename object_a_t, typename object_b_t> |
| static auto | equals (const object_a_t &object_a, const object_b_t &object_b) noexcept -> bool |
| | Determines whether the specified object instances are considered equal.
|
| template<typename object_a_t, typename object_b_t> |
| static auto | reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept -> bool |
| | Determines whether the specified object instances are the same instance.
|
| static auto | to_const_iterator (typename source_collection_t::const_iterator &value, const source_collection_t &source_collection, const target_collection_t &target_collection) noexcept -> typename target_collection_t::const_iterator |
| | Converts source iterator to target iterator.
|
| static auto | to_iterator (typename source_collection_t::const_iterator &value, const source_collection_t &source_collection, const target_collection_t &target_collection) noexcept -> typename target_collection_t::const_iterator |
| | Converts source iterator to target iterator.
|