Enhancements to Java Collections API
Jonathan Bluett-Duncan
jbluettduncan at gmail.com
Thu Dec 1 13:39:26 UTC 2016
Hi John,
I'm not sure about most of the suggestions you've made, especially the
Bidi* ones, but I understand that something like your suggestion for an
enhanced `Optional<V> getIfPresent(K key)` is (or was) being investigated
by Mr. Goetz himself and other people over at Project Valhalla
<http://openjdk.java.net/projects/valhalla/>. However, I can't seem to find
the archived email where it was announced...
Kind regards,
Jonathan
On 29 November 2016 at 20:13, John Platts <john_platts at hotmail.com> wrote:
> There are many features that are missing from the Java Collections API
> that should be added to the Java Collections API, including the following:
>
> * Bidirectional iterators for collections other than lists
> * New interfaces
> * BidiIterator - bidirectional iterator
> * extended by ListIterator interface
> * has hasPrevious() and previous() methods
> * ReverseIterable - reverse iterable
> * extends Iterable
> * extended by List, Deque, NavigableSet, and BidiIterable
> * has descendingIterator() and reverseForEach(Consumer<?
> super T>) methods
> * BidiIterable - bidirectional iterable
> * extends ReverseIterable
> * bidiIterator() returns a BidiIterator
> * bidiIteratorFromEnd() returns a BidiIterator that is
> positioned just past the last element in the collection
> * extended by List, BidiIterableCollection, BidiIterableSet,
> BidiIterableNavigableSet, and BidiIterableDeque
> * BidiIterableCollection - bidirectional iterable collection,
> extends BidiIterable and Collection
> * extended by List, BidiIterableSet,
> BidiIterableNavigableSet, and BidiIterableDeque
> * default implementation of bidiIterator() method added to
> the java.util.List interface that delegates to java.util.List.listIterator()
> * default implementation of bidiIteratorFromEnd() method
> added to the java.util.List interface that delegates to
> java.util.List.listIterator(size())
> * BidiIterableSet - bidirectional iterable set, extends
> BidiCollection and Set
> * BidiIterableNavigableSet - bidirectional iterable navigable
> iterable set, extends BidiIterableSet and NavigableSet
> * subSet(), headSet(), and tailSet() all return
> BidiIterableNavigableSet instances
> * BidiIterableDeque - bidirectional iterable deque, extends
> BidiCollection and Deque
> * BidiIterableMap - bidirectional iterable map
> * extends Map
> * keySet() and entrySet() return BidiIterableSet
> * values() returns BidiCollection
> * has reverseForEach(BiConsumer<? super K, ? super V>) method
> * BidiIterableNavigableMap - bidirectional iterable navigable map
> * extends BidiIterableMap and NavigableMap
> * keySet(), navigableKeySet(), and descendingKeySet() all
> return BidiNavigableSet
> * entrySet() returns BidiIterableSet
> * values() returns BidiCollection
> * subMap(), headMap() and tailMap() all return
> BidiIterableNavigableMap instances
> * BidiIterableDeque interface implemented on java.util.ArrayDeque,
> java.util.concurrent.ConcurrentLinkedDeque, java.util.concurrent.LinkedBlockingDeque,
> and java.util.LinkedList
> * BidiIterableSet interface implemented on java.util.LinkedHashSet,
> java.util.TreeSet, and java.util.concurrent.ConcurrentSkipListSet
> * BidiIterableNavigableSet interface implemented on
> java.util.TreeSet and java.util.concurrent.ConcurrentSkipListSet
> * BidiIterableMap interface implemented on java.util.LinkedHashMap,
> java.util.TreeMap, and java.util.concurrent.ConcurrentSkipListMap
> * BidiIterableNavigableMap interface implemented on
> java.util.TreeMap and java.util.concurrent.ConcurrentSkipListMap
> * Pollable interface
> * Extended by the Queue, Deque, and NavigableSet interfaces
> * Also implemented by the java.lang.ref.ReferenceQueue class
> * Contains the poll() method, which is already defined by the Queue
> and Deque interfaces
> * BidiPollable interface
> * Extends the Pollable interface
> * Extended by the Deque and NavigableSet interfaces
> * Contains the pollFirst() and pollLast() methods, which are
> already defined in both the Deque and NavigableSet interfaces
> * Navigable versions of java.util.EnumMap and java.util.EnumSet
> * Option #1: Implement the NavigableMap interface on top of
> java.util.EnumMap and java.util.EnumSet
> * Option #2: Implement separate java.util.NavigableEnumMap and
> java.util.NavigableEnumSet classes that behave similarly to the existing
> java.util.EnumMap and java.util.EnumSet classes, except that the
> java.util.NavigableEnumMap class has the functionality of the
> java.util.NavigableMap interface and that the java.util.NavigableEnumSet
> class has the functionality of the java.util.NavigableSet interface.
> * Under both options, the comparator() method of the navigable
> versions of EnumMap and EnumSet would return null
> * Navigable versions of EnumMap and EnumSet are possible since all
> enum types implement the Comparable interface
> * New enhanced map and set implementations
> * Support for hash maps and hash sets with custom hashcode function
> and custom equality predicate
> * Enhanced map interface that defines a Optional<V> getIfPresent(K
> key) method that returns the following:
> * A non-empty optional if the key is contained in the map and
> the value is non-null
> * An empty optional if the key is contained in the map, but the
> value is null
> * null if the map does not contain key
>
> Will these enhancements ever make it into Java SE 10 or Java SE 11?
>
> *
>
More information about the core-libs-dev
mailing list