RFR: 8266571: Sequenced Collections [v4]
Tagir F. Valeev
tvaleev at openjdk.org
Wed Mar 29 19:58:17 UTC 2023
On Wed, 29 Mar 2023 19:20:16 GMT, Rémi Forax <forax at openjdk.org> wrote:
>> src/java.base/share/classes/java/util/SequencedCollection.java line 107:
>>
>>> 105: */
>>> 106: default void addFirst(E e) {
>>> 107: throw new UnsupportedOperationException();
>>
>> Can this be defaulted to `this.reversed().addLast()` instead? If this throws uoe, the reversed should throw uoe as well; and the new default can simplify implementations by much as well.
>
> In the same spirit, `reversed()` should also have a default implementation equivalent to
>
> Collections.unmodifiableSequenceCollection(Arrays.asList(this.toArray())).reversed()
@forax but this would not be a view: changes in the underlying collection won't be reflected
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/7387#discussion_r1152416692
More information about the core-libs-dev
mailing list