xtd 0.2.0
Loading...
Searching...
No Matches
enumerable.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "../../../linq/enumerable.hpp"
6
8namespace xtd {
10 namespace collections {
12 namespace generic {
14 namespace extensions {
30 template <typename enumerable_t, typename source_t>
31 class enumerable {
32 public:
34
42 source_t aggregate(const std::function<source_t(const source_t&, const source_t&)>& func) const {
44 }
51 template<typename func_t>
52 source_t aggregate(const func_t& func) const {
54 }
62 template<typename accumulate_t>
63 accumulate_t aggregate(const accumulate_t& seed, const std::function<accumulate_t(const source_t&, const accumulate_t&)>& func) const {
64 return xtd::linq::enumerable::aggregate(base(), seed, func);
65 }
73 template<typename accumulate_t, typename func_t>
74 accumulate_t aggregate(const accumulate_t& seed, const func_t& func) const {
75 return xtd::linq::enumerable::aggregate(base(), seed, func);
76 }
85 template<typename accumulate_t, typename result_t>
86 result_t aggregate(const accumulate_t& seed, const std::function<accumulate_t(const source_t&, const accumulate_t&)>& func, const std::function<result_t(const accumulate_t&)>& result_selector) const {
87 return xtd::linq::enumerable::aggregate(base(), seed, func, result_selector);
88 }
97 template<typename accumulate_t, typename result_t, typename func_t, typename result_selector_t>
98 result_t aggregate(const accumulate_t& seed, const func_t& func, const result_selector_t& result_selector) const {
99 return xtd::linq::enumerable::aggregate(base(), seed, func, result_selector);
100 }
109 template<typename accumulate_t, typename func_t, typename result_selector_t>
110 accumulate_t aggregate(const accumulate_t& seed, const func_t& func, const result_selector_t& result_selector) const {
111 return xtd::linq::enumerable::aggregate(base(), seed, func, result_selector);
112 }
113
120 bool all(const std::function<bool(const source_t&)>& predicate) const {
122 }
129 template<typename predicate_t>
130 bool all(const predicate_t& predicate) const {
132 }
133
139 bool any() const noexcept {
140 return xtd::linq::enumerable::any(base());
141 }
148 bool any(const std::function<bool(const source_t&)>& predicate) const {
150 }
157 template<typename predicate_t>
158 bool any(const predicate_t& predicate) const {
160 }
161
168 const xtd::collections::generic::ienumerable<source_t>& append(const source_t& element) const noexcept {
169 return xtd::linq::enumerable::append(base(), element);
170 }
171
179 }
180
184 auto average() const noexcept {
185 return xtd::linq::enumerable::average(base());
186 }
187
191 source_t first_or_default(const source_t default_value) const noexcept {
192 return xtd::linq::enumerable::first_or_default(base(), default_value);
193 }
194
197 source_t first_or_default() const noexcept {
199 }
200
205 template<typename result_t>
206 const xtd::collections::generic::ienumerable<result_t>& select(const std::function<result_t(const source_t&)>& selector) const {
207 return xtd::linq::enumerable::select<source_t, result_t>(base(), selector);
208 }
213 template<typename result_t, typename selector_t>
214 const xtd::collections::generic::ienumerable<result_t>& select(const selector_t& selector) const {
215 return xtd::linq::enumerable::select<source_t, result_t>(base(), selector);
216 }
221 const xtd::collections::generic::ienumerable<source_t>& select(const std::function<source_t(const source_t&)>& selector) const {
222 return xtd::linq::enumerable::select(base(), selector);
223 }
228 template<typename selector_t>
229 const xtd::collections::generic::ienumerable<source_t>& select(const selector_t& selector) const {
230 return xtd::linq::enumerable::select(base(), selector);
231 }
232
236
240 const xtd::collections::generic::ienumerable<source_t>& where(const std::function<bool(const source_t&)>& predicate) const {
242 }
246 template<typename predicate_t>
249 }
251
252 private:
253 const enumerable_t& base() const noexcept {return static_cast<const enumerable_t&>(*this);}
254 };
255 }
256 }
257 }
258}
259
260#include "../../../linq/enumerable_collection.hpp"
261#include "../ienumerable.hpp"
Provides a set of static methods for querying objects that implement ienumerable <type_t>.
Definition enumerable.hpp:31
result_t aggregate(const accumulate_t &seed, const std::function< accumulate_t(const source_t &, const accumulate_t &)> &func, const std::function< result_t(const accumulate_t &)> &result_selector) const
Applies an accumulator function over a sequence. The specified seed value is used as the initial accu...
Definition enumerable.hpp:86
const xtd::collections::generic::ienumerable< source_t > & select(const std::function< source_t(const source_t &)> &selector) const
Projects each element of a sequence into a new form.
Definition enumerable.hpp:221
source_t aggregate(const std::function< source_t(const source_t &, const source_t &)> &func) const
Applies an accumulator function over a sequence.
Definition enumerable.hpp:42
bool any() const noexcept
Determines whether a sequence contains any elements.
Definition enumerable.hpp:139
accumulate_t aggregate(const accumulate_t &seed, const std::function< accumulate_t(const source_t &, const accumulate_t &)> &func) const
Applies an accumulator function over a sequence. The specified seed value is used as the initial accu...
Definition enumerable.hpp:63
const xtd::collections::generic::ienumerable< result_t > & select(const std::function< result_t(const source_t &)> &selector) const
Projects each element of a sequence into a new form.
Definition enumerable.hpp:206
source_t first_or_default(const source_t default_value) const noexcept
Returns the first element of the sequence that satisfies a condition or a default value if no such el...
Definition enumerable.hpp:191
const xtd::collections::generic::ienumerable< source_t > & as_enumerable() const noexcept
Returns the input typed as xtd::collection::generic::ienumerable <type_t>.
Definition enumerable.hpp:177
const xtd::collections::generic::ienumerable< source_t > & where(const std::function< bool(const source_t &)> &predicate) const
Filters a sequence of values based on a predicate.
Definition enumerable.hpp:240
auto average() const noexcept
Computes the average of a sequence of source_t values.
Definition enumerable.hpp:184
const xtd::collections::generic::ienumerable< source_t > & where(const predicate_t &predicate) const
Filters a sequence of values based on a predicate.
Definition enumerable.hpp:247
accumulate_t aggregate(const accumulate_t &seed, const func_t &func) const
Applies an accumulator function over a sequence. The specified seed value is used as the initial accu...
Definition enumerable.hpp:74
bool any(const std::function< bool(const source_t &)> &predicate) const
Determines whether any element of a sequence satisfies a condition.
Definition enumerable.hpp:148
const xtd::collections::generic::list< source_t > & to_list() const noexcept
Creates a xtd::collections::generic::list <type_t> from an xtd::collections::generic::ienumerable <ty...
bool any(const predicate_t &predicate) const
Determines whether any elements of a sequence satisfy a condition.
Definition enumerable.hpp:158
bool all(const std::function< bool(const source_t &)> &predicate) const
Determines whether all elements of a sequence satisfy a condition.
Definition enumerable.hpp:120
const xtd::collections::generic::ienumerable< source_t > & select(const selector_t &selector) const
Projects each element of a sequence into a new form.
Definition enumerable.hpp:229
source_t first_or_default() const noexcept
Returns the first element of the sequence that satisfies a condition or a default value if no such el...
Definition enumerable.hpp:197
accumulate_t aggregate(const accumulate_t &seed, const func_t &func, const result_selector_t &result_selector) const
Applies an accumulator function over a sequence. The specified seed value is used as the initial accu...
Definition enumerable.hpp:110
const xtd::collections::generic::ienumerable< result_t > & select(const selector_t &selector) const
Projects each element of a sequence into a new form.
Definition enumerable.hpp:214
source_t aggregate(const func_t &func) const
Applies an accumulator function over a sequence.
Definition enumerable.hpp:52
const xtd::collections::generic::ienumerable< source_t > & append(const source_t &element) const noexcept
Appends a value to the end of the sequence.
Definition enumerable.hpp:168
bool all(const predicate_t &predicate) const
Determines whether all elements of a sequence satisfy a condition.
Definition enumerable.hpp:130
result_t aggregate(const accumulate_t &seed, const func_t &func, const result_selector_t &result_selector) const
Applies an accumulator function over a sequence. The specified seed value is used as the initial accu...
Definition enumerable.hpp:98
Exposes the enumerator, which supports a simple iteration over a collection of a specified type.
Definition ienumerable.hpp:36
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.hpp:71
Represents a delegate, which is a data structure that refers to a static method or to a class instanc...
Definition delegate.hpp:370
static const xtd::collections::generic::ienumerable< source_t > & as_enumerable(const xtd::collections::generic::ienumerable< source_t > &source) noexcept
Returns the input typed as xtd::collection::generic::ienumerable <type_t>.
Definition enumerable.hpp:778
static bool all(const xtd::collections::generic::ienumerable< source_t > &source, const std::function< bool(const source_t &)> &predicate)
Determines whether all elements of a sequence satisfy a condition.
Definition enumerable.hpp:466
static xtd::decimal average(const xtd::collections::generic::ienumerable< xtd::decimal > &source)
Computes the average of a sequence of xtd::decimal values.
static source_t aggregate(const xtd::collections::generic::ienumerable< source_t > &source, const std::function< source_t(const source_t &, const source_t &)> &func)
Applies an accumulator function over a sequence.
Definition enumerable.hpp:61
static source_t first_or_default(const xtd::collections::generic::ienumerable< source_t > &source, const source_t &default_value) noexcept
Returns the first element of the sequence that satisfies a condition or a default value if no such el...
Definition enumerable.hpp:879
static bool any(const xtd::collections::generic::ienumerable< source_t > &source) noexcept
Determines whether a sequence contains any elements.
Definition enumerable.hpp:568
static const xtd::collections::generic::ienumerable< source_t > & where(const xtd::collections::generic::ienumerable< source_t > &source, const std::function< bool(const source_t &)> &predicate)
Filters a sequence of values based on a predicate.
Definition enumerable.hpp:1148
static const xtd::collections::generic::ienumerable< source_t > & append(const xtd::collections::generic::ienumerable< source_t > &source, const source_t &element) noexcept
Appends a value to the end of the sequence.
Definition enumerable.hpp:713
static const xtd::collections::generic::ienumerable< result_t > & select(const xtd::collections::generic::ienumerable< source_t > &source, const std::function< result_t(const source_t &)> &selector)
Projects each element of a sequence into a new form.
Definition enumerable.hpp:952
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10