Improved Java Collection APIs

Dr Andrew John Hughes gnu_andrew at
Fri Nov 19 22:27:01 UTC 2010

On 19 November 2010 15:49, John Platts <john_platts at> wrote:
> Here are improvements that I really want to see to Java Collection APIs:
> - Addition of an equality comparator interface.
> - An wrapper that wraps a java.util.Comparator as a equality comparator.
> - Map and set classes that allow an equality comparator to be used instead of the equals() method or identity comparisons
> - New map and set interfaces that behave like the existing java.util.Map and java.util.Set interfaces. Unlike the contract of the java.util.Map and java.util.Set interfaces, the contract of the new map and set interfaces will not require that o1 be considered to be equal to o2 when o1 != o2 and o1.equals(o2) are both true. The new map and set interfaces will still require that o1 be considered equal to o2 whenever o1 == o2 is true.
> - New collection interfaces which define versions of search and removal operations that take an additional equality comparator argument. This enables search and removal operations to use an equality comparator to determine equality instead of relying on the equals method, an identity comparison, or the method.
> - Additional concurrent collection classes. Some of these classes will require synchronized modification, while supporting thread-safe unsynchronized access and concurrent iteration.
> - Support for collections synchronized on a read-write lock.
> - Addition of methods that iterates through the collection and invokes a callback. This is useful in cases where the callback object can be pre-allocated, since iteration using a java.util.Iterator object usually requires an iterator to be allocated each time an iteration takes place.

Feel free to post patches to add these features.  Then they can be
reviewed and maybe added to the JDK.
Andrew :-)

Free Java Software Engineer
Red Hat, Inc. (

Support Free Java!
Contribute to GNU Classpath and the OpenJDK

PGP Key: 94EFD9D8 (
Fingerprint: F8EF F1EA 401E 2E60 15FA  7927 142C 2591 94EF D9D8

More information about the core-libs-dev mailing list