6#include <system/object.h>
7#include <system/icomparable.h>
11namespace Collections {
26#ifdef ASPOSE_COMPARE_BY_REF
52 : m_comparator(comparator)
59 m_comparator = comparator;
67 template <
typename Q = T>
68 typename std::enable_if<detail::has_operator_less<Q>::value,
bool>::type
operator()(
const Q &x,
const Q &y)
const
71 return m_comparator ? m_comparator->Compare(x, y) < 0 : (x < y);
79 template <
typename Q = T>
80 typename std::enable_if<!detail::has_operator_less<Q>::value,
bool>::type
operator()(
const Q &x,
const Q &y)
const
82 return m_comparator ? m_comparator->Compare(x, y) < 0 :
false;
96template<
class T,
typename =
void>
107 RTTI_INFO_TEMPLATE_CLASS(
ThisType, System::BaseTypesInfo<BaseType>);
127class ASPOSECPP_SHARED_CLASS DefaultComparer<T, typename std::enable_if<std::is_base_of<IComparable<T>, T>::value>::type>
128 :
public IComparer<T>
132 using BaseType = IComparer<T>;
134 using ThisType = DefaultComparer<T>;
138 RTTI_INFO_TEMPLATE_CLASS(ThisType, System::BaseTypesInfo<BaseType>);
145 virtual int Compare(
typename ThisType::args_type x,
typename ThisType::args_type y)
const override
147 return const_cast<T&
>(x).CompareTo(
const_cast<T&
>(y));
164 RTTI_INFO_TEMPLATE_CLASS(
ThisType, System::BaseTypesInfo<BaseType>);
177 return s_default_comparer;
Provides a base class for implementations of the System.Collections.Generic.IComparer generic interfa...
Definition: icomparer.h:155
Comparer()
Definition: icomparer.h:167
static SharedPtr< IComparer< T > > get_Default()
Returns a default sort order comparer for the type specified by the generic argument.
Definition: icomparer.h:174
Default comparator class. Uses operator < and operator == to compare values. Objects of this class sh...
Definition: icomparer.h:98
virtual int Compare(typename ThisType::args_type x, typename ThisType::args_type y) const override
Actual data comparison.
Definition: icomparer.h:114
Interface that compares two objects in greater-equal-less sense. Objects of this class should only be...
Definition: icomparer.h:21
const T & args_type
Comparison argument type.
Definition: icomparer.h:28
virtual int Compare(args_type x, args_type y) const =0
Comparison function.
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:51
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
Definition: db_command.h:9
std::enable_if_t<!std::is_floating_point< TA >::value &&!std::is_floating_point< TB >::value, int > Compare(const TA &a, const TB &b)
Compares two values.
Definition: primitive_types.h:113
Adapter to use IComparer within STL environment. Uses IComparer if set; otherwise,...
Definition: icomparer.h:45
ComparerAdapter()
Constructs adapter without any comparator available.
Definition: icomparer.h:47
ComparerAdapter(const SharedPtr< System::Collections::Generic::IComparer< T > > &comparator)
Constructs adapter.
Definition: icomparer.h:51
void set_Comparator(const SharedPtr< IComparer< T > > &comparator)
Sets comparator object.
Definition: icomparer.h:57
std::enable_if< detail::has_operator_less< Q >::value, bool >::type operator()(const Q &x, const Q &y) const
Comparison function for types with operator < available.
Definition: icomparer.h:68
std::enable_if<!detail::has_operator_less< Q >::value, bool >::type operator()(const Q &x, const Q &y) const
Comparison function for types with operator < not available.
Definition: icomparer.h:80