RFR: 8266571: Sequenced Collections
Chen Liang
liach at openjdk.org
Mon Mar 20 23:44:54 UTC 2023
On Tue, 8 Feb 2022 17:23:38 GMT, Stuart Marks <smarks at openjdk.org> wrote:
> PR for Sequenced Collections implementation.
Since we added reversal to deque, can we add notes to a few Collections APIs like `Collections::asLifoQueue` about this newer alternative? Also on using `reverse` on the list view than actually reversing a whole list.
In addition, the new methods should have `@since 20` tags, such as on `LinkedList::reversed`, `SortedSet::addFirst`. Other similar methods are version-tagged, like `Collection::spliterator` or `Method::getParameterCount`.
Is there a particular reason we define poll (null on empty) in SequencedMap but remove (NSEE on empty) in SequencedCollection?
I understand that SequencedCollection doesn't want to be null-ambiguous, and map entries are non-null so poll there is not ambiguous. But I still think using remove for both look more consistent.
Just curious, will sequenced collections be delivered directly or will it incubate/preview first?
src/java.base/share/classes/java/util/Collections.java line 1211:
> 1209: * @param s the set for which an unmodifiable view is to be returned.
> 1210: * @return an unmodifiable view of the specified set.
> 1211: * @since 20
Extraneous and wrong
Suggestion:
src/java.base/share/classes/java/util/Collections.java line 1248:
> 1246: * @param s the set for which an unmodifiable view is to be returned.
> 1247: * @return an unmodifiable view of the specified sequenced set.
> 1248: */
Suggestion:
* @since 20
*/
The last one was misplaced.
src/java.base/share/classes/java/util/Collections.java line 5980:
> 5978: * an eviction policy, which is not possible with a {@code LinkedHashSet}.
> 5979: *
> 5980: * <pre>{@code
Can we upgrade this to a snippet?
src/java.base/share/classes/java/util/SortedSet.java line 303:
> 301: * @since 20
> 302: */
> 303: default E removeFirst() {
Should removeFirst/removeLast be overridden in NavigableSet with a new default implementation like:
if (this.isEmpty()) {
throw new NoSuchElementException();
}
return this.pollFirst();
which is probably slightly more efficient?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/7387#issuecomment-1253174627
PR Comment: https://git.openjdk.org/jdk/pull/7387#issuecomment-1302239328
PR Comment: https://git.openjdk.org/jdk/pull/7387#issuecomment-1475519496
PR Review Comment: https://git.openjdk.org/jdk/pull/7387#discussion_r1012461962
PR Review Comment: https://git.openjdk.org/jdk/pull/7387#discussion_r1012462289
PR Review Comment: https://git.openjdk.org/jdk/pull/7387#discussion_r1139631921
PR Review Comment: https://git.openjdk.org/jdk/pull/7387#discussion_r1013372259
More information about the core-libs-dev
mailing list