On Wed, 7 Oct 2020 09:38:40 GMT, Jeanette Winzenburg <faste...@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