private static List<SQLSelectQueryBlock> splitSQLSelectQuery(SQLSelectQuery x) { List<SQLSelectQueryBlock> groupList = new ArrayList<SQLSelectQueryBlock>(); Stack<SQLSelectQuery> stack = new Stack<SQLSelectQuery>(); stack.push(x); do { SQLSelectQuery query = stack.pop(); if (query instanceof SQLSelectQueryBlock) { groupList.add((SQLSelectQueryBlock) query); } else if (query instanceof SQLUnionQuery) { SQLUnionQuery unionQuery = (SQLUnionQuery) query; stack.push(unionQuery.getLeft()); stack.push(unionQuery.getRight()); } } while (!stack.empty()); return groupList; }
@Override public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException { String tagName = localName.toUpperCase(Locale.ENGLISH); // make sure that this tag occurs in the proper context if(!elements.peek().isAllowed(tagName)) throw new SAXException(tagName+" is not allowed inside "+tagNames.peek()); Checker next = CHECKERS.get(tagName); if(next==null) next = ALL_ALLOWED; elements.push(next); tagNames.push(tagName); super.startElement(uri, localName, qName, atts); }
private void visit(N p) throws CycleDetectedException { if (!visited.add(p)) return; visiting.add(p); path.push(p); for (N q : getEdges(p)) { if (q==null) continue; // ignore unresolved references if (visiting.contains(q)) detectedCycle(q); visit(q); } visiting.remove(p); path.pop(); topologicalOrder.add(p); }
/** * walk the current operator and its descendants. * * @param nd * current operator in the graph * @throws SemanticException */ @Override protected void walk(Node nd) throws SemanticException { if (opStack.empty() || nd != opStack.peek()) { opStack.push(nd); } if (allParentsDispatched(nd)) { // all children are done or no need to walk the children if (!getDispatchedList().contains(nd)) { toWalk.addAll(nd.getChildren()); dispatch(nd, opStack); } opStack.pop(); return; } // add children, self to the front of the queue in that order toWalk.add(0, nd); addAllParents(nd); } }
import java.util.*; public class Test { public static void main(String[] args) { Stack<String> stack = new Stack<String>(); stack.push("Bottom"); stack.push("Middle"); stack.push("Top"); List<String> list = new ArrayList<String>(stack); for (String x : list) { System.out.println(x); } } }
@Override protected soot.Value getSimpleAssignRightLocal(polyglot.ast.Assign assign) { boolean repush = false; soot.jimple.Stmt tNoop = null; soot.jimple.Stmt fNoop = null; if (!trueNoop.empty() && !falseNoop.empty()) { tNoop = trueNoop.pop(); fNoop = falseNoop.pop(); repush = true; } soot.Value right = base().createAggressiveExpr(assign.right(), false, false); if (repush) { trueNoop.push(tNoop); falseNoop.push(fNoop); } if (right instanceof soot.jimple.ConditionExpr) { right = handleCondBinExpr((soot.jimple.ConditionExpr) right); } return right; }
private void flushParents(List<Record> willReturn){ Stack<RepeatedRecordInfo> reverseStack = new Stack<>(); while(!stack.isEmpty()){ reverseStack.push(stack.pop()); } while(!reverseStack.isEmpty()){ RepeatedRecordInfo info = reverseStack.pop(); info.timesSeen -= 1; flush(info, willReturn); stack.push(info); } }
private void run(Graph<T> graph, T v) { m_indices.put(v, m_index); m_lowlinks.put(v, m_index); m_index++; m_s.push(v); for (T vprime : graph.getPredecessors(v)) { if (! m_indices.containsKey(vprime)) { run(graph, vprime); int min = Math.min(m_lowlinks.get(v), m_lowlinks.get(vprime)); m_lowlinks.put(v, min); } else if (m_s.contains(vprime)) { m_lowlinks.put(v, Math.min(m_lowlinks.get(v), m_indices.get(vprime))); } } if (Objects.equals(m_lowlinks.get(v), m_indices.get(v))) { m_cycle = Lists.newArrayList(); T n; do { n = m_s.pop(); m_cycle.add(n); } while (! n.equals(v)); } }
public void push(String name, Object value) { Map<String,Object> vars = threadLocalVariables.get(); if (vars == null) { threadLocalVariables.set(vars = new HashMap<>()); //Generics.newHashMap()); } Stack<Object> stack = (Stack<Object>) vars.get(name); if (stack == null) { vars.put(name, stack = new Stack<>()); } stack.push(value); }