List of usage examples for com.google.common.collect Iterators concat
public static <T> Iterator<T> concat(Iterator<? extends T> a, Iterator<? extends T> b, Iterator<? extends T> c)
From source file:org.sonar.pickbasic.tree.impl.statement.ReadStatementsSingleLineTreeImpl.java
@Override public Iterator<Tree> childrenIterator() { return Iterators.concat( Iterators.forArray(readKeyword, expression, fromClausePick, settingClause, lockStatementSingleLine), thenClauseSingleLine.iterator(), Iterators.singletonIterator(semicolonToken)); }
From source file:org.datacleaner.spark.utils.HadoopJobExecutionUtils.java
private static void addJobConfigurations(final AnalysisJob job, final Set<Datastore> datastores, final Set<Dictionary> dictionaries, final Set<StringPattern> stringPatterns, final Set<SynonymCatalog> synonymCatalogs) { datastores.add(job.getDatastore());/* w w w . j av a2 s. c o m*/ Iterators.concat(job.getAnalyzerJobs().iterator(), job.getFilterJobs().iterator(), job.getTransformerJobs().iterator()).forEachRemaining(component -> { component.getDescriptor().getConfiguredProperties().forEach(descriptor -> { final Class<?> type = descriptor.getBaseType(); if (type == Datastore.class) { datastores.addAll(getProperties(component, descriptor)); } else if (type == Dictionary.class) { dictionaries.addAll(getProperties(component, descriptor)); } else if (type == StringPattern.class) { stringPatterns.addAll(getProperties(component, descriptor)); } else if (type == SynonymCatalog.class) { synonymCatalogs.addAll(getProperties(component, descriptor)); } }); for (final OutputDataStreamJob outputDataStreamJob : component.getOutputDataStreamJobs()) { addJobConfigurations(outputDataStreamJob.getJob(), datastores, dictionaries, stringPatterns, synonymCatalogs); } }); }
From source file:qdg.view.MixedGraphAsBiDiGraph.java
@Override public Iterator<Edge> getInArcIterator(Node node) { Iterator<Edge> forwardArcs = Iterators.transform(g.getInArcIterator(node), forwardEdge); Iterator<Edge> backwardArcs = Iterators.transform(g.getOutArcIterator(node), backwardEdge); Iterator<Edge> uEdges = new InArcIterator(node); return Iterators.concat(forwardArcs, backwardArcs, uEdges); }
From source file:qdg.view.MixedGraphAsDiGraph.java
@Override public Iterator<Edge> getIncidentArcIterator(Node node) { Iterator<Edge> arcs = Iterators.transform(g.getIncidentArcIterator(node), forwardEdge); Iterator<Edge> forwardUEdges = Iterators.transform(g.getIncidentEdgeIterator(node), forwardEdge); Iterator<Edge> backwardUEdges = Iterators.transform(g.getIncidentUEdgeIterator(node), backwardEdge); return Iterators.concat(arcs, forwardUEdges, backwardUEdges); }
From source file:org.eclipse.tracecompass.common.core.collect.BufferedBlockingQueue.java
/** * Instantiate an iterator on the complete data structure. This includes the * inner queue as well as the input and output buffers. * * If concurrent insertions happen while the iterator is being used, it is * possible for an element that was actually in the queue when the call was * made to have been removed by the {@link #take} method in the meantime. * However, this iterator guarantees that each element is either inside the * queue OR was removed by the {@link #take} method. No element should * "fall in the cracks".// www .j a v a 2 s.c o m * * @return An iterator over the whole buffered queue */ @Override public Iterator<T> iterator() { /* * Note that the iterators of ArrayBlockingQueue and * ConcurrentLinkedDeque are thread-safe, which allows iterating on them * while they are being modified without having to lock the accesses. * * To make sure we do not "miss" any elements, we need to look through * the input buffer first, then the inner queue, then the output buffer. */ Iterator<T> inputIterator = fInputBuffer.iterator(); Iterator<T> queueIterator = Iterables.concat(fInnerQueue).iterator(); Iterator<T> outputIterator = fOutputBuffer.iterator(); return checkNotNull(Iterators.concat(inputIterator, queueIterator, outputIterator)); }
From source file:grakn.core.graql.reasoner.query.ReasonerAtomicQuery.java
@Override public Iterator<ResolutionState> queryStateIterator(QueryStateBase parent, Set<ReasonerAtomicQuery> visitedSubGoals) { Pair<Stream<ConceptMap>, MultiUnifier> cacheEntry = tx().queryCache().getAnswerStreamWithUnifier(this); Iterator<AnswerState> dbIterator = cacheEntry.getKey() .map(a -> a.explain(a.explanation().setPattern(this.getPattern()))) .map(ans -> new AnswerState(ans, parent.getUnifier(), parent)).iterator(); Iterator<ResolutionState> dbCompletionIterator = Iterators .singletonIterator(new CacheCompletionState(this, new ConceptMap(), null)); Iterator<ResolutionState> subGoalIterator; boolean visited = visitedSubGoals.contains(this); //if this is ground and exists in the db then do not resolve further boolean doNotResolveFurther = visited || tx().queryCache().isComplete(this) || (this.isGround() && dbIterator.hasNext()); if (doNotResolveFurther) { subGoalIterator = Collections.emptyIterator(); } else {//from w w w . j av a2 s. c o m subGoalIterator = getRuleStream().map(rulePair -> rulePair.getKey().subGoal(this.getAtom(), rulePair.getValue(), parent, visitedSubGoals)).iterator(); } if (!visited) visitedSubGoals.add(this); return Iterators.concat(dbIterator, dbCompletionIterator, subGoalIterator); }