From ac7b954fc5abfa213361876a2c0ac6717152c4d1 Mon Sep 17 00:00:00 2001 From: Marko Luukkainen Date: Fri, 12 Mar 2021 16:44:44 +0200 Subject: [PATCH] Fix CollectionUtils.unique (removed unique items) gitlab #679 Change-Id: I4c297a9a3ed258e16b2cd3663b63115748c6ae61 --- .../utils/datastructures/collections/CollectionUtils.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/collections/CollectionUtils.java b/bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/collections/CollectionUtils.java index 720d0193a..8d962a1a3 100644 --- a/bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/collections/CollectionUtils.java +++ b/bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/collections/CollectionUtils.java @@ -217,15 +217,13 @@ public final class CollectionUtils { * Remove elements that appear more than once. Keep order otherwise. * @param list to be pruned */ - public static void unique(List list) { - int c = list.size(); - int i = c-1; + public static void unique(List list) { + int i = list.size()-1; while (i>0) { Object o = list.get(i); int index = list.indexOf(o); - if (index>=0) { + if (index>=0 && index < i) { list.remove(index); - c--; i--; } else { i--; -- 2.47.1