Skip to content

Commit

Permalink
We can now use Java 8 streams to filter an iterator - more verbose.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmay authored and egonw committed Jan 1, 2022
1 parent d52ebde commit 314cd4b
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Iterators;
import org.openscience.cdk.graph.GraphUtil;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
Expand All @@ -40,6 +39,7 @@
import java.util.Map;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.StreamSupport;

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

@Override
public Iterator<int[]> iterator() {
return Iterators.filter(iterable.iterator(), new UniqueAtomMatches()::test);
return StreamSupport.stream(iterable.spliterator(), false)
.filter(new UniqueAtomMatches()).iterator();
}
});
}
Expand All @@ -302,7 +303,8 @@ public Mappings uniqueBonds() {

@Override
public Iterator<int[]> iterator() {
return Iterators.filter(iterable.iterator(), new UniqueBondMatches(g)::test);
return StreamSupport.stream(iterable.spliterator(), false)
.filter(new UniqueBondMatches(g)).iterator();
}
});
}
Expand Down

0 comments on commit 314cd4b

Please sign in to comment.