RFR: 8253086: Optimization of removeAll and retainAll of ObservableListWrapper [v4]
Tom Schindl
tschindl at openjdk.java.net
Wed Oct 7 10:42:15 UTC 2020
On Wed, 7 Oct 2020 09:38:40 GMT, Jeanette Winzenburg <fastegal at openjdk.org> wrote:
>> The error occurs as specified in getSelectedItems(). It seems to be correct to write the following
>>
>> `listView.getItems().removeAll(new HashSet<>(selectedItems))
>> `
>>
>> (or ArrayList)
>>
>> It could be interpreted that the intention was to mitigate the side effects associated with the getSelectedItems()
>> specification.
>> The use of BitSet should be avoided when the list is large, as it is not a sparse implementation and therefore wastes a
>> lot of memory. For example, when removing the last item in the list.
>> `BitSet bs = new BitSet(c.size());
>> `
>> The previous change was an incorrect initialization size for BitSet.
>
>>
>>
>> The error occurs as specified in getSelectedItems().
>
> no, both spec and implementation (at least as far as its relation to this issue) is correct.
>
>> It seems to be correct to write the following
>>
>> `listView.getItems().removeAll(new HashSet<>(selectedItems)) `
>>
>> (or ArrayList)
>>
>
> asking client code to adopt to changes in the framework is not an option
>
>> It could be interpreted that the intention was to mitigate the side effects associated with the getSelectedItems()
>> specification.
>
> no side-effects, nothing mitigated, : it's a deliberate, full-fledged support of source lists that change on removing
> items from the target list
>> The use of BitSet should be avoided when the list is large, as it is not a sparse implementation and therefore wastes a
>> lot of memory. For example, when removing the last item in the list.
>> `BitSet bs = new BitSet(c.size()); `
>> The previous change was an incorrect initialization size for BitSet.
>
> feel free to suggest another (working without requiring changes to client code) two-pass approach in remove/retainAll.
did anyone look into Java-Collection-Frameworks (ArrayList and friends or Eclipse-Collections) how they handle this
situation effeciently?
-------------
PR: https://git.openjdk.java.net/jfx/pull/305
More information about the openjfx-dev
mailing list