Progress.Collections.IEqualityComparer<T> interface
- Last Updated: March 15, 2024
- 1 minute read
- OpenEdge
- Version 12.8
- Documentation
The Progress.Collections.IEqualityComparer<T> interface provides an
alternate implementation of HashCode() and
Equals() to the map collection. It is used in situations where
modifying a class is not possible, or the default implementations of
HashCode() and/or Equals() of an object have
undesirable behavior.
Public Properties
The interface has no public properties.
Public Methods
| Equals( ) method (Map Collections) | HashCode( ) method (IHashable) |
Notes
- Two objects that are considered the same, must return the same hash code. If
obj1:Equals(obj2)returns TRUE, thenobj2:Equals(obj1)must also return TRUE, andobj1:HashCode()must be the same asobj2:HashCode(). That implies that the same values should be used when identifying equality and generating the hash code. Note that different objects may return the same hash code. - The
HashCode()andEquals()methods should not return the Unknown value (?). If they do, an ERROR is raised. - A user-defined class must implement the
IEqualityComparerinterface to be able to work with aHashMapcollection that needs to use a custom equality comparer. In order to implement this interface, the “equality comparer” user-defined class will need to define the type argument as a specific class type, making it a comparer object for a specific type (or types that inherit that type).
Example
|