xtd 1.0.0
Loading...
Searching...
No Matches
enumerable_.hpp
Go to the documentation of this file.
1
4#pragma once
10#define __XTD_STD_INTERNAL__
12#undef __XTD_STD_INTERNAL__
13#define __XTD_CORE_INTERNAL__
17#undef __XTD_CORE_INTERNAL__
18#include "../callable.hpp"
19#include "../decimal.hpp"
20#include "../integer.hpp"
21#include "../iterable.hpp"
23#include "../func_callable.hpp"
24#include "../iequatable.hpp"
25#include "../int32.hpp"
26#include "../int64.hpp"
27#include "../numeric.hpp"
28#include "../optional.hpp"
30#include "../static.hpp"
31#include "../usize.hpp"
32#include <algorithm>
33#include <bitset>
34#include <functional>
35#include <queue>
36#include <stack>
37#include <tuple>
38
40template<typename type_t>
41struct __opaque_xtd_linq_enumerable_collection__;
42template<typename type_t, typename param_t>
43struct __opaque_xtd_linq_lazy_enumerable__;
45
47namespace xtd {
49 class range;
50 namespace collections::generic {
51 template<typename type_t>
53 template<typename type_t>
54 class ienumerable;
55 }
57
59 namespace linq {
60
77 public:
79
82 template<typename type_t>
84
86 template<typename type_t>
88
90 template<typename type_t>
92
94 template<typename type_t>
96
98 template<typename key_t, typename value_t>
101
103
113 template<xtd::iterable source_t, xtd::func_callable<xtd::iterable_value_type<source_t>, xtd::iterable_value_type<source_t>, xtd::iterable_value_type<source_t>> func_t>
114 [[nodiscard]] static auto aggregate(source_t&& source, func_t&& func) -> xtd::iterable_value_type<source_t>;
125 template<typename accumulate_t, xtd::iterable source_t, xtd::func_callable<accumulate_t, accumulate_t, xtd::iterable_value_type<source_t>> func_t>
126 [[nodiscard]] static auto aggregate(source_t&& source, accumulate_t&& seed, func_t&& func) -> accumulate_t;
139 template<typename result_t, typename accumulate_t, xtd::iterable source_t, xtd::func_callable<accumulate_t, accumulate_t, xtd::iterable_value_type<source_t>> func_t, xtd::func_callable<result_t, accumulate_t> result_selector_t>
140 [[nodiscard]] static auto aggregate(source_t&& source, accumulate_t&& seed, func_t&& func, result_selector_t&& result_selector) -> result_t;
141
150 template<xtd::iterable source_t, xtd::predicate_callable<xtd::iterable_value_type<source_t>> predicate_t>
151 [[nodiscard]] static auto all(source_t&& source, predicate_t&& predicate) -> bool;
152
161 template<xtd::iterable source_t>
162 [[nodiscard]] static auto any(source_t&& source) noexcept -> bool;
171 template<xtd::iterable source_t, xtd::predicate_callable<xtd::iterable_value_type<source_t>> predicate_t>
172 [[nodiscard]] static auto any(source_t&& source, predicate_t&& predicate) -> bool;
173
182 template<xtd::iterable source_t>
184
193 template<xtd::iterable source_t>
194 [[nodiscard]] static auto as_enumerable(source_t&& source) noexcept; // Defined in include/xtd/collections/generic/list.hpp
202 template<xtd::iterable source_t>
203 [[nodiscard]] static auto as_enumerable(const source_t& source) noexcept -> xtd::collections::generic::enumerable_generator<xtd::iterable_value_type<source_t>>;
211 template<xtd::iterable source_t>
220 template<typename value_t>
221 [[nodiscard]] static auto as_enumerable(std::initializer_list<value_t> source) noexcept -> xtd::collections::generic::enumerable_generator<value_t>;
230 template<std::forward_iterator iterator_t>
231 [[nodiscard]] static auto as_enumerable(iterator_t first, iterator_t last) noexcept -> xtd::collections::generic::enumerable_generator<typename std::decay<decltype(*first)>::type>;
240 template<std::forward_iterator iterator_t>
241 [[nodiscard]] static auto as_enumerable(iterator_t iterator, xtd::usize length) noexcept -> xtd::collections::generic::enumerable_generator<typename std::decay<decltype(*iterator)>::type>;
250 template<typename value_t, xtd::usize length>
251 [[nodiscard]] static auto as_enumerable(const value_t (&array)[length]) noexcept -> xtd::collections::generic::enumerable_generator<value_t>;
260 template<typename value_t, xtd::usize length>
261 [[nodiscard]] static auto as_enumerable(value_t (&array)[length]) noexcept -> xtd::collections::generic::enumerable_generator<value_t>;
262
264 template<xtd::usize size_>
265 [[nodiscard]] static auto as_enumerable(const std::bitset<size_>& source) noexcept -> xtd::collections::generic::enumerable_generator<bool>; // defined in xtd/collections/bit_array.hpp
266 template<xtd::usize size_>
267 [[nodiscard]] static auto as_enumerable(std::bitset<size_>& source) noexcept -> xtd::collections::generic::enumerable_generator<bool>; // defined in xtd/collections/bit_array.hpp
268 template<typename value_t, typename container_t>
269 [[nodiscard]] static auto as_enumerable(const std::queue<value_t, container_t>& source) noexcept -> xtd::collections::generic::enumerable_generator<value_t>;
270 template<typename value_t, typename container_t>
271 [[nodiscard]] static auto as_enumerable(std::queue<value_t, container_t>& source) noexcept -> xtd::collections::generic::enumerable_generator<value_t>;
272 template<typename value_t, typename container_t>
273 [[nodiscard]] static auto as_enumerable(const std::priority_queue<value_t, container_t>& source) noexcept -> xtd::collections::generic::enumerable_generator<value_t>;
274 template<typename value_t, typename container_t>
275 [[nodiscard]] static auto as_enumerable(std::priority_queue<value_t, container_t>& source) noexcept -> xtd::collections::generic::enumerable_generator<value_t>;
276 template<typename value_t, typename container_t>
277 [[nodiscard]] static auto as_enumerable(const std::stack<value_t, container_t>& source) noexcept -> xtd::collections::generic::enumerable_generator<value_t>;
278 template<typename value_t, typename container_t>
279 [[nodiscard]] static auto as_enumerable(std::stack<value_t, container_t>& source) noexcept -> xtd::collections::generic::enumerable_generator<value_t>;
281
286 template<xtd::iterable source_t>
288 [[nodiscard]] static auto average(source_t&& source) -> xtd::decimal;
293 template<xtd::iterable source_t>
295 [[nodiscard]] static auto average(source_t&& source) -> double;
300 template<xtd::iterable source_t>
302 [[nodiscard]] static auto average(source_t&& source) -> xtd::single;
307 template<xtd::iterable source_t>
309 [[nodiscard]] static auto average(source_t&& source) -> double;
314 template<xtd::iterable source_t>
316 [[nodiscard]] static auto average(source_t&& source) -> double;
317
321 template<xtd::iterable source_t>
322 requires std::same_as<xtd::iterable_value_type<source_t>, xtd::optional<xtd::decimal>>
323 [[nodiscard]] static auto average(source_t&& source) -> xtd::optional<xtd::decimal>;
327 template<xtd::iterable source_t>
328 requires std::same_as<xtd::iterable_value_type<source_t>, xtd::optional<double>>
329 [[nodiscard]] static auto average(source_t&& source) -> xtd::optional<double>;
333 template<xtd::iterable source_t>
334 requires std::same_as<xtd::iterable_value_type<source_t>, xtd::optional<xtd::single>>
335 [[nodiscard]] static auto average(source_t&& source) -> xtd::optional<xtd::single>;
339 template<xtd::iterable source_t>
340 requires std::same_as<xtd::iterable_value_type<source_t>, xtd::optional<xtd::int32>>
341 [[nodiscard]] static auto average(source_t&& source) -> xtd::optional<double>;
345 template<xtd::iterable source_t>
346 requires std::same_as<xtd::iterable_value_type<source_t>, xtd::optional<xtd::int64>>
347 [[nodiscard]] static auto average(source_t&& source) -> xtd::optional<double>;
348
356 template<typename result_t, xtd::iterable source_t>
357 [[nodiscard]] static auto cast(source_t&& source) -> xtd::collections::generic::enumerable_generator<result_t>; // Defined include/xtd/as.hpp
358
366 template<xtd::iterable source_t>
367 [[nodiscard]] static auto chunk(source_t&& source, xtd::usize size) -> xtd::collections::generic::enumerable_generator<xtd::array<xtd::iterable_value_type<source_t>>>; // Defined in include/xtd/array.hpp
368
374 template<xtd::iterable first_t, xtd::iterable second_t>
375 [[nodiscard]] static auto concat(first_t&& first, second_t&& second) noexcept -> xtd::collections::generic::enumerable_generator<xtd::iterable_value_type<first_t>>;
376
382 template<xtd::iterable source_t>
383 [[nodiscard]] static auto contains(source_t&& source, const xtd::iterable_value_type<source_t>& value) noexcept -> bool;
390 template<xtd::iterable source_t>
391 [[nodiscard]] static auto contains(source_t&& source, const xtd::iterable_value_type<source_t>& value, const iequality_comparer<xtd::iterable_value_type<source_t>>& comparer) noexcept -> bool;
398 template<xtd::iterable source_t, xtd::func_callable<bool, xtd::iterable_value_type<source_t>, xtd::iterable_value_type<source_t>> equater_t>
399 [[nodiscard]] static auto contains(source_t&& source, const xtd::iterable_value_type<source_t>& value, equater_t&& equater) noexcept -> bool;
400
408 template<xtd::iterable source_t>
409 [[nodiscard]] static auto count(source_t&& source) noexcept -> xtd::usize;
418 template<xtd::iterable source_t, xtd::predicate_callable<xtd::iterable_value_type<source_t>> predicate_t>
419 [[nodiscard]] static auto count(source_t&& source, predicate_t&& predicate) noexcept -> xtd::usize;
425 template<xtd::iterable source_t>
426 [[nodiscard]] static auto count(source_t&& source, xtd::iterable_value_type<source_t>&& value) noexcept -> xtd::usize;
427
437 template<typename key_t, xtd::iterable source_t, xtd::callable<key_t, xtd::iterable_value_type<source_t>> key_selector_t>
438 [[nodiscard]] 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>>;
449 template<typename key_t, xtd::iterable source_t, xtd::callable<key_t, xtd::iterable_value_type<source_t>> key_selector_t>
450 [[nodiscard]] static auto count_by(source_t&& source, key_selector_t&& key_selector, const iequality_comparer<key_t>& key_comparer) noexcept -> xtd::collections::generic::enumerable_generator<xtd::collections::generic::key_value_pair<key_t, xtd::usize>>;
462 template<typename key_t, xtd::iterable source_t, xtd::callable<key_t, xtd::iterable_value_type<source_t>> key_selector_t, xtd::func_callable<bool, key_t, key_t> key_equater_t>
463 [[nodiscard]] static auto count_by(source_t&& source, key_selector_t&& key_selector, key_equater_t&& key_equater) noexcept -> xtd::collections::generic::enumerable_generator<xtd::collections::generic::key_value_pair<key_t, xtd::usize>>; // Defined in include/xtd/collections/generic/list.hpp
464
472 template<xtd::iterable source_t>
482 template<xtd::iterable source_t>
484
489 template<xtd::iterable source_t>
490 [[nodiscard]] static auto distinct(source_t&& source) noexcept -> xtd::collections::generic::enumerable_generator<xtd::iterable_value_type<source_t>>; // Defined in include/xtd/collections/generic/list.hpp
495 template<xtd::iterable source_t>
502 template<xtd::iterable source_t, xtd::func_callable<bool, xtd::iterable_value_type<source_t>, xtd::iterable_value_type<source_t>> equater_t>
503 [[nodiscard]] static auto distinct(source_t&& source, equater_t&& equater) noexcept -> xtd::collections::generic::enumerable_generator<xtd::iterable_value_type<source_t>>; // Defined in include/xtd/collections/generic/list.hpp
504
510 template<xtd::iterable source_t>
511 [[nodiscard]] static auto first(source_t&& source) -> xtd::iterable_value_type<source_t>;
518 template<xtd::iterable source_t, xtd::func_callable<bool, xtd::iterable_value_type<source_t>> predicate_t>
519 [[nodiscard]] static auto first(source_t&& source, predicate_t&& predicate) -> xtd::iterable_value_type<source_t>;
520
527 template<xtd::iterable source_t, xtd::predicate_callable<xtd::iterable_value_type<source_t>> prediacte_t>
528 [[nodiscard]] 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>;
534 template<xtd::iterable source_t, xtd::predicate_callable<xtd::iterable_value_type<source_t>> prediacte_t>
535 [[nodiscard]] static auto first_or_default(source_t&& source, prediacte_t&& predicate) noexcept -> xtd::iterable_value_type<source_t>;
541 template<xtd::iterable source_t>
542 [[nodiscard]] static auto first_or_default(source_t&& source, xtd::iterable_value_type<source_t>&& default_value) noexcept -> xtd::iterable_value_type<source_t>;
547 template<xtd::iterable source_t>
548 [[nodiscard]] static auto first_or_default(source_t&& source) noexcept -> xtd::iterable_value_type<source_t>;
549
559 template<xtd::iterable source_t>
560 [[nodiscard]] static auto from(source_t&& source) noexcept; // Defined in include/xtd/collections/generic/list.hpp
569 template<xtd::iterable source_t>
570 [[nodiscard]] static auto from(const source_t& source) noexcept -> xtd::collections::generic::enumerable_generator<xtd::iterable_value_type<source_t>>;
579 template<xtd::iterable source_t>
580 [[nodiscard]] static auto from(source_t& source) noexcept -> xtd::collections::generic::enumerable_generator<xtd::iterable_value_type<source_t>>;
589 template<typename value_t>
590 [[nodiscard]] static auto from(std::initializer_list<value_t> source) noexcept -> xtd::collections::generic::enumerable_generator<value_t>;
602 template<std::forward_iterator iterator_t>
603 [[nodiscard]] static auto from(iterator_t first, iterator_t last) noexcept -> xtd::collections::generic::enumerable_generator<typename std::decay<decltype(*first)>::type>;
613 template<std::forward_iterator iterator_t>
614 [[nodiscard]] static auto from(iterator_t iterator, xtd::usize length) noexcept -> xtd::collections::generic::enumerable_generator<typename std::decay<decltype(*iterator)>::type>;
624 template<typename value_t, xtd::usize length>
625 [[nodiscard]] static auto from(const value_t (&array)[length]) noexcept -> xtd::collections::generic::enumerable_generator<value_t>;
635 template<typename value_t, xtd::usize length>
636 [[nodiscard]] static auto from(value_t (&array)[length]) noexcept -> xtd::collections::generic::enumerable_generator<value_t>;
637
639 template<xtd::usize size_>
640 [[nodiscard]] static auto from(const std::bitset<size_>& source) noexcept -> xtd::collections::generic::enumerable_generator<bool>; // defined in xtd/collections/bit_array.hpp
641 template<xtd::usize size_>
642 [[nodiscard]] static auto from(std::bitset<size_>& source) noexcept -> xtd::collections::generic::enumerable_generator<bool>; // defined in xtd/collections/bit_array.hpp
643 template<typename value_t, typename container_t>
644 [[nodiscard]] static auto from(const std::queue<value_t, container_t>& source) noexcept -> xtd::collections::generic::enumerable_generator<value_t>;
645 template<typename value_t, typename container_t>
646 [[nodiscard]] static auto from(std::queue<value_t, container_t>& source) noexcept -> xtd::collections::generic::enumerable_generator<value_t>;
647 template<typename value_t, typename container_t>
648 [[nodiscard]] static auto from(const std::priority_queue<value_t, container_t>& source) noexcept -> xtd::collections::generic::enumerable_generator<value_t>;
649 template<typename value_t, typename container_t>
650 [[nodiscard]] static auto from(std::priority_queue<value_t, container_t>& source) noexcept -> xtd::collections::generic::enumerable_generator<value_t>;
651 template<typename value_t, typename container_t>
652 [[nodiscard]] static auto from(const std::stack<value_t, container_t>& source) noexcept -> xtd::collections::generic::enumerable_generator<value_t>;
653 template<typename value_t, typename container_t>
654 [[nodiscard]] static auto from(std::stack<value_t, container_t>& source) noexcept -> xtd::collections::generic::enumerable_generator<value_t>;
656
662 template<xtd::iterable source_t>
663 [[nodiscard]] static auto last(source_t&& source) -> xtd::iterable_value_type<source_t>;
670 template<xtd::iterable source_t, xtd::func_callable<bool, xtd::iterable_value_type<source_t>> predicate_t>
671 [[nodiscard]] static auto last(source_t&& source, predicate_t&& predicate) -> xtd::iterable_value_type<source_t>;
672
676 template<xtd::iterable source_t>
678 [[nodiscard]] static auto max(source_t&& source) -> xtd::iterable_value_type<source_t>;
683 template<xtd::iterable source_t, xtd::callable<xtd::iterable_value_type<source_t>, xtd::iterable_value_type<source_t>> selector_t>
685 [[nodiscard]] static auto max(source_t&& source, selector_t&& selector) -> xtd::iterable_value_type<source_t>;
690 template<typename result_t, xtd::iterable source_t, xtd::callable<result_t, xtd::iterable_value_type<source_t>> selector_t>
692 [[nodiscard]] static auto max(source_t&& source, selector_t&& selector) -> result_t;
693
697 template<xtd::iterable source_t>
699 [[nodiscard]] static auto min(source_t&& source) -> xtd::iterable_value_type<source_t>;
704 template<xtd::iterable source_t, xtd::callable<xtd::iterable_value_type<source_t>, xtd::iterable_value_type<source_t>> selector_t>
706 [[nodiscard]] static auto min(source_t&& source, selector_t&& selector) -> xtd::iterable_value_type<source_t>;
711 template<typename result_t, xtd::iterable source_t, xtd::callable<result_t, xtd::iterable_value_type<source_t>> selector_t>
713 [[nodiscard]] static auto min(source_t&& source, selector_t&& selector) -> result_t;
714
718 template<xtd::iterable source_t>
724 template<xtd::iterable source_t>
731 template<xtd::iterable source_t, xtd::func_callable<bool, xtd::iterable_value_type<source_t>, xtd::iterable_value_type<source_t>> lesser_t>
732 [[nodiscard]] static auto order(source_t&& source, lesser_t&& lesser) -> xtd::collections::generic::enumerable_generator<xtd::iterable_value_type<source_t>>; // Defined in include/xtd/collections/generic/list.hpp
733
741 template<typename key_t, xtd::iterable source_t, xtd::callable<key_t, xtd::iterable_value_type<source_t>> key_selector_t>
742 [[nodiscard]] static auto order_by(source_t&& source, key_selector_t&& key_selector) -> xtd::collections::generic::enumerable_generator<xtd::iterable_value_type<source_t>>; // Defined in include/xtd/collections/generic/list.hpp
743
751 template<xtd::iterable source_t, xtd::callable<xtd::iterable_value_type<source_t>, xtd::iterable_value_type<source_t>> key_selector_t>
752 [[nodiscard]] static auto order_by(source_t&& source, key_selector_t&& key_selector) -> xtd::collections::generic::enumerable_generator<xtd::iterable_value_type<source_t>>; // Defined in include/xtd/collections/generic/list.hpp
753
761 template<typename key_t, xtd::iterable source_t, xtd::callable<key_t, xtd::iterable_value_type<source_t>> key_selector_t>
762 [[nodiscard]] static auto order_by_descending(source_t&& source, key_selector_t&& key_selector) -> xtd::collections::generic::enumerable_generator<xtd::iterable_value_type<source_t>>; // Defined in include/xtd/collections/generic/list.hpp
763
771 template<xtd::iterable source_t, xtd::callable<xtd::iterable_value_type<source_t>, xtd::iterable_value_type<source_t>> key_selector_t>
772 [[nodiscard]] static auto order_by_descending(source_t&& source, key_selector_t&& key_selector) -> xtd::collections::generic::enumerable_generator<xtd::iterable_value_type<source_t>>; // Defined in include/xtd/collections/generic/list.hpp
773
781 template<xtd::integer integer_t>
791 template<xtd::integer integer_t>
792 [[nodiscard]] static auto range(integer_t start, integer_t count) -> xtd::collections::generic::enumerable_generator<integer_t>;
799 template<xtd::integer integer_t>
800 [[nodiscard]] static auto range(integer_t start, integer_t count, integer_t step) -> xtd::collections::generic::enumerable_generator<integer_t>;
801
809 template<typename element_t>
810 [[nodiscard]] static auto repeat(const element_t& element, xtd::usize count) -> xtd::collections::generic::enumerable_generator<element_t>;
811
813 [[nodiscard]] static auto repeat(const char* element, xtd::usize count) -> xtd::collections::generic::enumerable_generator<string>; // Defined in include/xtd/string.hpp
814 [[nodiscard]] static auto repeat(const xtd::char16* element, xtd::usize count) -> xtd::collections::generic::enumerable_generator<string>; // Defined in include/xtd/string.hpp
815 [[nodiscard]] static auto repeat(const xtd::char32* element, xtd::usize count) -> xtd::collections::generic::enumerable_generator<string>; // Defined in include/xtd/string.hpp
816 [[nodiscard]] static auto repeat(const xtd::char8* element, xtd::usize count) -> xtd::collections::generic::enumerable_generator<string>; // Defined in include/xtd/string.hpp
817 [[nodiscard]] static auto repeat(const xtd::wchar* element, xtd::usize count) -> xtd::collections::generic::enumerable_generator<string>; // Defined in include/xtd/string.hpp
819
824 template<xtd::iterable source_t>
826
836 template<xtd::iterable source_t>
837 [[nodiscard]] static auto select(source_t&& source, auto&& selector) -> xtd::collections::generic::enumerable_generator<xtd::raw_type<decltype(selector(xtd::iterable_value_type<source_t> {}))>>;
838 /*
848 template<xtd::iterable source_t>
849 [[nodiscard]] static auto select(source_t&& source, auto&& selector) -> xtd::collections::generic::enumerable_generator<xtd::raw_type<decltype(selector(xtd::iterable_value_type<source_t> {}, xtd::usize {}))>>;
850 */
851
856 template<xtd::iterable first_t, xtd::iterable second_t>
857 [[nodiscard]] static auto sequence_equal(first_t&& first, second_t&& second) -> bool;
863 template<xtd::iterable first_t, xtd::iterable second_t>
864 [[nodiscard]] static auto sequence_equal(first_t&& first, second_t&& second, const iequality_comparer<xtd::iterable_value_type<first_t>>& comparer) -> bool;
870 template<xtd::iterable first_t, xtd::iterable second_t, xtd::func_callable<bool, xtd::iterable_value_type<first_t>, xtd::iterable_value_type<second_t>> equality_comparer_t>
871 [[nodiscard]] static auto sequence_equal(first_t&& first, second_t&& second, equality_comparer_t&& comparer) -> bool;
872
877 template<xtd::forward_iterable source_t>
878 [[nodiscard]] static auto shuffle(source_t&& source) -> xtd::collections::generic::enumerable_generator<xtd::iterable_value_type<source_t>>; // Defined in include/xtd/random.hpp
879
884 template<xtd::iterable source_t>
886
894 template<xtd::iterable source_t>
896
901 template<xtd::iterable source_t>
908 template<xtd::iterable source_t>
909 [[nodiscard]] static auto take(source_t&& source, const xtd::range& range) -> xtd::collections::generic::enumerable_generator<xtd::iterable_value_type<source_t>>; // Defined in include/xtd/range.hpp
910
918 template<xtd::iterable source_t>
920
930 template<typename source_t>
931 [[nodiscard]] static auto to_array(const ienumerable<source_t>& source); // Defined in include/xtd/array.hpp
932
942 template<typename source_t>
943 [[nodiscard]] static auto to_list(const ienumerable<source_t>& source); // Defined in include/xtd/collections/generic/list.hpp
944
956 template<xtd::iterable source_t>
958
966 template<xtd::iterable first_t, xtd::iterable second_t>
976 template<xtd::iterable first_t, xtd::iterable second_t>
977 [[nodiscard]] static auto zip(first_t&& first, second_t&& second, auto&& result_selector) -> xtd::collections::generic::enumerable_generator<xtd::raw_type<decltype(result_selector(xtd::iterable_value_type<first_t> {}, xtd::iterable_value_type<second_t> {}))>>;
983 template<xtd::iterable first_t, xtd::iterable second_t, xtd::iterable third_t>
991 template<xtd::iterable first_t, xtd::iterable second_t, xtd::iterable third_t>
992 [[nodiscard]] static auto zip(first_t&& first, second_t&& second, third_t&& third, auto&& result_selector) -> xtd::collections::generic::enumerable_generator<xtd::raw_type<decltype(result_selector(xtd::iterable_value_type<first_t> {}, xtd::iterable_value_type<second_t> {}, xtd::iterable_value_type<third_t> {}))>>;
994
995 private:
996 template<typename type_t>
997 struct enumerable_holder {
998 enumerable_holder(const type_t& value);
999 //enumerable_holder(type_t& value);
1000 enumerable_holder(type_t&& value) requires std::movable<type_t>;
1001
1002 auto get() const -> const xtd::raw_type<type_t>&;
1003
1004 private:
1005 std::optional<type_t> value_;
1006 const xtd::raw_type<type_t>* ptr_;
1007 };
1008
1009 template<typename...>
1010 static inline constexpr bool always_false_v = false;
1011
1012 template<typename predicate_t, typename value_t>
1013 [[nodiscard]] static constexpr auto invoke_predicate_with_optional_index(predicate_t&& predicate, value_t&& value, xtd::usize index) -> bool;
1014
1015 template<typename result_t, typename selector_t, typename value_t>
1016 [[nodiscard]] static auto invoke_selector_with_optional_index(selector_t&& selector, value_t&& value, xtd::usize index) -> result_t;
1017 };
1018 }
1019}
Contains xtd::callable concept.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
Represents an enumerable generator that supports deferred, lazy iteration over a collection of a spec...
Definition enumerable_generator.hpp:45
Exposes a method that compares two objects.
Definition icomparer.hpp:30
Exposes the enumerator, which supports a simple iteration over a collection of a specified type.
Definition ienumerable.hpp:40
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:84
Provides a set of static methods for querying objects that implement ienumerable <type_t>.
Definition enumerable_.hpp:76
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 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.
static auto last(source_t &&source) -> xtd::iterable_value_type< source_t >
Returns the last element of a sequence.
static auto order(source_t &&source, lesser_t &&lesser) -> xtd::collections::generic::enumerable_generator< xtd::iterable_value_type< source_t > >
Sorts the elements of a sequence in ascending order.
static auto zip(first_t &&first, second_t &&second, auto &&result_selector) -> xtd::collections::generic::enumerable_generator< xtd::raw_type< decltype(result_selector(xtd::iterable_value_type< first_t > {}, xtd::iterable_value_type< second_t > {}))> >
Applies a specified function to the corresponding elements of two sequences, producing a sequence of ...
static auto range(integer_t start, integer_t count) -> xtd::collections::generic::enumerable_generator< integer_t >
Generates a sequence of integral numbers within a specified range.
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 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 last(source_t &&source, predicate_t &&predicate) -> xtd::iterable_value_type< source_t >
Returns the last element in a sequence that satisfies a specified condition.
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.
static auto max(source_t &&source, selector_t &&selector) -> xtd::iterable_value_type< source_t >
Returns the maximum value in a sequence of xtd::numeric values.
typename xtd::collections::generic::ienumerable< type_t > ienumerable
Represents the ienumerable value type.
Definition enumerable_.hpp:91
typename xtd::collections::generic::enumerator< type_t > enumerator
Represents the enumerator value type.
Definition enumerable_.hpp:83
static auto sequence_equal(first_t &&first, second_t &&second, const iequality_comparer< xtd::iterable_value_type< first_t > > &comparer) -> bool
Determines whether two sequences are equal by comparing their elements by using a specifie the equali...
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 from(std::initializer_list< value_t > source) noexcept -> xtd::collections::generic::enumerable_generator< value_t >
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
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...
typename xtd::collections::generic::iequality_comparer< type_t > iequality_comparer
Represents the ienumerable value type.
Definition enumerable_.hpp:87
static auto zip(first_t &&first, second_t &&second, third_t &&third) -> xtd::collections::generic::enumerable_generator< std::tuple< xtd::iterable_value_type< first_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.
static auto min(source_t &&source) -> xtd::iterable_value_type< source_t >
Returns the minimum value in a sequence of xtd::numeric values.
static auto count_by(source_t &&source, key_selector_t &&key_selector, const iequality_comparer< key_t > &key_comparer) 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 as_enumerable(iterator_t first, iterator_t last) noexcept -> xtd::collections::generic::enumerable_generator< typename std::decay< decltype(*first)>::type >
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
typename xtd::collections::generic::list< type_t > list
Represents the list value type.
Definition enumerable_.hpp:95
static auto as_enumerable(value_t(&array)[length]) noexcept -> xtd::collections::generic::enumerable_generator< value_t >
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
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 aggregate(source_t &&source, accumulate_t &&seed, func_t &&func) -> accumulate_t
Applies an accumulator function over a sequence. The specified seed value is used as the initial accu...
static auto as_enumerable(const value_t(&array)[length]) noexcept -> xtd::collections::generic::enumerable_generator< value_t >
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
static auto first(source_t &&source, predicate_t &&predicate) -> xtd::iterable_value_type< source_t >
Returns the first element in a sequence that satisfies a specified condition.
static auto aggregate(source_t &&source, accumulate_t &&seed, func_t &&func, result_selector_t &&result_selector) -> result_t
Applies an accumulator function over a sequence. The specified seed value is used as the initial accu...
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 average(source_t &&source) -> double
Computes the average of a sequence of xtd::int64 values.
static auto average(source_t &&source) -> xtd::optional< double >
Computes the average of a sequence of optional xtd::int64 values.
static auto as_enumerable(const source_t &source) noexcept -> xtd::collections::generic::enumerable_generator< xtd::iterable_value_type< source_t > >
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
static auto average(source_t &&source) -> xtd::optional< double >
Computes the average of a sequence of optional double values.
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 first_or_default(source_t &&source, 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 default value if no such el...
static auto from(iterator_t iterator, xtd::usize length) noexcept -> xtd::collections::generic::enumerable_generator< typename std::decay< decltype(*iterator)>::type >
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
static auto all(source_t &&source, predicate_t &&predicate) -> bool
Determines whether all elements of a sequence satisfy a condition.
static auto average(source_t &&source) -> xtd::optional< xtd::decimal >
Computes the average of a sequence of optional xtd::decimal values.
static auto as_enumerable(iterator_t iterator, xtd::usize length) noexcept -> xtd::collections::generic::enumerable_generator< typename std::decay< decltype(*iterator)>::type >
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
static auto distinct(source_t &&source, equater_t &&equater) noexcept -> xtd::collections::generic::enumerable_generator< xtd::iterable_value_type< source_t > >
Returns distinct elements from a sequence by using a specified xtd::collections::generic::iequality_c...
static auto average(source_t &&source) -> xtd::optional< xtd::single >
Computes the average of a sequence of optional float values.
static auto order(source_t &&source, const xtd::collections::generic::icomparer< xtd::iterable_value_type< source_t > > &comparer) -> xtd::collections::generic::enumerable_generator< xtd::iterable_value_type< source_t > >
Sorts the elements of a sequence in ascending order.
static auto from(source_t &&source) noexcept
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
static auto max(source_t &&source, selector_t &&selector) -> result_t
Returns the maximum value in a sequence of xtd::numeric values.
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 contains(source_t &&source, const xtd::iterable_value_type< source_t > &value, equater_t &&equater) noexcept -> bool
Determines whether a sequence contains a specified element by using a specified equality comparer.
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 first_or_default(source_t &&source, prediacte_t &&predicate) noexcept -> xtd::iterable_value_type< source_t >
Returns the first element of the sequence that satisfies a condition or a default value if no such el...
static auto from(iterator_t first, iterator_t last) noexcept -> xtd::collections::generic::enumerable_generator< typename std::decay< decltype(*first)>::type >
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
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 distinct(source_t &&source, const iequality_comparer< xtd::iterable_value_type< source_t > > &comparer) noexcept -> xtd::collections::generic::enumerable_generator< xtd::iterable_value_type< source_t > >
Returns distinct elements from a sequence by using a specified xtd::collections::generic::iequality_c...
static auto as_enumerable(source_t &source) noexcept -> xtd::collections::generic::enumerable_generator< xtd::iterable_value_type< source_t > >
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
static auto any(source_t &&source, predicate_t &&predicate) -> bool
Determines whether any element of a sequence satisfies a condition.
static auto from(const value_t(&array)[length]) noexcept -> xtd::collections::generic::enumerable_generator< value_t >
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
static auto min(source_t &&source, selector_t &&selector) -> xtd::iterable_value_type< source_t >
Returns the minimum value in a sequence of xtd::numeric values.
static auto zip(first_t &&first, second_t &&second, third_t &&third, auto &&result_selector) -> xtd::collections::generic::enumerable_generator< xtd::raw_type< decltype(result_selector(xtd::iterable_value_type< first_t > {}, xtd::iterable_value_type< second_t > {}, xtd::iterable_value_type< third_t > {}))> >
Applies a specified function to the corresponding elements of three sequences, producing a sequence o...
static auto from(value_t(&array)[length]) noexcept -> xtd::collections::generic::enumerable_generator< value_t >
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
static auto count(source_t &&source, predicate_t &&predicate) noexcept -> xtd::usize
Returns a number that represents how many elements in the specified sequence satisfy a condition.
static auto from(const source_t &source) noexcept -> xtd::collections::generic::enumerable_generator< xtd::iterable_value_type< source_t > >
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
static auto contains(source_t &&source, const xtd::iterable_value_type< source_t > &value, const iequality_comparer< xtd::iterable_value_type< source_t > > &comparer) noexcept -> bool
Determines whether a sequence contains a specified element by using a specified equality comparer.
static auto average(source_t &&source) -> double
Computes the average of a sequence of double values.
static auto to_array(const ienumerable< source_t > &source)
Creates a xtd::array <type_t> from an xtd::collections::generic::ienumerable <type_t>.
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 repeat(const element_t &element, xtd::usize count) -> xtd::collections::generic::enumerable_generator< element_t >
Generates a sequence that contains one repeated value.
static auto range(integer_t start, integer_t count, integer_t step) -> xtd::collections::generic::enumerable_generator< integer_t >
Generates a sequence of integral numbers within a specified range and step.
static auto first(source_t &&source) -> xtd::iterable_value_type< source_t >
Returns the first element of a sequence.
static auto as_enumerable(std::initializer_list< value_t > source) noexcept -> xtd::collections::generic::enumerable_generator< value_t >
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
xtd::collections::generic::key_value_pair< key_t, value_t > key_value_pair
Represents the key value pair value type.
Definition enumerable_.hpp:99
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 min(source_t &&source, selector_t &&selector) -> result_t
Returns the minimum value in a sequence of xtd::numeric values.
static auto count(source_t &&source) noexcept -> xtd::usize
Returns the number of elements in a sequence.
static auto range(integer_t count) -> xtd::collections::generic::enumerable_generator< integer_t >
Generates a sequence of integral numbers within a specified range.
static auto first_or_default(source_t &&source) noexcept -> xtd::iterable_value_type< source_t >
Returns the first element of the sequence that satisfies a condition or a default value if no such el...
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 default_if_empty(source_t &&source, const xtd::iterable_value_type< source_t > &default_value) noexcept -> xtd::collections::generic::enumerable_generator< xtd::iterable_value_type< source_t > >
Returns the elements of the specified sequence or the specified value in a singleton collection if th...
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 from(source_t &source) noexcept -> xtd::collections::generic::enumerable_generator< xtd::iterable_value_type< source_t > >
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
static auto count(source_t &&source, xtd::iterable_value_type< source_t > &&value) noexcept -> xtd::usize
Returns the number of elements with the specified value.
static auto select(source_t &&source, auto &&selector) -> xtd::collections::generic::enumerable_generator< xtd::raw_type< decltype(selector(xtd::iterable_value_type< source_t > {}))> >
Projects each element of a sequence into a new form.
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(source_t &&source, const xtd::range &range) -> 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 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.
static auto count_by(source_t &&source, key_selector_t &&key_selector, key_equater_t &&key_equater) 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 sequence_equal(first_t &&first, second_t &&second, equality_comparer_t &&comparer) -> bool
Determines whether two sequences are equal by comparing their elements by using a specifie the equali...
static auto to_list(const ienumerable< source_t > &source)
Creates a xtd::collections::generic::list <type_t> from an xtd::collections::generic::ienumerable <ty...
static auto average(source_t &&source) -> xtd::single
Computes the average of a sequence of float values.
static auto average(source_t &&source) -> xtd::optional< double >
Computes the average of a sequence of optional xtd::int32 values.
static auto average(source_t &&source) -> double
Computes the average of a sequence of xtd::int32 values.
Represents a range that has start and end indexes.
Definition range.hpp:38
Definition numeric.hpp:12
Definition real_decimal.hpp:13
Definition real_double.hpp:13
Definition real_single.hpp:13
Definition signed_integer_32.hpp:13
Definition signed_integer_64.hpp:14
Contains xtd::decimal type.
Contains xtd::collections::generic::equality_comparer <type_t> class.
Contains xtd::func_callable concept.
Contains xtd::collections::generic::comparer <type_t> class.
Contains xtd::collections::generic::enumerator <type_t> class.
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
#define static_
This keyword is use to represent a static object. A static object can't be instantiated (constructors...
Definition static.hpp:38
std::type_info type
Stores information about a type.
Definition type.hpp:23
char8_t char8
Represents a 8-bit unicode character.
Definition char8.hpp:26
wchar_t wchar
Represents a wide character.
Definition wchar.hpp:24
long double decimal
Represents a decimal-precision floating-point number.
Definition decimal.hpp:23
char16_t char16
Represents a 16-bit unicode character.
Definition char16.hpp:26
std::optional< type_t > optional
Represents the optional alias on std::optional.
Definition optional.hpp:26
std::size_t usize
Represents an unsigned size of any object in bytes.
Definition usize.hpp:22
float single
Represents a single-precision floating-point number.
Definition single.hpp:23
char32_t char32
Represents a 32-bit unicode character.
Definition char32.hpp:23
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
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::iequatable interface.
Contains xtd::int32 type.
Contains xtd::int64 type.
Contains xtd::integer concept.
Contains xtd::iterable concept.
Contains xtd::iterable_value_type alias.
Contains xtd::collections::generic::helpers::lesser struct.
The xtd::collections::generic namespace contains interfaces and classes that define generic collectio...
Definition comparer.hpp:16
Provides classes and interfaces that support queries that use Language-Integrated Query (LINQ).
Definition enumerable_.hpp:59
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
constexpr auto length() const noexcept -> size_type
Returns the length of the current read_only_span.
Definition read_only_span.hpp:209
constexpr auto size() const noexcept -> size_type
Returns the number of elements.
Definition read_only_span.hpp:213
Contains xtd::numeric concept.
Contains xtd::optional type.
Contains xtd::predicate_callable concept.
Contains xtd::collections::generic::helpers::raw_array class.
Contains xtd::static_object class.
Supports a simple iteration over a generic collection.
Definition enumerator.hpp:39
Defines a key/value pair that can be set or retrieved.
Definition key_value_pair.hpp:37
Contains xtd::usize type.