8266571: Sequenced Collections

Reviewed-by: alanb
This commit is contained in:
Stuart Marks 2023-04-25 15:19:08 +00:00
parent bad6aa68e4
commit 17ce0976e4
42 changed files with 7060 additions and 150 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -73,6 +73,10 @@ package java.util;
* exception for its correctness: <i>the fail-fast behavior of iterators
* should be used only to detect bugs.</i>
*
* <p>The {@link #addFirst addFirst} and {@link #addLast addLast} methods of this class
* throw {@code UnsupportedOperationException}. The encounter order of elements is determined
* by the comparison method; therefore, explicit positioning is not supported.
*
* <p>This class is a member of the
* <a href="{@docRoot}/java.base/java/util/package-summary.html#CollectionsFramework">
* Java Collections Framework</a>.
@ -460,6 +464,30 @@ public class TreeSet<E> extends AbstractSet<E>
return (e == null) ? null : e.getKey();
}
/**
* Throws {@code UnsupportedOperationException}. The encounter order induced by this
* set's comparison method determines the position of elements, so explicit positioning
* is not supported.
*
* @throws UnsupportedOperationException always
* @since 21
*/
public void addFirst(E e) {
throw new UnsupportedOperationException();
}
/**
* Throws {@code UnsupportedOperationException}. The encounter order induced by this
* set's comparison method determines the position of elements, so explicit positioning
* is not supported.
*
* @throws UnsupportedOperationException always
* @since 21
*/
public void addLast(E e) {
throw new UnsupportedOperationException();
}
/**
* Returns a shallow copy of this {@code TreeSet} instance. (The elements
* themselves are not cloned.)