From c3e27396c62f191b4343df151e5a86bfa63a32f3 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Tue, 5 Oct 2021 00:36:47 +0200 Subject: chore: change package name --- .../viatra/solver/data/util/CollectionsUtil.java | 72 ---------------------- 1 file changed, 72 deletions(-) delete mode 100644 store/src/main/java/org/eclipse/viatra/solver/data/util/CollectionsUtil.java (limited to 'store/src/main/java/org/eclipse/viatra/solver/data/util/CollectionsUtil.java') diff --git a/store/src/main/java/org/eclipse/viatra/solver/data/util/CollectionsUtil.java b/store/src/main/java/org/eclipse/viatra/solver/data/util/CollectionsUtil.java deleted file mode 100644 index 21b0a9df..00000000 --- a/store/src/main/java/org/eclipse/viatra/solver/data/util/CollectionsUtil.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.eclipse.viatra.solver.data.util; - -import java.util.Iterator; -import java.util.NoSuchElementException; -import java.util.function.Function; -import java.util.function.Predicate; - -public final class CollectionsUtil { - private CollectionsUtil() { - throw new UnsupportedOperationException(); - } - - public static Iterator map(Iterator source, Function transformation) { - return new Iterator() { - - @Override - public boolean hasNext() { - return source.hasNext(); - } - - @Override - public T next() { - return transformation.apply(source.next()); - } - }; - } - - public static Iterable map(Iterable source, Function transformation) { - return (()->map(source.iterator(),transformation)); - } - - public static Iterator filter(Iterator source, Predicate condition) { - return new Iterator() { - T internalNext = move(); - boolean internalHasNext; - - private T move() { - internalHasNext = source.hasNext(); - if(internalHasNext) { - internalNext = source.next(); - } - while(internalHasNext && !condition.test(internalNext)) { - internalHasNext = source.hasNext(); - if(internalHasNext) { - internalNext = source.next(); - } - } - return internalNext; - } - - @Override - public boolean hasNext() { - return internalHasNext; - } - - @Override - public T next() { - if(!internalHasNext) { - throw new NoSuchElementException(); - } else { - T result = internalNext; - move(); - return result; - } - } - }; - } - - public static Iterable filter(Iterable source, Predicate condition) { - return (()->filter(source.iterator(),condition)); - } -} -- cgit v1.2.3-70-g09d2