Skip to content

Commit 314cd4b

Browse files
johnmayegonw
authored andcommitted
We can now use Java 8 streams to filter an iterator - more verbose.
1 parent d52ebde commit 314cd4b

File tree

1 file changed

+5
-3
lines changed
  • base/isomorphism/src/main/java/org/openscience/cdk/isomorphism

1 file changed

+5
-3
lines changed

base/isomorphism/src/main/java/org/openscience/cdk/isomorphism/Mappings.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import com.google.common.collect.FluentIterable;
2828
import com.google.common.collect.ImmutableMap;
2929
import com.google.common.collect.Iterables;
30-
import com.google.common.collect.Iterators;
3130
import org.openscience.cdk.graph.GraphUtil;
3231
import org.openscience.cdk.interfaces.IAtom;
3332
import org.openscience.cdk.interfaces.IAtomContainer;
@@ -40,6 +39,7 @@
4039
import java.util.Map;
4140
import java.util.function.Function;
4241
import java.util.function.Predicate;
42+
import java.util.stream.StreamSupport;
4343

4444
/**
4545
* A fluent interface for handling (sub)-graph mappings from a query to a target
@@ -282,7 +282,8 @@ public Mappings uniqueAtoms() {
282282

283283
@Override
284284
public Iterator<int[]> iterator() {
285-
return Iterators.filter(iterable.iterator(), new UniqueAtomMatches()::test);
285+
return StreamSupport.stream(iterable.spliterator(), false)
286+
.filter(new UniqueAtomMatches()).iterator();
286287
}
287288
});
288289
}
@@ -302,7 +303,8 @@ public Mappings uniqueBonds() {
302303

303304
@Override
304305
public Iterator<int[]> iterator() {
305-
return Iterators.filter(iterable.iterator(), new UniqueBondMatches(g)::test);
306+
return StreamSupport.stream(iterable.spliterator(), false)
307+
.filter(new UniqueBondMatches(g)).iterator();
306308
}
307309
});
308310
}

0 commit comments

Comments
 (0)