java.util.Stack.push()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(313)

本文整理了Java中java.util.Stack.push()方法的一些代码示例,展示了Stack.push()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Stack.push()方法的具体详情如下:
包路径:java.util.Stack
类名称:Stack
方法名:push

Stack.push介绍

[英]Pushes the specified object onto the top of the stack.
[中]将指定的对象推到堆栈顶部。

代码示例

代码示例来源:origin: alibaba/druid

  1. private static List<SQLSelectQueryBlock> splitSQLSelectQuery(SQLSelectQuery x) {
  2. List<SQLSelectQueryBlock> groupList = new ArrayList<SQLSelectQueryBlock>();
  3. Stack<SQLSelectQuery> stack = new Stack<SQLSelectQuery>();
  4. stack.push(x);
  5. do {
  6. SQLSelectQuery query = stack.pop();
  7. if (query instanceof SQLSelectQueryBlock) {
  8. groupList.add((SQLSelectQueryBlock) query);
  9. } else if (query instanceof SQLUnionQuery) {
  10. SQLUnionQuery unionQuery = (SQLUnionQuery) query;
  11. stack.push(unionQuery.getLeft());
  12. stack.push(unionQuery.getRight());
  13. }
  14. } while (!stack.empty());
  15. return groupList;
  16. }

代码示例来源:origin: apache/usergrid

  1. /**
  2. * Push a new fieldname on to the stack
  3. */
  4. private void pushField( final String fieldName ) {
  5. if ( fieldStack.isEmpty() ) {
  6. fieldStack.push( fieldName );
  7. return;
  8. }
  9. final String newFieldName = fieldStack.peek() + "." + fieldName;
  10. fieldStack.push( newFieldName );
  11. }

代码示例来源:origin: jenkinsci/jenkins

  1. @Override
  2. public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
  3. String tagName = localName.toUpperCase(Locale.ENGLISH);
  4. // make sure that this tag occurs in the proper context
  5. if(!elements.peek().isAllowed(tagName))
  6. throw new SAXException(tagName+" is not allowed inside "+tagNames.peek());
  7. Checker next = CHECKERS.get(tagName);
  8. if(next==null) next = ALL_ALLOWED;
  9. elements.push(next);
  10. tagNames.push(tagName);
  11. super.startElement(uri, localName, qName, atts);
  12. }

代码示例来源:origin: jenkinsci/jenkins

  1. private void visit(N p) throws CycleDetectedException {
  2. if (!visited.add(p)) return;
  3. visiting.add(p);
  4. path.push(p);
  5. for (N q : getEdges(p)) {
  6. if (q==null) continue; // ignore unresolved references
  7. if (visiting.contains(q))
  8. detectedCycle(q);
  9. visit(q);
  10. }
  11. visiting.remove(p);
  12. path.pop();
  13. topologicalOrder.add(p);
  14. }

代码示例来源:origin: apache/hive

  1. /**
  2. * walk the current operator and its descendants.
  3. *
  4. * @param nd
  5. * current operator in the graph
  6. * @throws SemanticException
  7. */
  8. @Override
  9. protected void walk(Node nd) throws SemanticException {
  10. if (opStack.empty() || nd != opStack.peek()) {
  11. opStack.push(nd);
  12. }
  13. if (allParentsDispatched(nd)) {
  14. // all children are done or no need to walk the children
  15. if (!getDispatchedList().contains(nd)) {
  16. toWalk.addAll(nd.getChildren());
  17. dispatch(nd, opStack);
  18. }
  19. opStack.pop();
  20. return;
  21. }
  22. // add children, self to the front of the queue in that order
  23. toWalk.add(0, nd);
  24. addAllParents(nd);
  25. }
  26. }

代码示例来源:origin: galenframework/galen

  1. public void pushSection(PageSection pageSection) {
  2. LayoutSection section = new LayoutSection(pageSection.getName(), pageSection.getPlace());
  3. if (!sectionStack.isEmpty()) {
  4. sectionStack.peek().addSection(section);
  5. }
  6. else {
  7. layoutReport.getSections().add(section);
  8. }
  9. sectionStack.push(section);
  10. }

代码示例来源:origin: stackoverflow.com

  1. import java.util.*;
  2. public class Test
  3. {
  4. public static void main(String[] args)
  5. {
  6. Stack<String> stack = new Stack<String>();
  7. stack.push("Bottom");
  8. stack.push("Middle");
  9. stack.push("Top");
  10. List<String> list = new ArrayList<String>(stack);
  11. for (String x : list)
  12. {
  13. System.out.println(x);
  14. }
  15. }
  16. }

代码示例来源:origin: jenkinsci/jenkins

  1. synchronized void push(RunExecution r) {
  2. Executor e = Executor.currentExecutor();
  3. Stack<RunExecution> s = stack.get(e);
  4. if(s==null) stack.put(e,s=new Stack<RunExecution>());
  5. s.push(r);
  6. }

代码示例来源:origin: org.codehaus.groovy/groovy

  1. private GroovySourceAST getGrandParentNode() {
  2. Object currentNode = stack.pop();
  3. Object parentNode = stack.pop();
  4. Object grandParentNode = stack.peek();
  5. stack.push(parentNode);
  6. stack.push(currentNode);
  7. return (GroovySourceAST) grandParentNode;
  8. }
  9. }

代码示例来源:origin: pmd/pmd

  1. private Object init(JavaNode node, Object data) {
  2. stack.push(count);
  3. count = NumericConstants.ZERO;
  4. node.childrenAccept(this, data);
  5. if (count > 1) {
  6. addViolation(data, node);
  7. }
  8. count = stack.pop();
  9. return data;
  10. }

代码示例来源:origin: jenkinsci/jenkins

  1. String[] p = path.split("/");
  2. Stack<String> name = new Stack<String>();
  3. for (int i=0; i<c.length;i++) {
  4. if (i==0 && c[i].equals("")) continue;
  5. name.push(c[i]);
  6. ));
  7. name.pop();
  8. continue;
  9. continue;
  10. name.push(p[i]);

代码示例来源:origin: stanfordnlp/CoreNLP

  1. @Override
  2. void advance() {
  3. if (searchStack.isEmpty()) {
  4. next = null;
  5. } else {
  6. next = searchStack.pop();
  7. if (pathMatchesNode(next)) {
  8. for (int i = next.numChildren() - 1; i >= 0; i--) {
  9. searchStack.push(next.getChild(i));
  10. }
  11. }
  12. }
  13. }
  14. };

代码示例来源:origin: stanfordnlp/CoreNLP

  1. @Override
  2. public void initialize() {
  3. searchStack = new Stack<>();
  4. for (int i = t.numChildren() - 1; i >= 0; i--) {
  5. searchStack.push(t.getChild(i));
  6. }
  7. if (!searchStack.isEmpty()) {
  8. advance();
  9. }
  10. }

代码示例来源:origin: Sable/soot

  1. @Override
  2. protected soot.Value getSimpleAssignRightLocal(polyglot.ast.Assign assign) {
  3. boolean repush = false;
  4. soot.jimple.Stmt tNoop = null;
  5. soot.jimple.Stmt fNoop = null;
  6. if (!trueNoop.empty() && !falseNoop.empty()) {
  7. tNoop = trueNoop.pop();
  8. fNoop = falseNoop.pop();
  9. repush = true;
  10. }
  11. soot.Value right = base().createAggressiveExpr(assign.right(), false, false);
  12. if (repush) {
  13. trueNoop.push(tNoop);
  14. falseNoop.push(fNoop);
  15. }
  16. if (right instanceof soot.jimple.ConditionExpr) {
  17. right = handleCondBinExpr((soot.jimple.ConditionExpr) right);
  18. }
  19. return right;
  20. }

代码示例来源:origin: jphp-group/jphp

  1. public Scope addScope(boolean isRoot) {
  2. Scope scope = new Scope(scopeStack.empty() ? null : scopeStack.peek());
  3. scopeStack.push(scope);
  4. if (isRoot)
  5. rootScopeStack.push(scope);
  6. return scope;
  7. }

代码示例来源:origin: stanfordnlp/CoreNLP

  1. private void flushParents(List<Record> willReturn){
  2. Stack<RepeatedRecordInfo> reverseStack = new Stack<>();
  3. while(!stack.isEmpty()){
  4. reverseStack.push(stack.pop());
  5. }
  6. while(!reverseStack.isEmpty()){
  7. RepeatedRecordInfo info = reverseStack.pop();
  8. info.timesSeen -= 1;
  9. flush(info, willReturn);
  10. stack.push(info);
  11. }
  12. }

代码示例来源:origin: org.testng/testng

  1. private void run(Graph<T> graph, T v) {
  2. m_indices.put(v, m_index);
  3. m_lowlinks.put(v, m_index);
  4. m_index++;
  5. m_s.push(v);
  6. for (T vprime : graph.getPredecessors(v)) {
  7. if (! m_indices.containsKey(vprime)) {
  8. run(graph, vprime);
  9. int min = Math.min(m_lowlinks.get(v), m_lowlinks.get(vprime));
  10. m_lowlinks.put(v, min);
  11. }
  12. else if (m_s.contains(vprime)) {
  13. m_lowlinks.put(v, Math.min(m_lowlinks.get(v), m_indices.get(vprime)));
  14. }
  15. }
  16. if (Objects.equals(m_lowlinks.get(v), m_indices.get(v))) {
  17. m_cycle = Lists.newArrayList();
  18. T n;
  19. do {
  20. n = m_s.pop();
  21. m_cycle.add(n);
  22. } while (! n.equals(v));
  23. }
  24. }

代码示例来源:origin: stanfordnlp/CoreNLP

  1. public void push(String name, Object value) {
  2. Map<String,Object> vars = threadLocalVariables.get();
  3. if (vars == null) {
  4. threadLocalVariables.set(vars = new HashMap<>()); //Generics.newHashMap());
  5. }
  6. Stack<Object> stack = (Stack<Object>) vars.get(name);
  7. if (stack == null) {
  8. vars.put(name, stack = new Stack<>());
  9. }
  10. stack.push(value);
  11. }

代码示例来源:origin: k9mail/k-9

  1. @Override
  2. public void startMessage() throws MimeException {
  3. if (stack.isEmpty()) {
  4. stack.push(decryptedRootPart);
  5. } else {
  6. Part part = (Part) stack.peek();
  7. Message innerMessage = new MimeMessage();
  8. part.setBody(innerMessage);
  9. stack.push(innerMessage);
  10. }
  11. }

代码示例来源:origin: org.codehaus.groovy/groovy

  1. private GroovySourceAST getParentNode() {
  2. Object currentNode = stack.pop();
  3. Object parentNode = stack.peek();
  4. stack.push(currentNode);
  5. return (GroovySourceAST) parentNode;
  6. }

相关文章