xtd 0.2.0
enumerable.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "../collections/generic/helpers/allocator.hpp"
6//#include "../collections/generic/iequality_comparer.hpp"
7#include "../collections/generic/equality_comparer.hpp"
8#define __XTD_CORE_INTERNAL__
9#include "../internal/__array_definition.hpp"
10#include "../internal/__key_value_pair_definition.hpp"
11#include "../internal/__list_definition.hpp"
12#undef __XTD_CORE_INTERNAL__
13#include "../decimal.hpp"
14#include "../iequatable.hpp"
15#include "../int32.hpp"
16#include "../int64.hpp"
17#include "../optional.hpp"
18#include "../size.hpp"
19#include "../static.hpp"
20#include <algorithm>
21#include <functional>
22
24template<class type_t>
25struct __opaque_xtd_linq_enumerable_collection__;
27
29namespace xtd {
31 namespace collections::generic {
32 template<class type_t>
33 class ienumerable;
34 }
36
38 namespace linq {
39
56 public:
58
61 template<class type_t>
63
65 template<class type_t>
67
69 template<class type_t>
71
73 template<class key_t, class value_t>
76
78
88 template<class source_t>
89 static source_t aggregate(const ienumerable<source_t>& source, const std::function<source_t(const source_t&, const source_t&)>& func) {
90 auto nb = 0;
91 auto aggregated = source_t {};
92 for (const auto& item : source)
93 if (nb++ == 0) aggregated = item;
94 else aggregated = func(aggregated, item);
95 return aggregated;
96 }
106 template<class source_t>
107 static source_t aggregate(const ienumerable<source_t>& source, const source_t& seed, const std::function<source_t(const source_t&, const source_t&)>& func) {
108 auto aggregated = seed;
109 for (const auto& item : source)
110 aggregated = func(aggregated, item);
111 return aggregated;
112 }
123 template<class accumulate_t, class source_t>
124 static accumulate_t aggregate(const ienumerable<source_t>& source, const accumulate_t& seed, const std::function<accumulate_t(const source_t&, const accumulate_t&)>& func) {
125 auto aggregated = seed;
126 for (const auto& item : source)
127 aggregated = func(aggregated, item);
128 return aggregated;
129 }
140 template<class source_t>
141 static source_t aggregate(const ienumerable<source_t>& source, const source_t& seed, const std::function<source_t(const source_t&, const source_t&)>& func, const std::function<source_t(const source_t&)>& result_selector) {
142 auto aggregated = seed;
143 for (const auto& item : source)
144 aggregated = func(aggregated, item);
145 return result_selector(aggregated);
146 }
159 template<class result_t, class accumulate_t, class source_t>
160 static result_t aggregate(const ienumerable<source_t>& source, 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) {
161 auto aggregated = seed;
162 for (const auto& item : source)
163 aggregated = func(aggregated, item);
164 return result_selector(aggregated);
165 }
166
175 template<class source_t>
176 static bool all(const ienumerable<source_t>& source, const std::function<bool(const source_t&)>& predicate) {
177 for (const auto& item : source)
178 if (!predicate(item)) return false;
179 return true;
180 }
181
190 template<class source_t>
191 static bool any(const ienumerable<source_t>& source) noexcept {
192 return source.begin() != source.end();
193 }
202 template<class source_t>
203 static bool any(const ienumerable<source_t>& source, const std::function<bool(const source_t&)>& predicate) {
204 for (const auto& item : source)
205 if (predicate(item)) return true;
206 return false;
207 }
208
217 template<class source_t>
218 static const ienumerable<source_t>& append(const ienumerable<source_t>& source, const source_t& element) noexcept {
219 static thread_local auto result = __opaque_xtd_linq_enumerable_collection__<source_t> {};
220 result = __opaque_xtd_linq_enumerable_collection__<source_t> {};
221 for (const auto& item : source)
222 result.items.push_back(item);
223 result.items.push_back(element);
224 return result;
225 }
226
234 template<class source_t>
235 static const ienumerable<source_t>& as_enumerable(const ienumerable<source_t>& source) noexcept {
236 return source;
237 }
245 template<class source_t>
246 static const ienumerable<source_t>& as_enumerable(std::initializer_list<source_t> source) noexcept {
247 static thread_local auto result = __opaque_xtd_linq_enumerable_collection__<source_t> {};
248 result = __opaque_xtd_linq_enumerable_collection__<source_t> {};
249 for (const auto& item : source)
250 result.items.push_back(item);
251 return result;
252 }
260 template<class collection_t>
261 static const auto& as_enumerable(const collection_t& source) noexcept {
262 using source_t = typename collection_t::value_type;
263 static thread_local auto result = __opaque_xtd_linq_enumerable_collection__<source_t> {};
264 result = __opaque_xtd_linq_enumerable_collection__<source_t> {};
265 for (const auto& item : source)
266 result.items.push_back(item);
267 return static_cast<const ienumerable<source_t>&>(result);
268 }
277 template<class input_iterator_t>
278 static const auto& as_enumerable(input_iterator_t first, input_iterator_t last) noexcept {
279 using source_t = typename std::decay<decltype(*first)>::type;
280 static thread_local auto result = __opaque_xtd_linq_enumerable_collection__<source_t> {};
281 result = __opaque_xtd_linq_enumerable_collection__<source_t> {};
282 for (auto iterator = first; iterator != last; ++iterator)
283 result.items.push_back(*iterator);
284 return static_cast<const ienumerable<source_t>&>(result);
285 }
294 template<class input_iterator_t>
295 static const auto& as_enumerable(input_iterator_t iterator, size_t length) noexcept {
296 return as_enumerable(iterator, iterator + length);
297 }
306 template<class source_t, size_t length>
307 static const auto& as_enumerable(const source_t (&array)[length]) noexcept {
308 return as_enumerable(array, array + length);
309 }
310
320 static double average(const ienumerable<double>& source);
325 static float average(const ienumerable<float>& source);
330 static double average(const ienumerable<xtd::int32>& source);
335 static double average(const ienumerable<xtd::int64>& source);
336
357
365 template<class result_t, class source_t>
366 static const ienumerable<result_t>& cast(const ienumerable<source_t>& source) noexcept;
367
374 template<class source_t>
376
382 template<class source_t>
383 static const ienumerable<source_t>& concat(const ienumerable<source_t>& first, const ienumerable<source_t>& second) noexcept {
384 static thread_local auto result = __opaque_xtd_linq_enumerable_collection__<source_t> {};
385 result = __opaque_xtd_linq_enumerable_collection__<source_t> {};
386 for (const auto& item : first)
387 result.items.push_back(item);
388 for (const auto& item : second)
389 result.items.push_back(item);
390 return static_cast<const ienumerable<source_t>&>(result);
391 }
392
398 template<class source_t>
399 static bool contains(const ienumerable<source_t>& source, const source_t& value) noexcept {
400 for (const auto& item : source)
401 if (item == value) return true;
402 return false;
403 }
404
411 template<class source_t>
412 static bool contains(const ienumerable<source_t>& source, const source_t& value, const xtd::collections::generic::iequality_comparer<source_t>& comparer) noexcept {
413 for (const auto& item : source)
414 if (comparer.equals(item, value)) return true;
415 return false;
416 }
417
425 template<class source_t>
426 static xtd::size count(const ienumerable<source_t>& source) noexcept {
427 auto count = xtd::size {0};
428 auto enumerator = source.get_enumerator();
429 while (enumerator.move_next()) ++count;
430 return count;
431 }
432
441 template<class source_t>
442 static xtd::size count(const ienumerable<source_t>& source, const std::function<bool(const source_t&)>& predicate) noexcept {
443 auto count = xtd::size {0};
444 auto enumerator = source.get_enumerator();
445 while (enumerator.move_next())
446 if (predicate(enumerator.current())) ++count;
447 return count;
448 }
449
459 template<class key_t, class source_t>
460 static const ienumerable<key_value_pair<key_t, xtd::size>>& count_by(const ienumerable<source_t>& source, const std::function<key_t(const source_t&)>& key_selector) noexcept {
462 }
463
474 template<class key_t, class source_t>
475 static const ienumerable<key_value_pair<key_t, xtd::size>>& count_by(const ienumerable<source_t>& source, const std::function<key_t(const source_t&)>& key_selector, const iequality_comparer<key_t>& key_comparer) noexcept {
476 static thread_local auto result = __opaque_xtd_linq_enumerable_collection__<key_value_pair<key_t, xtd::size>> {};
477 result = __opaque_xtd_linq_enumerable_collection__<key_value_pair<key_t, xtd::size>> {};
478 auto keys = list<key_t> {};
479 auto enumerator = source.get_enumerator();
480 while (enumerator.move_next()) {
481 auto key = key_selector(enumerator.current());
482 auto index = size_t {0};
483 for (; index < keys.size(); ++index)
484 if (key_comparer.equals(keys[index], key)) break;
485 if (index < keys.size()) result.items[index] = {key, result.items[index].value() + 1};
486 else {
487 keys.push_back(key);
488 result.items.push_back({key, 1});
489 }
490 }
491 return static_cast<const ienumerable<key_value_pair<key_t, xtd::size>>&>(result);
492 }
493
501 template<class source_t>
502 static const ienumerable<source_t>& default_if_empty(const ienumerable<source_t>& source) noexcept {
503 return default_if_empty(source, source_t {});
504 }
505
514 template<class source_t>
515 static const ienumerable<source_t>& default_if_empty(const ienumerable<source_t>& source, const source_t& default_value) noexcept {
516 static thread_local auto result = __opaque_xtd_linq_enumerable_collection__<source_t> {};
517 result = __opaque_xtd_linq_enumerable_collection__<source_t> {};
518 if (!any(source)) result.items.push_back(default_value);
519 else for (const auto& item : source)
520 result.items.push_back(item);
521 return result;
522 }
523
530 template<class source_t>
531 static source_t first_or_default(const ienumerable<source_t>& source, const std::function<bool(const source_t&)>& predicate, const source_t& default_value) noexcept {
532 const auto& result = where(source, predicate);
533 return any(result) ? *result.begin() : default_value;
534 }
540 template<class source_t>
541 static source_t first_or_default(const ienumerable<source_t>& source, const std::function<bool(const source_t&)>& predicate) noexcept {
542 return first_or_default(source, predicate, source_t {});
543 }
549 template<class source_t>
550 static source_t first_or_default(const ienumerable<source_t>& source, const source_t& default_value) noexcept {
551 return any(source) ? *source.begin() : default_value;
552 }
557 template<class source_t>
558 static source_t first_or_default(const ienumerable<source_t>& source) noexcept {
559 return first_or_default(source, source_t {});
560 }
561
571
580 template<class source_t>
581 static const ienumerable<source_t>& from(const ienumerable<source_t>& source) noexcept {
582 return as_enumerable(source);
583 }
592 template<class source_t>
593 static const ienumerable<source_t>& from(std::initializer_list<source_t> source) noexcept {
594 return as_enumerable(source);
595 }
604 template<class collection_t>
605 static const auto& from(const collection_t& source) noexcept {
606 return as_enumerable(source);
607 }
619 template<class input_iterator_t>
620 static const auto& from(input_iterator_t first, input_iterator_t last) noexcept {
621 return as_enumerable(first, last);
622 }
632 template<class input_iterator_t>
633 static const auto& from(input_iterator_t iterator, size_t length) noexcept {
634 return as_enumerable(iterator, iterator + length);
635 }
645 template<class source_t, size_t length>
646 static const auto& from(const source_t (&array)[length]) noexcept {
647 return as_enumerable(array, array + length);
648 }
649
659 template<class result_t, class source_t>
660 static const ienumerable<result_t>& select(const ienumerable<source_t>& source, const std::function<result_t(const source_t&)>& selector) {
661 static thread_local auto result = __opaque_xtd_linq_enumerable_collection__<result_t> {};
662 result = __opaque_xtd_linq_enumerable_collection__<result_t> {};
663 for (const auto& item : source)
664 result.items.push_back(selector(item));
665 return result;
666 }
675 template<class source_t>
676 static const ienumerable<source_t>& select(const ienumerable<source_t>& source, const std::function<source_t(const source_t&)>& selector) {
677 static thread_local auto result = __opaque_xtd_linq_enumerable_collection__<source_t> {};
678 result = __opaque_xtd_linq_enumerable_collection__<source_t> {};
679 for (const auto& item : source)
680 result.items.push_back(selector(item));
681 return result;
682 }
692 template<class result_t, class source_t>
693 static const ienumerable<result_t>& select(const ienumerable<source_t>& source, const std::function<result_t(const source_t&, xtd::size)>& selector) {
694 static thread_local auto result = __opaque_xtd_linq_enumerable_collection__<result_t> {};
695 result = __opaque_xtd_linq_enumerable_collection__<result_t> {};
696 auto index = xtd::size {0};
697 for (const auto& item : source)
698 result.items.push_back(selector(item, index++));
699 return result;
700 }
709 template<class source_t>
710 static const ienumerable<source_t>& select(const ienumerable<source_t>& source, const std::function<source_t(const source_t&, xtd::size)>& selector) {
711 static thread_local auto result = __opaque_xtd_linq_enumerable_collection__<source_t> {};
712 result = __opaque_xtd_linq_enumerable_collection__<source_t> {};
713 auto index = xtd::size {0};
714 for (const auto& item : source)
715 result.items.push_back(selector(item, index++));
716 return result;
717 }
718
727 template<class source_t>
728 static const list<source_t>& to_list(const ienumerable<source_t>& source) noexcept;
729
738 template<class source_t>
739 static const ienumerable<source_t>& where(const ienumerable<source_t>& source, const std::function<bool(const source_t&)>& predicate) {
740 static thread_local auto result = __opaque_xtd_linq_enumerable_collection__<source_t> {};
741 result = __opaque_xtd_linq_enumerable_collection__<source_t> {};
742 for (const auto& item : source)
743 if (predicate(item)) result.items.push_back(item);
744 return result;
745 }
754 template<class source_t>
755 static const ienumerable<source_t>& where(const ienumerable<source_t>& source, const std::function<bool(const source_t&, xtd::size)>& predicate) {
756 static thread_local auto result = __opaque_xtd_linq_enumerable_collection__<source_t> {};
757 result = __opaque_xtd_linq_enumerable_collection__<source_t> {};
758 auto index = xtd::size {0};
759 for (const auto& item : source)
760 if (predicate(item, index++)) result.items.push_back(item);
761 return result;
762 }
764
765 private:
766 template<class source_t, class collection_t>
767 static const list<source_t>& collection_to_list(const collection_t& source) noexcept;
768 template<class source_t, class input_iterator_t>
769 static const list<source_t>& input_iterator_to_list(input_iterator_t first, input_iterator_t last) noexcept;
770 };
771 }
772}
773
774#include "../collections/generic/extensions/enumerable.hpp"
775#include "from.hpp"
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:59
Provides a base class for implementations of the xtd::collections::generic::iequality_comparer <type_...
Definition equality_comparer.hpp:35
Exposes the enumerator, which supports a simple iteration over a collection of a specified type.
Definition ienumerable.hpp:36
Defines methods to support the comparison of objects for equality.
Definition iequality_comparer.hpp:34
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.hpp:80
Provides a set of static methods for querying objects that implement ienumerable <type_t>.
Definition enumerable.hpp:55
static const auto & from(const source_t(&array)[length]) noexcept
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
Definition enumerable.hpp:646
static const auto & as_enumerable(input_iterator_t first, input_iterator_t last) noexcept
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
Definition enumerable.hpp:278
static xtd::decimal average(const ienumerable< xtd::decimal > &source)
Computes the average of a sequence of xtd::decimal values.
static const ienumerable< xtd::array< source_t > > & chunk(const ienumerable< source_t > &source, xtd::size size)
Splits the elements of a sequence into chunks of size at most size.
static const ienumerable< source_t > & from(std::initializer_list< source_t > source) noexcept
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
Definition enumerable.hpp:593
static const auto & from(input_iterator_t first, input_iterator_t last) noexcept
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
Definition enumerable.hpp:620
static const ienumerable< result_t > & select(const 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:660
static const auto & as_enumerable(input_iterator_t iterator, size_t length) noexcept
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
Definition enumerable.hpp:295
static xtd::optional< float > average(const ienumerable< xtd::optional< float > > &source) noexcept
Computes the average of a sequence of optional float values.
static const ienumerable< result_t > & cast(const ienumerable< source_t > &source) noexcept
Casts the elements of an xtd::collections::generic::ienumerable to the specified type.
static bool all(const 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:176
typename xtd::collections::generic::ienumerable< type_t > ienumerable
Represents the ienumerable value type.
Definition enumerable.hpp:66
static xtd::optional< xtd::decimal > average(const ienumerable< xtd::optional< xtd::decimal > > &source) noexcept
Computes the average of a sequence of optional xtd::decimal values.
static const ienumerable< result_t > & select(const ienumerable< source_t > &source, const std::function< result_t(const source_t &, xtd::size)> &selector)
Projects each element of a sequence into a new form by incorporating the element's index.
Definition enumerable.hpp:693
static const ienumerable< source_t > & where(const ienumerable< source_t > &source, const std::function< bool(const source_t &)> &predicate)
Filters a sequence of values based on a predicate.
Definition enumerable.hpp:739
static double average(const ienumerable< xtd::int32 > &source)
Computes the average of a sequence of xtd::int32 values.
static bool any(const ienumerable< source_t > &source) noexcept
Determines whether a sequence contains any elements.
Definition enumerable.hpp:191
static bool any(const ienumerable< source_t > &source, const std::function< bool(const source_t &)> &predicate)
Determines whether any element of a sequence satisfies a condition.
Definition enumerable.hpp:203
static source_t aggregate(const ienumerable< source_t > &source, const source_t &seed, const std::function< source_t(const source_t &, const source_t &)> &func, const std::function< source_t(const source_t &)> &result_selector)
Applies an accumulator function over a sequence. The specified seed value is used as the initial accu...
Definition enumerable.hpp:141
static bool contains(const ienumerable< source_t > &source, const source_t &value, const xtd::collections::generic::iequality_comparer< source_t > &comparer) noexcept
Determines whether a sequence contains a specified element by using a specified equality comparer.
Definition enumerable.hpp:412
typename xtd::collections::generic::iequality_comparer< type_t > iequality_comparer
Represents the ienumerable value type.
Definition enumerable.hpp:62
typename xtd::collections::generic::list< type_t > list
Represents the list value type.
Definition enumerable.hpp:70
static xtd::optional< double > average(const ienumerable< xtd::optional< xtd::int32 > > &source) noexcept
Computes the average of a sequence of optional xtd::int32 values.
static const auto & from(input_iterator_t iterator, size_t length) noexcept
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
Definition enumerable.hpp:633
static const ienumerable< key_value_pair< key_t, xtd::size > > & count_by(const ienumerable< source_t > &source, const std::function< key_t(const source_t &)> &key_selector) noexcept
Returns the count of elements in the source sequence grouped by key.
Definition enumerable.hpp:460
static const ienumerable< source_t > & select(const ienumerable< source_t > &source, const std::function< source_t(const source_t &)> &selector)
Projects each element of a sequence into a new form.
Definition enumerable.hpp:676
static double average(const ienumerable< double > &source)
Computes the average of a sequence of double values.
static result_t aggregate(const ienumerable< source_t > &source, 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)
Applies an accumulator function over a sequence. The specified seed value is used as the initial accu...
Definition enumerable.hpp:160
static bool contains(const ienumerable< source_t > &source, const source_t &value) noexcept
Determines whether a sequence contains a specified element by using the default equality comparer.
Definition enumerable.hpp:399
static const ienumerable< source_t > & default_if_empty(const ienumerable< source_t > &source, const source_t &default_value) noexcept
Returns the elements of the specified sequence or the specified value in a singleton collection if th...
Definition enumerable.hpp:515
static double average(const ienumerable< xtd::int64 > &source)
Computes the average of a sequence of xtd::int64 values.
static const ienumerable< source_t > & as_enumerable(std::initializer_list< source_t > source) noexcept
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
Definition enumerable.hpp:246
static const ienumerable< source_t > & as_enumerable(const ienumerable< source_t > &source) noexcept
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
Definition enumerable.hpp:235
static source_t first_or_default(const ienumerable< source_t > &source, const std::function< bool(const source_t &)> &predicate, const source_t &default_value) noexcept
Returns the first element of the sequence that satisfies a condition, or a specified default value if...
Definition enumerable.hpp:531
static const ienumerable< source_t > & default_if_empty(const ienumerable< source_t > &source) noexcept
Returns the elements of the specified sequence or the type parameter's default value in a singleton c...
Definition enumerable.hpp:502
static source_t first_or_default(const 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:550
static const auto & as_enumerable(const source_t(&array)[length]) noexcept
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
Definition enumerable.hpp:307
static const ienumerable< key_value_pair< key_t, xtd::size > > & count_by(const ienumerable< source_t > &source, const std::function< key_t(const source_t &)> &key_selector, const iequality_comparer< key_t > &key_comparer) noexcept
Returns the count of elements in the source sequence grouped by key.
Definition enumerable.hpp:475
static xtd::optional< double > average(const ienumerable< xtd::optional< double > > &source) noexcept
Computes the average of a sequence of optional double values.
static const ienumerable< xtd::int32 > & range(xtd::int32 start, xtd::int32 count)
Generates a sequence of integral numbers within a specified range.
static const ienumerable< source_t > & append(const ienumerable< source_t > &source, const source_t &element) noexcept
Appends a value to the end of the sequence.
Definition enumerable.hpp:218
static float average(const ienumerable< float > &source)
Computes the average of a sequence of float values.
static xtd::optional< double > average(const ienumerable< xtd::optional< xtd::int64 > > &source) noexcept
Computes the average of a sequence of optional xtd::int64 values.
static source_t aggregate(const ienumerable< source_t > &source, const source_t &seed, const std::function< source_t(const source_t &, const source_t &)> &func)
Applies an accumulator function over a sequence. The specified seed value is used as the initial accu...
Definition enumerable.hpp:107
static const ienumerable< source_t > & select(const ienumerable< source_t > &source, const std::function< source_t(const source_t &, xtd::size)> &selector)
Projects each element of a sequence into a new form by incorporating the element's index.
Definition enumerable.hpp:710
static const ienumerable< source_t > & concat(const ienumerable< source_t > &first, const ienumerable< source_t > &second) noexcept
Concatenates two sequences.
Definition enumerable.hpp:383
static xtd::size count(const ienumerable< source_t > &source, const std::function< bool(const source_t &)> &predicate) noexcept
Returns a number that represents how many elements in the specified sequence satisfy a condition.
Definition enumerable.hpp:442
static accumulate_t aggregate(const ienumerable< source_t > &source, const accumulate_t &seed, const std::function< accumulate_t(const source_t &, const accumulate_t &)> &func)
Applies an accumulator function over a sequence. The specified seed value is used as the initial accu...
Definition enumerable.hpp:124
static source_t first_or_default(const ienumerable< source_t > &source, const std::function< bool(const source_t &)> &predicate) noexcept
Returns the first element of the sequence that satisfies a condition or a default value if no such el...
Definition enumerable.hpp:541
static const ienumerable< source_t > & where(const ienumerable< source_t > &source, const std::function< bool(const source_t &, xtd::size)> &predicate)
Filters a sequence of values based on a predicate. Each element's index is used in the logic of the p...
Definition enumerable.hpp:755
static xtd::size count(const ienumerable< source_t > &source) noexcept
Returns the number of elements in a sequence.
Definition enumerable.hpp:426
static const auto & from(const collection_t &source) noexcept
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
Definition enumerable.hpp:605
static source_t first_or_default(const ienumerable< source_t > &source) noexcept
Returns the first element of the sequence that satisfies a condition or a default value if no such el...
Definition enumerable.hpp:558
static source_t aggregate(const 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:89
static const list< source_t > & to_list(const ienumerable< source_t > &source) noexcept
Creates a xtd::collections::generic::list <type_t> from an xtd::collections::generic::ienumerable <ty...
static const auto & as_enumerable(const collection_t &source) noexcept
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
Definition enumerable.hpp:261
static const ienumerable< source_t > & from(const ienumerable< source_t > &source) noexcept
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
Definition enumerable.hpp:581
Contains xtd::linq::from methods.
generic::ienumerable< xtd::any_object > ienumerable
Exposes an enumerator, which supports a simple iteration over a non-generic collection.
Definition ienumerable.hpp:32
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
#define static_
This keyword is use to represent a static object. A static object can't be instantiated (constructors...
Definition static.hpp:37
std::optional< type_t > optional
Represents the null_opt alias on std::nullopt_t.
Definition optional.hpp:175
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
long double decimal
Represents a decimal-precision floating-point number.
Definition decimal.hpp:23
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
std::type_info type
Stores information about a type.
Definition type.hpp:23
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
@ any
Indicates that all styles except allow_binary_specifier, allow_octal_specifier and allow_hex_specifie...
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Defines a key/value pair that can be set or retrieved.
Definition key_value_pair.hpp:37