xtd 0.2.0
Loading...
Searching...
No Matches
xtd::collections::generic::iequality_comparer< type_t > Class Template Referenceabstract
Inheritance diagram for xtd::collections::generic::iequality_comparer< type_t >:
xtd::interface

Definition

template<typename type_t>
class xtd::collections::generic::iequality_comparer< type_t >

Defines methods to support the comparison of objects for equality.

Definition
template<typename type_t>
Defines methods to support the comparison of objects for equality.
Definition iequality_comparer.h:34
#define interface_
This keyword is use to represent an interface.
Definition interface.h:58
Header
#include <xtd/collections/iequality_comparer
Namespace
xtd::collections::generic
Library
xtd.core
Remarks
This interface allows the implementation of customized equality comparison for collections. That is, you can create your own definition of equality for type type_t, and specify that this definition be used with a collection type that accepts the xtd::collections::generic::iequality_comparer <type_t> generic interface. In the xtd framework, constructors of the xtd::collections::generic::dictionary <key_t, value_t> generic collection type accept this interface.
A default implementation of this interface is provided by the xtd::collections::generic::equality_comparer::default_equality_comparer property of the xtd::collections::generic::equality_comparer <type_t> generic class. The xtd::string_comparer class implements xtd::collections::generic::iequality_comparer <type_t> of type xtd::string.
This interface supports only equality comparisons. Customization of comparisons for sorting and ordering is provided by the xtd::collections::generic::icomparer <type_t> generic interface.
We recommend that you derive from the xtd::collections::generic::equality_comparer <type_t> class instead of implementing the xtd::collections::generic::iequality_comparer <type_t> interface, because the xtd::collections::generic::equality_comparer <type_t> class tests for equality using the xtd::iequatable::equals method instead of the xtd::object::equals method. This is consistent with the contains, index_of, last_index_of, and remove methods of the xtd::collections::generic::dictionary <key_t, value_t> class and other generic collections.

Public Methods

virtual bool equals (const type_t &x, const type_t &y) const noexcept=0
 Determines whether the specified objects are equal.
 
virtual xtd::size get_hash_code (const type_t &obj) const noexcept=0
 Returns a hash code for the specified object.
 

The documentation for this class was generated from the following file: