RFR: 8266571: Sequenced Collections
Stuart Marks
smarks at openjdk.org
Tue Mar 21 03:46:58 UTC 2023
On Mon, 20 Mar 2023 23:52:11 GMT, Chen Liang <liach at openjdk.org> wrote:
>> PR for Sequenced Collections implementation.
>
> Just curious, does sequenced collection specify if add simulates addLast if addition supports custom ordering? I wish to have efficient reversible batch addition operations available, like ordered versions of addAll.
@liach
> Just curious, does sequenced collection specify if add simulates addLast if addition supports custom ordering? I wish to have efficient reversible batch addition operations available, like ordered versions of addAll.
Well the specs say what they say. For List, Deque, and LinkedHashSet, the add(E) method adds at the end. The addAll(Collection<E>) method is specified to honor the iteration order (really, encounter order) of the argument, and they all add at the end. (But Deque.addAll is specified in terms of addLast.) If some other existing collection defines add(E) to insert at some custom location, then addAll(Collection<E>) will need to specify what it does. Converting that collection to be sequenced doesn't necessarily change that.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/7387#issuecomment-1477240323
More information about the core-libs-dev
mailing list