Refine search
@Override public boolean hasNext() { if (geometriesDeque.isEmpty()) { return false; } while (geometriesDeque.peek() instanceof OGCConcreteGeometryCollection) { OGCGeometryCollection collection = (OGCGeometryCollection) geometriesDeque.pop(); for (int i = 0; i < collection.numGeometries(); i++) { geometriesDeque.push(collection.geometryN(i)); } } return !geometriesDeque.isEmpty(); }
/** * Stores name of currently parsed view in a stack so it can be determined * during {@code prepare()}. * * @param parsingView * {@code true} to store one more name, {@code false} to remove it * from stack * @param viewName * name of the view */ public void setParsingCreateView(boolean parsingView, String viewName) { // It can be recursive, thus implemented as counter. this.parsingView += parsingView ? 1 : -1; assert this.parsingView >= 0; if (parsingView) { viewNameStack.push(viewName); } else { assert viewName.equals(viewNameStack.peek()); viewNameStack.pop(); } } public String getParsingCreateViewName() {
/** * Store un-initialized variables in a temporary stack for future use. */ private void storePrevScopeUninitializedVariableData() { final ScopeData scopeData = scopeStack.peek(); final Deque<DetailAST> prevScopeUninitializedVariableData = new ArrayDeque<>(); scopeData.uninitializedVariables.forEach(prevScopeUninitializedVariableData::push); prevScopeUninitializedVariables.push(prevScopeUninitializedVariableData); }
public void testHoldsLockOnAllOperations() { create().element(); create().offer("foo"); create().peek(); create().poll(); create().remove(); create().equals(new ArrayDeque<>(ImmutableList.of("foo"))); create().hashCode(); create().isEmpty(); create().iterator(); create().remove("foo"); create().removeFirstOccurrence("e"); create().removeLastOccurrence("e"); create().push("e"); create().pop(); create().descendingIterator();
@Override public Activity startActivity(String activityName) { if (Thread.currentThread() != mainThread) { return OFF_THREAD_ACTIVITY; } ActivityInfo newActivity = new ActivityInfo(activityName).initialize(); if (!activityStack.isEmpty()) { ActivityInfo currentActivity = activityStack.peek(); currentActivity.ownTime += newActivity.startTime - ((currentActivity.resumeTime > 0) ? currentActivity.resumeTime : currentActivity.startTime); currentActivity.ownMem += (currentActivity.startMem - newActivity.startMem > 0) ? currentActivity.startMem - newActivity.startMem : 0; } activityStack.push(newActivity); return activityInstance; }
private void moveToNext() { if (nextBlank && !this.iterators.isEmpty()) { if (!iterators.peek().hasNext()) { iterators.removeFirst(); moveToNext(); } else { final Object next = iterators.peekFirst().next(); if (next instanceof Iterator) { push((Iterator<?>) next); moveToNext(); } else { this.next = (T) next; nextBlank = false; } } } }
private StringBuilder dump(StringBuilder sb) { Deque<ASTNode> stack = new ArrayDeque<ASTNode>(); stack.push(this); int tabLength = 0; while (!stack.isEmpty()) { ASTNode next = stack.peek(); if (!next.visited) { sb.append(StringUtils.repeat(" ", tabLength * 3)); sb.append(next.toString()); sb.append("\n"); if (next.children != null) { for (int i = next.children.size() - 1 ; i >= 0 ; i--) { stack.push((ASTNode)next.children.get(i)); } } tabLength++; next.visited = true; } else { tabLength--; next.visited = false; stack.pop(); } } return sb; }
}); Deque<NodeImpl> stack = new ArrayDeque<>(); stack.push(root); for (Range range : rangeList) { NodeImpl current = new NodeImpl(); current.start = range.left; current.end = range.right; while (range.right <= stack.peek().start) { stack.pop(); NodeImpl parent = stack.peek(); current.next = parent.firstChild; parent.firstChild = current; stack.push(current);
/** * End a {@link Scope} by removing {@code this} from a {@link java.util.Deque} contained in a * {@link java.lang.ThreadLocal}. * If {@code this} isn't on the top of the Deque, an {@link IllegalStateException} will be thrown, as that signals a * process is trying to end somebody else's scope. * If the Deque is empty, it will be removed from the ThreadLocal. */ protected void endScope() { Deque<Scope> scopes = CURRENT_SCOPE.get(); if (this != scopes.peek()) { throw new IllegalStateException( "Incorrectly trying to end another Scope then which the calling process is contained in." ); } scopes.pop(); if (scopes.isEmpty()) { logger.debug("Clearing out ThreadLocal current Scope, as no Scopes are present"); CURRENT_SCOPE.remove(); } }
private StringBuilder dump(StringBuilder sb) { Deque<ASTNode> stack = new ArrayDeque<ASTNode>(); stack.push(this); int tabLength = 0; while (!stack.isEmpty()) { ASTNode next = stack.peek(); if (!next.visited) { sb.append(StringUtils.repeat(" ", tabLength * 3)); sb.append(next.toString()); sb.append("\n"); if (next.children != null) { for (int i = next.children.size() - 1 ; i >= 0 ; i--) { stack.push((ASTNode)next.children.get(i)); } } tabLength++; next.visited = true; } else { tabLength--; next.visited = false; stack.pop(); } } return sb; }
/** * Clears the UnitOfWork currently bound to the current thread, if that UnitOfWork is the given * {@code unitOfWork}. * * @param unitOfWork The UnitOfWork expected to be bound to the current thread. * @throws IllegalStateException when the given UnitOfWork was not the current active UnitOfWork. This exception * indicates a potentially wrong nesting of Units Of Work. */ public static void clear(UnitOfWork<?> unitOfWork) { if (!isStarted()) { throw new IllegalStateException("Could not clear this UnitOfWork. There is no UnitOfWork active."); } if (CURRENT.get().peek() == unitOfWork) { CURRENT.get().pop(); if (CURRENT.get().isEmpty()) { CURRENT.remove(); } } else { throw new IllegalStateException("Could not clear this UnitOfWork. It is not the active one."); } }