xtd 1.0.0
Loading...
Searching...
No Matches
distinct_view.hpp
Go to the documentation of this file.
1
4#pragma once
5
8#include "../../iterable.hpp"
9#include "../../string.hpp"
10#include "../../views/views.hpp"
11
13namespace xtd {
15 namespace ranges {
17 namespace views {
38 template<typename comparer_t>
39 struct with_comparer {
40 const comparer_t& comparer;
41
42 template <xtd::iterable iterable_t>
43 auto operator()(iterable_t&& source) const {return xtd::linq::enumerable::from(std::forward<iterable_t>(source)).distinct(comparer);}
44
45 template <xtd::iterable iterable_t>
46 friend auto operator |(iterable_t&& source, const with_comparer& self) {return self(std::forward<iterable_t>(source));}
47 };
48
49 public:
51
56 template <xtd::iterable iterable_t>
57 auto operator()(iterable_t&& source) const {return xtd::linq::enumerable::as_enumerable(std::forward<iterable_t>(source)).distinct();}
62 template <xtd::iterable iterable_t, typename comparer_t>
63 auto operator()(iterable_t&& source, const comparer_t& comparer) const {return xtd::linq::enumerable::as_enumerable(std::forward<iterable_t>(source)).distinct(comparer);}
67 template<typename comparer_t>
68 auto operator()(const comparer_t& comparer) const {return with_comparer {comparer};}
69
81 template <xtd::iterable iterable_t>
82 friend auto operator |(iterable_t&& source, const distinct_view& view) {return view(std::forward<iterable_t>(source));}
84 };
85 }
86 }
87}
static auto from(source_t &&source) noexcept
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>.
The xtd::ranges::views::distinct_view class is used to distinct elements from a sequence.
Definition distinct_view.hpp:37
auto operator()(iterable_t &&source) const
Returns distinct elements from a sequence by using the default equality comparer to compare values.
Definition distinct_view.hpp:57
friend auto operator|(iterable_t &&source, const distinct_view &view)
Applies a distinct projection on the given range using the pipe operator.
Definition distinct_view.hpp:82
auto operator()(const comparer_t &comparer) const
Returns distinct elements from a sequence by using a specified xtd::collections::generic::iequality_c...
Definition distinct_view.hpp:68
auto operator()(iterable_t &&source, const comparer_t &comparer) const
Returns distinct elements from a sequence by using a specified xtd::collections::generic::iequality_c...
Definition distinct_view.hpp:63
Contains xtd::istringable interface.
Contains xtd::iterable concept.
Contains xtd::linq::enumerable <type_t> class.
The view namesapce contains range views, lightweight objects that indirectly represent iterable seque...
Definition distinct.hpp:20
The ranges namespace is an extension and generalization of the xtd::linq that makes them more powerfu...
Definition distinct.hpp:18
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Contains xtd::string alias.
Contains xtd::views alias namespace.