xtd 0.2.0
Loading...
Searching...
No Matches
xtd::collections::generic::enumerable< type_t > Struct Template Reference

Definition

template<class type_t>
struct xtd::collections::generic::enumerable< type_t >

Represents the enumerable concept.

Definition
template<class value_t>
Exposes the enumerator, which supports a simple iteration over a collection of a specified type.
Definition ienumerable.hpp:40
Definition enumerable.hpp:17
std::remove_cvref_t< value_t > raw_type
Represents a raw type alias equivalent to std::remove_cvref_t<value_t>.
Definition raw_type.hpp:25
Header
#include <xtd//collections/generic/enumerable>
Namespace
xtd
Library
xtd.core
Examples
The following code shows how to use xtd::collections::generic::enumerable concept
#include <xtd/xtd>
auto int_generator() -> enumerable_generator<int> {
co_yield 15;
co_yield 11;
co_yield 13;
co_yield 14;
co_yield 12;
}
template <collections::generic::enumerable enumerable_t>
[[nodiscard]] auto enumerate(enumerable_t&& enumerable) -> enumerable_generator<enumerable_value_type<enumerable_t>> {
for (const auto& item : enumerable)
co_yield item;
}
auto main() -> int {
for (auto item : enumerate(array {5, 1, 3, 4, 2}).select([](auto v) {return v * 2;}).order())
println("{,2}", item);
for (auto item : enumerate(list {10, 6, 8, 9, 7}).select([](auto v) {return v * 3;}).order())
println("{,2}", item);
for (auto item : enumerate(int_generator()).select([](auto v) {return v * 4;}).order())
println("{,2}", item);
}
// This code produces the following output :
//
// 2
// 4
// 6
// 8
// 10
// 18
// 21
// 24
// 27
// 30
// 44
// 48
// 52
// 56
// 60
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
Represents an enumerable enumerable_generator.
Definition enumerable_generator.hpp:24
constexpr auto select
The xtd::ranges::views::select instance.
Definition select.hpp:40
@ v
The V key.
Definition console_key.hpp:130
void println(FILE *file)
Writes the current line terminator to the file output stream using the specified format information.
Definition println.hpp:14

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