List of usage examples for com.google.common.collect Queues newArrayDeque
public static <E> ArrayDeque<E> newArrayDeque()
From source file:org.terasology.rendering.nui.editor.utils.NUIEditorNodeUtils.java
private static Deque<JsonTree> getPathToRoot(JsonTree node) { Deque<JsonTree> pathToRoot = Queues.newArrayDeque(); // Create a stack with the root node at the top and the argument at the bottom. JsonTree currentNode = node;/* w w w. j a va 2 s .c om*/ while (!currentNode.isRoot()) { pathToRoot.push(currentNode); currentNode = (JsonTree) currentNode.getParent(); } pathToRoot.push(currentNode); return pathToRoot; }
From source file:org.eclipse.incquery.tooling.localsearch.ui.debugger.LocalSearchDebugger.java
@Override public void patternMatchingStarted(final LocalSearchMatcher lsMatcher) { // If a new debug session is starting, obtain the view if (startHandlerCalled) { startHandlerCalled = false;/*from w w w . jav a2 s .c o m*/ // Syncexec is assumed to be needed because of the showView call PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override public void run() { try { localSearchDebugView = (LocalSearchDebugView) PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getActivePage().showView(LocalSearchDebugView.ID); BreakPointListener breakPointListener = new BreakPointListener(LocalSearchDebugger.this); TreeViewer operationListViewer = localSearchDebugView.getOperationListViewer(); operationListViewer.addDoubleClickListener(breakPointListener); localSearchDebugView.setDebugger(LocalSearchDebugger.this); // TODO make sure that the initialization is done for every part so that restart is possible runningMatchers = Queues.newArrayDeque(); runningExecutors = Queues.newArrayDeque(); String simpleQueryName = getSimpleQueryName(lsMatcher.getQuerySpecification()); TableViewer matchesViewer = localSearchDebugView.getMatchesViewer(simpleQueryName); @SuppressWarnings("unchecked") List<MatchingFrame> storedFrames = (List<MatchingFrame>) matchesViewer .getData(LocalSearchDebugView.VIEWER_KEY); storedFrames.clear(); localSearchDebugView.refreshView(); } catch (PartInitException e) { IncQueryLoggingUtil.getDefaultLogger().log(Level.ERROR, "A part init exception occured while executing pattern matcher started handler" + e.getMessage(), e); } } }); } runningMatchers.push(lsMatcher); }
From source file:com.google.gwt.resources.gss.PermutationsCollector.java
@Override public void runPass() { childrenStack = Queues.newArrayDeque(); permutationAxesListBuilder = new Builder<String>(); delegate.startVisit(this); }
From source file:com.github.fge.jsonschema.processors.validation.ValidationStack.java
/** * Push one validation context onto the stack * * <p>A {@link FullData} instance contains all the necessary information to * decide what is to be done here. The most important piece of information * is the pointer into the instance being analyzed:</p> * * <ul>//from w ww . j av a2 s . c o m * <li>if it is the same pointer, then we attempt to append the schema * URI into the validation element; if there is a duplicate, this is a * validation loop, throw an exception;</li> * <li>otherwise, a new element is created with the new instance pointer * and the schema URI.</li> * </ul> * * @param data the validation data * @throws ProcessingException instance pointer is unchanged, and an * attempt is made to validate it using the exact same schema * * @see #pop() */ void push(final FullData data) throws ProcessingException { final JsonPointer ptr = data.getInstance().getPointer(); final SchemaURI schemaURI = new SchemaURI(data.getSchema()); if (ptr.equals(pointer)) { if (schemaURIs.contains(schemaURI)) throw new ProcessingException(validationLoopMessage(data)); schemaURIs.addLast(schemaURI); return; } validationQueue.addLast(new Element(pointer, schemaURIs)); pointer = ptr; schemaURIs = Queues.newArrayDeque(); schemaURIs.addLast(schemaURI); }
From source file:org.asoem.greyfish.utils.space.cluster.DBSCAN.java
private Optional<DBSCANCluster<T>> tryCluster(final T origin, final Collection<T> objects, final Map<T, PointStatus> objectStatusMap) { final List<T> clusterObjects = new ArrayList<>(); final Queue<T> seeds = Queues.newArrayDeque(); final PointStatus originStatus = objectStatusMap.get(origin); assert originStatus != null; assert originStatus.equals(PointStatus.UNKNOWN); objectStatusMap.put(origin, PointStatus.SEED); seeds.offer(origin);//w w w . j a v a2 s .c o m while (!seeds.isEmpty()) { final T seed = seeds.poll(); assert seed != null; final Collection<T> currentNeighbors = neighborSearch.filterNeighbors(objects, seed, epsilon); if (currentNeighbors.size() >= minPts) { for (T neighbor : currentNeighbors) { final PointStatus neighborStatus = objectStatusMap.get(neighbor); assert neighborStatus != null; if (neighborStatus.equals(PointStatus.NOISE)) { clusterObjects.add(neighbor); objectStatusMap.put(neighbor, PointStatus.DENSITY_REACHABLE); } else if (neighborStatus.equals(PointStatus.UNKNOWN)) { seeds.offer(neighbor); objectStatusMap.put(neighbor, PointStatus.SEED); } } objectStatusMap.put(seed, PointStatus.CORE_OBJECT); } else { objectStatusMap.put(seed, PointStatus.DENSITY_REACHABLE); } clusterObjects.add(seed); } if (clusterObjects.size() == 1) { objectStatusMap.put(origin, PointStatus.NOISE); return Optional.absent(); } else { return Optional.of(DBSCANCluster.create(clusterObjects)); } }
From source file:org.eclipse.viatra.query.tooling.localsearch.ui.debugger.LocalSearchDebugger.java
@Override public void patternMatchingStarted(final LocalSearchMatcher lsMatcher) { if (isDisposed) { return;//from w w w. java 2 s . c o m } // If a new debug session is starting, obtain the view if (startHandlerCalled) { startHandlerCalled = false; // Syncexec is assumed to be needed because of the showView call PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override public void run() { try { localSearchDebugView = (LocalSearchDebugView) PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getActivePage().showView(LocalSearchDebugView.ID); BreakPointListener breakPointListener = new BreakPointListener(LocalSearchDebugger.this); TreeViewer operationListViewer = localSearchDebugView.getOperationListViewer(); operationListViewer.addDoubleClickListener(breakPointListener); localSearchDebugView.setDebugger(LocalSearchDebugger.this); // TODO make sure that the initialization is done for every part so that restart is possible runningMatchers = Queues.newArrayDeque(); runningExecutors = Queues.newArrayDeque(); String simpleQueryName = getSimpleQueryName(lsMatcher.getQuerySpecification()); TableViewer matchesViewer = localSearchDebugView.getMatchesViewer(simpleQueryName); @SuppressWarnings("unchecked") List<MatchingFrame> storedFrames = (List<MatchingFrame>) matchesViewer .getData(LocalSearchDebugView.VIEWER_KEY); storedFrames.clear(); localSearchDebugView.refreshView(); } catch (PartInitException e) { ViatraQueryLoggingUtil.getDefaultLogger().log(Level.ERROR, "A part init exception occured while executing pattern matcher started handler" + e.getMessage(), e); } } }); } runningMatchers.push(lsMatcher); }
From source file:com.google.cloud.dataflow.sdk.util.common.ReflectHelpers.java
/** * Returns all interfaces of the given clazz. * @param clazz//from w ww . j av a 2s .c om * @return */ public static FluentIterable<Class<?>> getClosureOfInterfaces(Class<?> clazz) { checkNotNull(clazz); Queue<Class<?>> interfacesToProcess = Queues.newArrayDeque(); Collections.addAll(interfacesToProcess, clazz.getInterfaces()); LinkedHashSet<Class<?>> interfaces = new LinkedHashSet<>(); while (!interfacesToProcess.isEmpty()) { Class<?> current = interfacesToProcess.remove(); if (interfaces.add(current)) { Collections.addAll(interfacesToProcess, current.getInterfaces()); } } return FluentIterable.from(interfaces); }
From source file:org.decojer.cavaj.utils.SwitchTypes.java
/** * Is used for JDK-Bytecode mode string-switches. Execute switch case BB to create the case * value map: index to string.// w w w .j av a 2 s.c om * * @param caseBb * case BB * @param indexReg * index register * @param str * string * @param defaultCase * default case * @param index2string * case value map: index to string * @return {@code true} - success */ private static boolean executeBbStringIndex(@Nonnull final BB caseBb, final int indexReg, @Nonnull final String str, @Nonnull final BB defaultCase, @Nonnull final Map<Integer, String> index2string) { assert defaultCase != null; // prevent warning for now, later check more final Deque<Object> stack = Queues.newArrayDeque(); for (int i = 0; i < caseBb.getOps(); ++i) { final Op op = caseBb.getOp(i); switch (op.getOptype()) { case PUSH: stack.push(((PUSH) op).getValue()); break; case STORE: if (((STORE) op).getReg() != indexReg) { return false; } final Object index = stack.pop(); if (!(index instanceof Integer)) { return false; } index2string.put((Integer) index, str); return true; default: return false; } } return false; }
From source file:org.terasology.engine.subsystem.awt.devices.AwtMouseDevice.java
@Override public Queue<InputAction> getInputQueue() { Queue<InputAction> oldInputQueue; synchronized (inputQueueLock) { oldInputQueue = inputQueue;/* w ww. j a v a 2s . c om*/ inputQueue = Queues.newArrayDeque(); } return oldInputQueue; }
From source file:com.puppycrawl.tools.checkstyle.checks.coding.DeclarationOrderCheck.java
@Override public void beginTree(DetailAST rootAST) { scopeStates = Queues.newArrayDeque(); classFieldNames = Sets.newHashSet(); }