RFR: 8091429: ObservableList<E>#replaceRange(int from, int to, Collection<? extends E> col) [v2]
Marius Hanl
mhanl at openjdk.org
Mon Nov 3 10:44:48 UTC 2025
On Mon, 20 Oct 2025 05:02:12 GMT, John Hendrikx <jhendrikx at openjdk.org> wrote:
>> * `setAll(int, Collection)` and disallow it to change size
>> I think this doesn't carry its weight. It's just an explicit name for a narrow special case of a more general operation. However, if we're going to have a method with this signature, I suggest to not go for the narrow special case, but instead at least allow me to overlap the new list across the end of the existing list.
>>
>> * `replaceAll(int, int, Collection)`
>> We already have `List.replaceAll(UnaryOperator)`, which does something quite different (namely, replacing all elements with different elements). I think your proposed operation really is more like a `replaceRange`.
>
> @mstr2 I was hesitant to introduce another "new" method, and was looking to only overload `setAll`, but thinking it over a bit longer, I think if we want to offer this functionality in a free form way, we may as well just introduce a `replaceRange` method. I removed the `setAll` overload and renamed the range version to `replaceRange`.
I also like `replaceRange`. When I first checked the PR with the old name, I didn't really understand the intent of the function.
But now I understand it +1 from me. I've definitely needed this sometimes, especially for tables.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1937#discussion_r2486037952
More information about the openjfx-dev
mailing list