xtd 1.0.0
Loading...
Searching...
No Matches
enumerable.hpp
Go to the documentation of this file.
1
4#pragma once
7
9namespace xtd {
11 namespace collections {
13 namespace generic {
15 namespace extensions {
38 template<typename value_t, typename enumerable_t>
39 class enumerable {
40 public:
42
45 using enumerable_type = enumerable_t;
47 using value_type = value_t;
49 template<typename type_t>
51
53 template<typename type_t>
56
58
66 [[nodiscard]] auto aggregate(auto&& func) const -> value_t {
68 }
69
77 [[nodiscard]] auto aggregate(value_t&& seed, auto&& func) const -> value_t {
78 return xtd::linq::enumerable::aggregate(self(), std::forward<value_t>(seed), func);
79 }
80
90 [[nodiscard]] auto aggregate(value_t&& seed, auto&& func, auto&& result_selector) const {
91 return xtd::linq::enumerable::aggregate(self(), std::forward<value_t>(seed), func, result_selector);
92 }
93
100 template<xtd::predicate_callable<value_t> predicate_t>
101 [[nodiscard]] auto all(predicate_t&& predicate) const -> bool {
102 return xtd::linq::enumerable::all(self(), std::forward<predicate_t>(predicate));
103 }
104
110 [[nodiscard]] auto any() const noexcept -> bool {
111 return xtd::linq::enumerable::any(self());
112 }
113
119 template<xtd::predicate_callable<value_t> predicate_t>
120 [[nodiscard]] auto any(predicate_t&& predicate) const -> bool {
121 return xtd::linq::enumerable::any(self(), std::forward<predicate_t>(predicate));
122 }
123
130 template<typename element_t>
131 [[nodiscard]] auto append(element_t&& element) const noexcept -> xtd::collections::generic::enumerable_generator<value_t> {
132 return xtd::linq::enumerable::append(self(), std::forward<element_t>(element));
133 }
134
140 [[nodiscard]] auto as_enumerable() const noexcept {
142 }
143
147 [[nodiscard]] auto average() const noexcept {
148 return xtd::linq::enumerable::average(self());
149 }
150
155 template<typename result_t>
156 [[nodiscard]] auto cast() const noexcept -> xtd::collections::generic::enumerable_generator<result_t> {
158 }
159
166
170 template<xtd::iterable second_t>
171 [[nodiscard]] auto concat(second_t&& second) const noexcept -> xtd::collections::generic::enumerable_generator<value_t> {
172 return xtd::linq::enumerable::concat(self(), std::forward<second_t>(second));
173 }
174
178 [[nodiscard]] auto contains(value_t&& value) const noexcept -> bool {
179 return xtd::linq::enumerable::contains(self(), std::forward<value_t>(value));
180 }
181
185 [[nodiscard]] auto contains(value_t&& value, xtd::collections::generic::iequality_comparer<value_t>&& comparer) const noexcept -> bool {
186 return xtd::linq::enumerable::contains(self(), std::forward<value_t>(value), std::forward<xtd::collections::generic::iequality_comparer<value_t>>(comparer));
187 }
188
192 template<xtd::func_callable<bool, value_t, value_t> equater_t>
193 [[nodiscard]] auto contains(value_t&& value, equater_t&& equater) const noexcept -> bool {
194 return xtd::linq::enumerable::contains(self(), std::forward<value_t>(value), std::forward<equater_t>(equater));
195 }
196
202 [[nodiscard]] auto count() const noexcept -> xtd::usize {
203 return xtd::linq::enumerable::count(self());
204 }
205
211 template<xtd::predicate_callable<value_t> predicate_t>
212 [[nodiscard]] auto count(predicate_t&& predicate) const noexcept -> xtd::usize {
213 return xtd::linq::enumerable::count(self(), std::forward<predicate_t>(predicate));
214 }
215
218 [[nodiscard]] auto count(value_t&& value) const noexcept -> xtd::usize {
219 return xtd::linq::enumerable::count(self(), std::forward<value_t>(value));
220 }
221
229 template<typename key_t, xtd::callable<key_t, value_t> key_selector_t>
230 [[nodiscard]] auto count_by(key_selector_t&& key_selector) const noexcept {
231 return xtd::linq::enumerable::count_by<key_t>(self(), std::forward<key_selector_t>(key_selector));
232 }
233
241 template<typename key_t, xtd::callable<key_t, value_t> key_selector_t>
243 return xtd::linq::enumerable::count_by<key_t>(self(), std::forward<key_selector_t>(key_selector), std::forward<xtd::collections::generic::iequality_comparer<key_t>>(key_comparer));
244 }
245
253 template<typename key_t, xtd::callable<key_t, value_t> key_selector_t, xtd::func_callable<bool, key_t, key_t> key_equater_t>
254 [[nodiscard]] auto count_by(key_selector_t&& key_selector, key_equater_t&& key_equater) const noexcept -> xtd::collections::generic::enumerable_generator<xtd::collections::generic::key_value_pair<key_t, xtd::usize>> {
255 return xtd::linq::enumerable::count_by<key_t, value_t>(self(), std::forward<key_selector_t>(key_selector), std::forward<key_equater_t>(key_equater));
256 }
257
260 [[nodiscard]] auto default_if_empty() const noexcept -> xtd::collections::generic::enumerable_generator<value_t> {
262 }
263
266 [[nodiscard]] auto default_if_empty(const value_t& default_value) const noexcept -> xtd::collections::generic::enumerable_generator<value_t> {
267 return xtd::linq::enumerable::default_if_empty(self(), default_value);
268 }
269
272 [[nodiscard]] auto distinct() const noexcept -> xtd::collections::generic::enumerable_generator<value_t> {
273 return xtd::linq::enumerable::distinct(self());
274 }
275
281
284 template<xtd::func_callable<bool, value_t, value_t> equater_t>
285 [[nodiscard]] auto distinct(equater_t&& equater) const noexcept -> xtd::collections::generic::enumerable_generator<value_t> {
286 return xtd::linq::enumerable::distinct(self(), std::forward<equater_t>(equater));
287 }
288
293 [[nodiscard]] auto first() const -> value_t {
294 return xtd::linq::enumerable::first(self());
295 }
296
301 template<xtd::func_callable<bool, value_t> prediacte_t>
302 [[nodiscard]] auto first(prediacte_t&& prediacte) const -> value_t {
303 return xtd::linq::enumerable::first(self(), std::forward<prediacte_t>(prediacte));
304 }
305
310 template<xtd::predicate_callable<value_t> predicate_t>
311 [[nodiscard]] auto first_or_default(predicate_t&& predicate, value_t&& default_value) const noexcept -> value_t {
312 return xtd::linq::enumerable::first_or_default(self(), std::forward<predicate_t>(predicate), std::forward<value_t>(default_value));
313 }
314
317 template<xtd::predicate_callable<value_t> predicate_t>
318 [[nodiscard]] auto first_or_default(predicate_t&& predicate) const noexcept -> value_t {
319 return xtd::linq::enumerable::first_or_default(self(), std::forward<predicate_t>(predicate));
320 }
321
324 [[nodiscard]] auto first_or_default(value_t&& default_value) const noexcept -> value_t {
325 return xtd::linq::enumerable::first_or_default(self(), std::forward<value_t>(default_value));
326 }
327
329 [[nodiscard]] auto first_or_default() const noexcept -> value_t {
331 }
332
337 [[nodiscard]] auto last() const -> value_t {
338 return xtd::linq::enumerable::last(self());
339 }
340
345 template<xtd::func_callable<bool, value_t> prediacte_t>
346 [[nodiscard]] auto last(prediacte_t&& prediacte) const -> value_t {
347 return xtd::linq::enumerable::last(self(), std::forward<prediacte_t>(prediacte));
348 }
349
352 [[nodiscard]] auto max() const -> value_t requires xtd::numeric<value_t> {
353 return xtd::linq::enumerable::max(self());
354 }
355
358 template<xtd::callable<value_t, value_t> selector_t>
359 [[nodiscard]] auto max(selector_t&& selector) const -> value_t requires xtd::numeric<value_t> {
360 return xtd::linq::enumerable::max(self(), std::forward<selector_t>(selector));
361 }
362
365 template<typename result_t, xtd::callable<result_t, value_t> selector_t>
367 [[nodiscard]] auto max(selector_t&& selector) const -> result_t {
368 return xtd::linq::enumerable::max<result_t>(self(), std::forward<selector_t>(selector));
369 }
370
373 [[nodiscard]] auto min() const -> value_t requires xtd::numeric<value_t> {
374 return xtd::linq::enumerable::min(self());
375 }
376
379 template<xtd::callable<value_t, value_t> selector_t>
380 [[nodiscard]] auto min(selector_t&& selector) const -> value_t requires xtd::numeric<value_t> {
381 return xtd::linq::enumerable::min(self(), selector);
382 }
383
386 template<typename result_t, xtd::callable<result_t, value_t> selector_t>
388 [[nodiscard]] auto min(selector_t&& selector) const -> result_t {
389 return xtd::linq::enumerable::min<result_t, value_t>(self(), selector);
390 }
391
394 [[nodiscard]] auto order() const -> xtd::collections::generic::enumerable_generator<value_t> {
395 return xtd::linq::enumerable::order(self());
396 }
397
403
406 template<xtd::func_callable<bool, value_t, value_t> lesser_t>
407 [[nodiscard]] auto order(lesser_t&& lesser) const -> xtd::collections::generic::enumerable_generator<value_t> {
408 return xtd::linq::enumerable::order(self(), lesser);
409 }
410
416 [[nodiscard]] auto order_by(const std::function<value_t(const value_t&)>& key_selector) const {
417 return xtd::linq::enumerable::order_by(self(), key_selector);
418 }
419
425 template<typename key_t>
426 [[nodiscard]] auto order_by_descending(const std::function<key_t(const value_t&)>& key_selector) const {
428 }
429
435 [[nodiscard]] auto order_by_descending(const std::function<value_t(const value_t&)>& key_selector) const {
436 return xtd::linq::enumerable::order_by_descending(self(), key_selector);
437 }
438
444 template<typename key_t>
445 [[nodiscard]] auto order_by(const std::function<key_t(const value_t&)>& key_selector) const {
446 return xtd::linq::enumerable::order_by<key_t, value_t>(self(), key_selector);
447 }
448
452 [[nodiscard]] auto reverse() const -> xtd::collections::generic::enumerable_generator<value_t> {
453 return xtd::linq::enumerable::reverse(self());
454 }
455
462 [[nodiscard]] auto select(auto&& selector) const { // -> xtd::collections::generic::enumerable_generator<xtd::raw_type<decltype(selector(std::declval<const xtd::raw_type<value_t>&>()))>> {
463 return xtd::linq::enumerable::select(self(), selector);
464 }
465
470 template<xtd::iterable second_t>
471 [[nodiscard]] auto sequence_equal(second_t&& second) const -> bool {
472 return xtd::linq::enumerable::sequence_equal(self(), second);
473 }
474
478 template<xtd::iterable second_t>
479 [[nodiscard]] auto sequence_equal(second_t&& second, const xtd::collections::generic::iequality_comparer<value_t>& equality_comparer) const -> bool {
481 }
482
486 template<xtd::iterable second_t, xtd::func_callable<bool, value_t, xtd::iterable_value_type<second_t>> equality_comparer_t>
487 [[nodiscard]] auto sequence_equal(second_t&& second, equality_comparer_t&& equality_comparer) const -> bool {
489 }
490
494 [[nodiscard]] auto shuffle() const -> xtd::collections::generic::enumerable_generator<value_t> {
495 return xtd::linq::enumerable::shuffle(self());
496 }
497
504
514
522
529
539
545 [[nodiscard]] auto to_array() const -> xtd::array<value_t>;
546
552 [[nodiscard]] auto to_list() const -> xtd::collections::generic::list<value_t>;
553
563 [[nodiscard]] auto where(auto&& predicate) const {
565 }
566
573 template<xtd::iterable second_t>
575 return xtd::linq::enumerable::zip(self(), std::forward<second_t>(second));
576 }
577
584 template<xtd::iterable second_t>
585 [[nodiscard]] auto zip(second_t&& second, auto&& result_selector) const { // -> xtd::collections::generic::enumerable_generator<xtd::raw_type<decltype(result_selector(std::declval<const xtd::raw_type<value_t>&>(), std::declval<const xtd::iterable_value_type<second_t&>>()))>> {
586 return xtd::linq::enumerable::zip(self(), std::forward<second_t>(second), result_selector);
587 }
588
592 template<xtd::iterable second_t, xtd::iterable third_t>
594 return xtd::linq::enumerable::zip(self(), std::forward<second_t>(second), std::forward<third_t>(third));
595 }
596
601 template<xtd::iterable second_t, xtd::iterable third_t>
602 [[nodiscard]] auto zip(second_t&& second, third_t&& third, auto&& result_selector) const { // -> xtd::collections::generic::enumerable_generator<xtd::raw_type<decltype(result_selector(std::declval<const xtd::raw_type<value_t>&>(), std::declval<const xtd::iterable_value_type<second_t>&>(), std::declval<const xtd::iterable_value_type<third_t>&>()))>> {
603 return xtd::linq::enumerable::zip(self(), std::forward<second_t>(second), std::forward<third_t>(third), result_selector);
604 }
605
606
607 private:
608 auto self() const noexcept -> const enumerable_t& {return static_cast<const enumerable_t&>(*this);}
609 };
610 }
611 }
612 }
613}
614
615#define __XTD_CORE_INTERNAL__
617#undef __XTD_CORE_INTERNAL__
618#include "../ienumerable.hpp"
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
Provides a base class for implementations of the xtd::collections::generic::icomparer <type_t> generi...
Definition comparer.hpp:33
Represents an enumerable generator that supports deferred, lazy iteration over a collection of a spec...
Definition enumerable_generator.hpp:45
Provides a base class for implementations of the xtd::collections::generic::iequality_comparer <type_...
Definition equality_comparer.hpp:35
auto contains(value_t &&value) const noexcept -> bool
Determines whether a sequence contains a specified element by using the default equality comparer.
Definition enumerable.hpp:178
auto cast() const noexcept -> xtd::collections::generic::enumerable_generator< result_t >
Casts the elements of an xtd::collections::generic::ienumerable to the specified type.
Definition enumerable.hpp:156
auto to_list() const -> xtd::collections::generic::list< value_t >
Creates a xtd::collections::generic::list <type_t> from an xtd::collections::generic::ienumerable <ty...
auto max(selector_t &&selector) const -> result_t
Returns the maximum value in a sequence of xtd::numeric values.
Definition enumerable.hpp:367
value_t value_type
Represents the ienumerable value type.
Definition enumerable.hpp:47
auto count(predicate_t &&predicate) const noexcept -> xtd::usize
Returns a number that represents how many elements in the specified sequence satisfy a condition.
Definition enumerable.hpp:212
auto aggregate(auto &&func) const -> value_t
Applies an accumulator function over a sequence.
Definition enumerable.hpp:66
auto max(selector_t &&selector) const -> value_t
Returns the maximum value in a sequence of xtd::numeric values.
Definition enumerable.hpp:359
auto skip(xtd::usize count) const -> xtd::collections::generic::enumerable_generator< value_t >
Bypasses a specified number of elements in a sequence and then returns the remaining elements.
Definition enumerable.hpp:501
auto average() const noexcept
Computes the average of a sequence of value_t values.
Definition enumerable.hpp:147
auto last(prediacte_t &&prediacte) const -> value_t
Returns the last element in a sequence that satisfies a specified condition.
Definition enumerable.hpp:346
auto first_or_default(predicate_t &&predicate) const noexcept -> value_t
Returns the first element of the sequence that satisfies a condition or a default value if no such el...
Definition enumerable.hpp:318
auto order(const xtd::collections::generic::icomparer< value_t > &comparer) const -> xtd::collections::generic::enumerable_generator< value_t >
Sorts the elements of a sequence in ascending order.
Definition enumerable.hpp:400
auto last() const -> value_t
Returns the last element of a sequence.
Definition enumerable.hpp:337
auto take_while(auto &&predicate) const -> xtd::collections::generic::enumerable_generator< value_t >
Returns elements from a sequence as long as a specified condition is true, and then skips the remaini...
Definition enumerable.hpp:536
auto count_by(key_selector_t &&key_selector, key_equater_t &&key_equater) const noexcept -> xtd::collections::generic::enumerable_generator< xtd::collections::generic::key_value_pair< key_t, xtd::usize > >
Returns the count of elements in the current sequence grouped by key.
Definition enumerable.hpp:254
auto aggregate(value_t &&seed, auto &&func, auto &&result_selector) const
Applies an accumulator function over a sequence. The specified seed value is used as the initial accu...
Definition enumerable.hpp:90
auto skip_while(auto &&predicate) const -> xtd::collections::generic::enumerable_generator< value_t >
Bypasses elements in a sequence as long as a specified condition is true and then returns the remaini...
Definition enumerable.hpp:511
auto take(xtd::usize count) const -> xtd::collections::generic::enumerable_generator< value_t >
Returns a specified number of contiguous elements from the start of a sequence.
Definition enumerable.hpp:519
auto first_or_default() const noexcept -> value_t
Returns the first element of the sequence that satisfies a condition or a default value if no such el...
Definition enumerable.hpp:329
auto take(const xtd::range &range) const -> xtd::collections::generic::enumerable_generator< value_t >
Returns a specified number of contiguous elements from the start of a sequence.
Definition enumerable.hpp:526
auto first(prediacte_t &&prediacte) const -> value_t
Returns the first element in a sequence that satisfies a specified condition.
Definition enumerable.hpp:302
auto distinct() const noexcept -> xtd::collections::generic::enumerable_generator< value_t >
Returns distinct elements from a sequence by using the default equality comparer to compare values.
Definition enumerable.hpp:272
auto count_by(key_selector_t &&key_selector) const noexcept
Returns the count of elements in the current sequence grouped by key.
Definition enumerable.hpp:230
auto reverse() const -> xtd::collections::generic::enumerable_generator< value_t >
Inverts the order of the elements in a sequence.
Definition enumerable.hpp:452
auto sequence_equal(second_t &&second, const xtd::collections::generic::iequality_comparer< value_t > &equality_comparer) const -> bool
Determines whether two sequences are equal by comparing their elements by using a specifie the equali...
Definition enumerable.hpp:479
auto any(predicate_t &&predicate) const -> bool
Determines whether any element of a sequence satisfies a condition.
Definition enumerable.hpp:120
enumerable_t enumerable_type
Represents the ienumerable enumerable type.
Definition enumerable.hpp:45
auto to_array() const -> xtd::array< value_t >
Creates a xtd::array <type_t> from an xtd::collections::generic::ienumerable <type_t>.
auto zip(second_t &&second, third_t &&third, auto &&result_selector) const
Applies a specified function to the corresponding elements of three sequences, producing a sequence o...
Definition enumerable.hpp:602
auto order_by_descending(const std::function< key_t(const value_t &)> &key_selector) const
Sorts the elements of a sequence in descending order according to a key.
Definition enumerable.hpp:426
auto zip(second_t &&second, auto &&result_selector) const
Applies a specified function to the corresponding elements of two sequences, producing a sequence of ...
Definition enumerable.hpp:585
auto append(element_t &&element) const noexcept -> xtd::collections::generic::enumerable_generator< value_t >
Appends a value to the end of the sequence.
Definition enumerable.hpp:131
auto min() const -> value_t
Returns the minimum value in a sequence of xtd::numeric values.
Definition enumerable.hpp:373
auto select(auto &&selector) const
Projects each element of a sequence into a new form.
Definition enumerable.hpp:462
auto order(lesser_t &&lesser) const -> xtd::collections::generic::enumerable_generator< value_t >
Sorts the elements of a sequence in ascending order.
Definition enumerable.hpp:407
auto any() const noexcept -> bool
Determines whether a sequence contains any elements.
Definition enumerable.hpp:110
auto order_by(const std::function< key_t(const value_t &)> &key_selector) const
Sorts the elements of a sequence in ascending order according to a key.
Definition enumerable.hpp:445
auto min(selector_t &&selector) const -> result_t
Returns the minimum value in a sequence of xtd::numeric values.
Definition enumerable.hpp:388
auto default_if_empty(const value_t &default_value) const noexcept -> xtd::collections::generic::enumerable_generator< value_t >
Returns the elements of the specified sequence or the specified value in a singleton collection if th...
Definition enumerable.hpp:266
auto first() const -> value_t
Returns the first element of a sequence.
Definition enumerable.hpp:293
auto aggregate(value_t &&seed, auto &&func) const -> value_t
Applies an accumulator function over a sequence. The specified seed value is used as the initial accu...
Definition enumerable.hpp:77
auto max() const -> value_t
Returns the maximum value in a sequence of xtd::numeric values.
Definition enumerable.hpp:352
typename xtd::linq::enumerable::list< type_t > list
Represents the list value type.
Definition enumerable.hpp:54
auto zip(second_t &&second, third_t &&third) const -> xtd::collections::generic::enumerable_generator< std::tuple< value_t, xtd::iterable_value_type< second_t >, xtd::iterable_value_type< third_t > > >
Produces a sequence of tuples with elements from the three specified sequences.
Definition enumerable.hpp:593
auto default_if_empty() const noexcept -> xtd::collections::generic::enumerable_generator< value_t >
Returns the elements of the specified sequence or the type parameter's default value in a singleton c...
Definition enumerable.hpp:260
auto order() const -> xtd::collections::generic::enumerable_generator< value_t >
Sorts the elements of a sequence in ascending order.
Definition enumerable.hpp:394
auto contains(value_t &&value, equater_t &&equater) const noexcept -> bool
Determines whether a sequence contains a specified element by using a specified equality comparer.
Definition enumerable.hpp:193
auto sequence_equal(second_t &&second) const -> bool
Determines whether two sequences are equal by comparing the elements by using the default equality co...
Definition enumerable.hpp:471
auto order_by_descending(const std::function< value_t(const value_t &)> &key_selector) const
Sorts the elements of a sequence in descending order according to a key.
Definition enumerable.hpp:435
auto distinct(equater_t &&equater) const noexcept -> xtd::collections::generic::enumerable_generator< value_t >
Returns distinct elements from a sequence by using a specified xtd::collections::generic::iequality_c...
Definition enumerable.hpp:285
auto all(predicate_t &&predicate) const -> bool
Determines whether all elements of a sequence satisfy a condition.
Definition enumerable.hpp:101
auto first_or_default(predicate_t &&predicate, value_t &&default_value) const noexcept -> value_t
Returns the first element of the sequence that satisfies a condition, or a specified default value if...
Definition enumerable.hpp:311
auto min(selector_t &&selector) const -> value_t
Returns the minimum value in a sequence of xtd::numeric values.
Definition enumerable.hpp:380
auto count() const noexcept -> xtd::usize
Returns the number of elements in current sequence.
Definition enumerable.hpp:202
auto chunk(xtd::usize size) const -> xtd::collections::generic::enumerable_generator< xtd::array< value_t > >
Splits the elements of a sequence into chunks of size at most size.
Definition enumerable.hpp:163
auto shuffle() const -> xtd::collections::generic::enumerable_generator< value_t >
Shuffles the order of the elements of a sequence.
Definition enumerable.hpp:494
auto contains(value_t &&value, xtd::collections::generic::iequality_comparer< value_t > &&comparer) const noexcept -> bool
Determines whether a sequence contains a specified element by using a specified equality comparer.
Definition enumerable.hpp:185
auto as_enumerable() const noexcept
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
Definition enumerable.hpp:140
auto order_by(const std::function< value_t(const value_t &)> &key_selector) const
Sorts the elements of a sequence in ascending order according to a key.
Definition enumerable.hpp:416
auto count_by(key_selector_t &&key_selector, xtd::collections::generic::iequality_comparer< key_t > &&key_comparer) const noexcept -> xtd::collections::generic::enumerable_generator< xtd::collections::generic::key_value_pair< key_t, xtd::usize > >
Returns the count of elements in the current sequence grouped by key.
Definition enumerable.hpp:242
auto sequence_equal(second_t &&second, equality_comparer_t &&equality_comparer) const -> bool
Determines whether two sequences are equal by comparing their elements by using a specifie the equali...
Definition enumerable.hpp:487
auto concat(second_t &&second) const noexcept -> xtd::collections::generic::enumerable_generator< value_t >
Concatenates two sequences.
Definition enumerable.hpp:171
auto distinct(xtd::collections::generic::iequality_comparer< value_t > &&comparer) const noexcept -> xtd::collections::generic::enumerable_generator< value_t >
Returns distinct elements from a sequence by using a specified xtd::collections::generic::iequality_c...
Definition enumerable.hpp:278
typename xtd::linq::enumerable::ienumerable< type_t > ienumerable
Represents the ienumerable value type.
Definition enumerable.hpp:50
auto first_or_default(value_t &&default_value) const noexcept -> value_t
Returns the first element of the sequence that satisfies a condition or a default value if no such el...
Definition enumerable.hpp:324
auto where(auto &&predicate) const
Filters a sequence of values based on a predicate.
Definition enumerable.hpp:563
auto count(value_t &&value) const noexcept -> xtd::usize
Returns the number of elements with the specified value.
Definition enumerable.hpp:218
auto zip(second_t &&second) const -> xtd::collections::generic::enumerable_generator< std::tuple< value_t, xtd::iterable_value_type< second_t > > >
Produces a sequence of tuples with elements from the two specified sequences.
Definition enumerable.hpp:574
Exposes a method that compares two objects.
Definition icomparer.hpp:30
Defines methods to support the comparison of objects for equality.
Definition iequality_comparer.hpp:34
static auto chunk(source_t &&source, xtd::usize size) -> xtd::collections::generic::enumerable_generator< xtd::array< xtd::iterable_value_type< source_t > > >
Splits the elements of a sequence into chunks of size at most size.
static auto last(source_t &&source) -> xtd::iterable_value_type< source_t >
Returns the last element of a sequence.
static auto sequence_equal(first_t &&first, second_t &&second) -> bool
Determines whether two sequences are equal by comparing the elements by using the default equality co...
static auto zip(first_t &&first, second_t &&second) -> xtd::collections::generic::enumerable_generator< std::tuple< xtd::iterable_value_type< first_t >, xtd::iterable_value_type< second_t > > >
Produces a sequence of tuples with elements from the two specified sequences.
static auto skip_while(source_t &&source, auto &&predicate) -> xtd::collections::generic::enumerable_generator< xtd::iterable_value_type< source_t > >
Bypasses elements in a sequence as long as a specified condition is true and then returns the remaini...
static auto order_by_descending(source_t &&source, key_selector_t &&key_selector) -> xtd::collections::generic::enumerable_generator< xtd::iterable_value_type< source_t > >
Sorts the elements of a sequence in descending order according to a key.
typename xtd::collections::generic::ienumerable< type_t > ienumerable
Represents the ienumerable value type.
Definition enumerable_.hpp:92
static auto distinct(source_t &&source) noexcept -> xtd::collections::generic::enumerable_generator< xtd::iterable_value_type< source_t > >
Returns distinct elements from a sequence by using the default equality comparer to compare values.
static auto concat(first_t &&first, second_t &&second) noexcept -> xtd::collections::generic::enumerable_generator< xtd::iterable_value_type< first_t > >
Concatenates two sequences.
static auto first_or_default(source_t &&source, prediacte_t &&predicate, xtd::iterable_value_type< source_t > &&default_value) noexcept -> xtd::iterable_value_type< source_t >
Returns the first element of the sequence that satisfies a condition, or a specified default value if...
static auto min(source_t &&source) -> xtd::iterable_value_type< source_t >
Returns the minimum value in a sequence of xtd::numeric values.
typename xtd::collections::generic::list< type_t > list
Represents the list value type.
Definition enumerable_.hpp:96
static auto default_if_empty(source_t &&source) noexcept -> xtd::collections::generic::enumerable_generator< xtd::iterable_value_type< source_t > >
Returns the elements of the specified sequence or the type parameter's default value in a singleton c...
static auto contains(source_t &&source, const xtd::iterable_value_type< source_t > &value) noexcept -> bool
Determines whether a sequence contains a specified element by using the default equality comparer.
static auto take(source_t &&source, xtd::usize count) -> xtd::collections::generic::enumerable_generator< xtd::iterable_value_type< source_t > >
Returns a specified number of contiguous elements from the start of a sequence.
static auto count_by(source_t &&source, key_selector_t &&key_selector) noexcept -> xtd::collections::generic::enumerable_generator< xtd::collections::generic::key_value_pair< key_t, xtd::usize > >
Returns the count of elements in the source sequence grouped by key.
static auto all(source_t &&source, predicate_t &&predicate) -> bool
Determines whether all elements of a sequence satisfy a condition.
static auto shuffle(source_t &&source) -> xtd::collections::generic::enumerable_generator< xtd::iterable_value_type< source_t > >
Shuffles the order of the elements of a sequence.
Definition random.hpp:277
static auto order(source_t &&source) -> xtd::collections::generic::enumerable_generator< xtd::iterable_value_type< source_t > >
Sorts the elements of a sequence in ascending order.
static auto cast(source_t &&source) -> xtd::collections::generic::enumerable_generator< result_t >
Casts the elements of an xtd::collections::generic::ienumerable to the specified type.
static auto where(source_t &&source, auto &&predicate) -> xtd::collections::generic::enumerable_generator< xtd::iterable_value_type< source_t > >
Filters a sequence of values based on a predicate.
static auto aggregate(source_t &&source, func_t &&func) -> xtd::iterable_value_type< source_t >
Applies an accumulator function over a sequence.
static auto as_enumerable(source_t &&source) noexcept
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
static auto average(source_t &&source) -> xtd::decimal
Computes the average of a sequence of xtd::decimal values.
static auto select(source_t &&source, auto &&selector) -> xtd::collections::generic::enumerable_generator< xtd::raw_type< decltype(selector(std::declval< const xtd::iterable_value_type< source_t > & >()))> >
Projects each element of a sequence into a new form.
static auto append(source_t &&source, xtd::iterable_value_type< source_t > &&element) noexcept -> xtd::collections::generic::enumerable_generator< xtd::iterable_value_type< source_t > >
Appends a value to the end of the sequence.
static auto first(source_t &&source) -> xtd::iterable_value_type< source_t >
Returns the first element of a sequence.
static auto order_by(source_t &&source, key_selector_t &&key_selector) -> xtd::collections::generic::enumerable_generator< xtd::iterable_value_type< source_t > >
Sorts the elements of a sequence in ascending order according to a key.
static auto count(source_t &&source) noexcept -> xtd::usize
Returns the number of elements in a sequence.
static auto reverse(source_t &&source) -> xtd::collections::generic::enumerable_generator< xtd::iterable_value_type< source_t > >
Inverts the order of the elements in a sequence.
static auto skip(source_t &&source, xtd::usize count) -> xtd::collections::generic::enumerable_generator< xtd::iterable_value_type< source_t > >
Bypasses a specified number of elements in a sequence and then returns the remaining elements.
static auto max(source_t &&source) -> xtd::iterable_value_type< source_t >
Returns the maximum value in a sequence of xtd::numeric values.
static auto take_while(source_t &&source, auto &&predicate) -> xtd::collections::generic::enumerable_generator< xtd::iterable_value_type< source_t > >
Returns elements from a sequence as long as a specified condition is true, and then skips the remaini...
static auto any(source_t &&source) noexcept -> bool
Determines whether a sequence contains any elements.
Represents a range that has start and end indexes.
Definition range.hpp:38
Definition enumerable.hpp:17
Definition numeric.hpp:12
Contains foreach_ keyword.
Contains xtd::collections::generic::ienumerable <type_t> interface.
xtd::raw_type< decltype(*std::begin(std::declval< iterable_t & >()))> iterable_value_type
Represents the orward iterable value type.
Definition iterable_value_type.hpp:29
xtd::delegate< result_t(arguments_t... arguments)> func
Represents a delegate that has variables parameters and returns a value of the type specified by the ...
Definition func.hpp:27
std::size_t usize
Represents an unsigned size of any object in bytes.
Definition usize.hpp:22
xtd::func< bool, type_t > predicate
Represents a delegate that defines a set of criteria and determines whether the specified object meet...
Definition predicate.hpp:16
Contains xtd::linq::enumerable <type_t> class.
The xtd::extensions namespace contains interface extensions.
Definition collection_common.hpp:14
The xtd::collections::generic namespace contains interfaces and classes that define generic collectio...
Definition comparer.hpp:16
The xtd::collections namespace contains interfaces and classes that define various collections of obj...
Definition any_pair.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
constexpr auto size() const noexcept -> size_type
Returns the number of elements.
Definition read_only_span.hpp:213