System.Generics.Defaults.IEqualityComparer
Delphi
IEqualityComparer<T> = interface
C++
template<typename T> __interface IEqualityComparer__1 : public System::IInterface
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
interface class |
public | System.Generics.Defaults.pas System.Generics.Defaults.hpp |
System.Generics.Defaults | System.Generics.Defaults |
Description
IEqualityComparer is the generic interface used to check the equality of two values.
IEqualityComparer is implemented by classes that need to support an equality comparison for two values of the same type. Generic collections require instances of classes that implement the IEqualityComparer interface in order to provide support for custom data types. For example, the Equals method is used by TList to compare whether a given value is present in the list. Aside from checking the equality of two values, IEqualityComparer also provides a GetHashCode method that is used to generate a hash code for any value. GetHashCode is extensively used in hash based map classes like TDictionary.
Note: We recommend that the TEqualityComparer class is used as the base for custom equality comparers instead of directly implementing the IEqualityComparer interface.
See Also
- System.Generics.Defaults.TEqualityComparer
- System.Generics.Defaults.TEqualityComparer.operator ()
- System.Generics.Defaults.TDelegatedEqualityComparer
- System.Generics.Defaults.IComparer
Code Examples