Integrated: 8091429: ObservableList<E>#replaceRange(int from, int to, Collection<? extends E> col)
John Hendrikx
jhendrikx at openjdk.org
Sat Nov 8 22:19:18 UTC 2025
On Wed, 15 Oct 2025 03:40:24 GMT, John Hendrikx <jhendrikx at openjdk.org> wrote:
> This PR implements a new default method on `ObservableList` to be able to replace elements within a specified range.
>
> Justification for this change is to allow an `ObservableList` to be bulk modified resulting in a single `ListChangeListener` call back. In this way the callbacks don't observe the list changing its size from S to S-X back to S again(*). Currently the only way to bulk replace a range of items is to remove X items then add X items, resulting in two listener callbacks in between which the size of the list can be observed to change.
>
> The other alternative is to call `set` individually for each item, which results in many change notifications.
>
> With the addition of this PR, and the changes in `ModifiableObservableListBase`, replacing a range of items becomes a single change callback.
>
> (*) The list may indeed change size still as plain `List` does not have `setAll` operations; size listeners may observe this, but it will no longer be observable from a `ListChangeListener` due to multiple separate callbacks.
This pull request has now been integrated.
Changeset: b76090df
Author: John Hendrikx <jhendrikx at openjdk.org>
URL: https://git.openjdk.org/jfx/commit/b76090dfe6821efcbd86230e1b24ad7f455c7a41
Stats: 135 lines in 3 files changed: 134 ins; 1 del; 0 mod
8091429: ObservableList<E>#replaceRange(int from, int to, Collection<? extends E> col)
Reviewed-by: mstrauss, kcr
-------------
PR: https://git.openjdk.org/jfx/pull/1937
More information about the openjfx-dev
mailing list