On Tue, 8 Feb 2022 17:23:38 GMT, Stuart Marks <sma...@openjdk.org> wrote:
> PR for Sequenced Collections implementation. Note that `SortedMap::firstKey` and `SortedMap::lastKey` can now both have a default implementation that delegates to `SequencedMap::firstEntry` and `SequencedMap::lastEntry` respectively. src/java.base/share/classes/java/util/SequencedMap.java line 343: > 341: return new SeqEntrySet(); > 342: } > 343: } Missing trailing newline: Suggestion: } src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java line 554: > 552: public E removeLast() { > 553: synchronized (lock) { > 554: int size = getArray().length; Wrong indentation: Suggestion: int size = getArray().length; (this would be avoided if the JDK was using the more accessible tabs[^1]) [^1]: prettier/prettier#7475 src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java line 1734: > 1732: it = base.listIterator(base.size()); > 1733: } > 1734: } Storing the `size` in a field allows `Reversed::stream().estimateSize()` to match `Reversed::size()`: Suggestion: final ListIterator<E> it; final int size; DescendingIterator() { synchronized (lock) { size = base.size(); it = base.listIterator(size); } } src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java line 1803: > 1801: public Spliterator<E> spliterator() { > 1802: // TODO can probably improve this > 1803: return Spliterators.spliteratorUnknownSize(new > DescendingIterator(), 0); Suggestion: var it = new DescendingIterator(); return Spliterators.spliterator( it, it.size, Spliterator.IMMUTABLE | Spliterator.ORDERED); ------------- PR Comment: https://git.openjdk.org/jdk/pull/7387#issuecomment-1308200115 PR Review Comment: https://git.openjdk.org/jdk/pull/7387#discussion_r1139871748 PR Review Comment: https://git.openjdk.org/jdk/pull/7387#discussion_r1103614429 PR Review Comment: https://git.openjdk.org/jdk/pull/7387#discussion_r1103615024 PR Review Comment: https://git.openjdk.org/jdk/pull/7387#discussion_r1103615337