List of usage examples for java.util Queue forEach
default void forEach(Consumer<? super T> action)
From source file:com.wrmsr.wava.basic.BasicLoopInfo.java
public static Set<Name> getLoopContents(Name loop, Multimap<Name, Name> inputs, Multimap<Name, Name> backEdges) { Set<Name> seen = new HashSet<>(); seen.add(loop);//from w w w. j a va 2s .c om Queue<Name> queue = new LinkedList<>(); inputs.get(loop).stream().filter(n -> !n.equals(loop) && backEdges.containsEntry(loop, n)) .forEach(queue::add); queue.forEach(seen::add); while (!queue.isEmpty()) { Name cur = queue.poll(); inputs.get(cur).stream().filter(input -> !seen.contains(input)).forEach(input -> { seen.add(input); queue.add(input); }); } return seen; }
From source file:org.jamocha.Jamocha.java
public static void main(final String[] args) { final Jamocha jamocha = new Jamocha(); jamocha.loadParser(System.in); while (true) { try {/* www .j av a 2 s . c o m*/ System.out.print("SFP> "); final Pair<Queue<Warning>, String> parserReturn = jamocha.parse(); if (null == parserReturn) System.exit(0); final String expression = parserReturn.getRight(); if (null != expression) { log.info(expression); } final Queue<Warning> warnings = parserReturn.getLeft(); warnings.forEach(w -> log.warn("Warning: " + w.getMessage())); } catch (final ParseException e) { log.catching(e); return; } catch (final Throwable e) { log.catching(e); } } }