JDK-6321875 : (coll) no equality-function parameter for sets & maps...
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util:collections
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2005-09-09
  • Updated: 2012-10-08
  • Resolved: 2005-09-09
Related Reports
Duplicate :  
Description
A DESCRIPTION OF THE REQUEST :
Java sets & maps currently don't take "equality tests" as arguments to their constructors.  We do this sort of thing in Scheme and ML all the time, and it's really useful.


JUSTIFICATION :
I am working on a project where this would come in handy.  As java is now, I need to create different kinds of objects that all contain the same information but which implement different equals() functions.  I know that inheritance solves this problem, but it's a little overkill when I only need the different behavior for a single hashtable.

Comments
EVALUATION We've considered adding "equality functions", as the submitter suggests. One difficult thing is to come up with a good name for these. "Equator", "Equalizer", and "Equivocator" come to mind, but might not make it into the official javadoc. I think we have pre-existing rfe's. Let's see... 4269596: (coll) Wanted: A way to customize the equals/hashCode algorithm 4771660: (coll) Comparator, Comparable, Identity, and Equivalence 6270657: (coll) remove/contains and "Equators" other than .equals() I'll close this as a dup of 4269596. It's very difficult to find a good middle ground in collection class design between excessive complexity and insufficient functionality.
09-09-2005