org.openstreetmap.josm.data.osm
Interface Hash<K,T>

All Known Implementing Classes:
DataSet.IdHash, DuplicateNode.NodeHash

public interface Hash<K,T>

An interface allowing injection of hashcode and equality implementation based on some inner state of an object for a set. It supports two type parameters to implement effective foreign key implementation inside (@link Storage}, but for basic use, both type parameters are the same. For use cases, see Storage.


Method Summary
 boolean equals(K k, T t)
          Compare two instances for semantic or lookup equality.
 int getHashCode(K k)
          Get hashcode for given instance, based on some inner state of the instance.
 

Method Detail

getHashCode

int getHashCode(K k)
Get hashcode for given instance, based on some inner state of the instance. The returned hashcode should remain constant over the time, so it should be based on some instance invariant.

Parameters:
k - the object to compute hashcode for
Returns:
computed hashcode

equals

boolean equals(K k,
               T t)
Compare two instances for semantic or lookup equality. For use cases where it compares different types, refer to Storage.

Parameters:
k - the object to compare
t - the object to compare
Returns:
true if the objects are semantically equivalent, or if k uniquely identifies t in given class.


JOSM