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

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

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

Stack.empty介绍

[英]Returns whether the stack is empty or not.
[中]返回堆栈是否为空。

代码示例

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

  1. /**
  2. * Peek the last signal
  3. */
  4. public Signal signalPeek() {
  5. if (!exec.signals.empty()) {
  6. return exec.signals.peek();
  7. }
  8. return null;
  9. }

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

  1. /**
  2. * Pop the last signal
  3. */
  4. public Signal signalPop() {
  5. if (!exec.signals.empty()) {
  6. return exec.signals.pop();
  7. }
  8. return null;
  9. }

代码示例来源:origin: groovy/groovy-core

  1. private GroovySourceAST getParentNode() {
  2. GroovySourceAST parentNode = null;
  3. GroovySourceAST currentNode = stack.pop();
  4. if (!stack.empty()) {
  5. parentNode = stack.peek();
  6. }
  7. stack.push(currentNode);
  8. return parentNode;
  9. }

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

  1. private Set<Class> findAllInterfacesInHierarchy(Class candidateGoExtensionClass) {
  2. Stack<Class> classesInHierarchy = new Stack<>();
  3. classesInHierarchy.add(candidateGoExtensionClass);
  4. Set<Class> interfaces = new HashSet<>();
  5. while (!classesInHierarchy.empty()) {
  6. Class classToCheckFor = classesInHierarchy.pop();
  7. if (classToCheckFor.isInterface()) {
  8. interfaces.add(classToCheckFor);
  9. }
  10. classesInHierarchy.addAll(Arrays.asList(classToCheckFor.getInterfaces()));
  11. if (classToCheckFor.getSuperclass() != null) {
  12. classesInHierarchy.add(classToCheckFor.getSuperclass());
  13. }
  14. }
  15. return interfaces;
  16. }

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

  1. private void validateRootExists(CaseInsensitiveString root, PipelineDependencyState pipelineDependencyState, Stack<CaseInsensitiveString> visiting) throws Exception {
  2. if (!pipelineDependencyState.hasPipeline(root)) {
  3. StringBuffer sb = new StringBuffer("Pipeline \"");
  4. sb.append(root);
  5. sb.append("\" does not exist.");
  6. visiting.pop();
  7. if (!visiting.empty()) {
  8. CaseInsensitiveString parent = visiting.peek();
  9. sb.append(" It is used from pipeline \"");
  10. sb.append(parent);
  11. sb.append("\".");
  12. }
  13. throw new Exception(sb.toString());
  14. }
  15. }

代码示例来源: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: groovy/groovy-core

  1. private GroovySourceAST getGrandParentNode() {
  2. GroovySourceAST grandParentNode = null;
  3. GroovySourceAST parentNode;
  4. GroovySourceAST currentNode = stack.pop();
  5. if (!stack.empty()) {
  6. parentNode = stack.pop();
  7. if (!stack.empty()) {
  8. grandParentNode = stack.peek();
  9. }
  10. stack.push(parentNode);
  11. }
  12. stack.push(currentNode);
  13. return grandParentNode;
  14. }

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

  1. private Set<Operator<?>> getAllOperatorsForSimpleFetch(Set<Operator<?>> opSet) {
  2. Set<Operator<?>> returnSet = new LinkedHashSet<Operator<?>>();
  3. Stack<Operator<?>> opStack = new Stack<Operator<?>>();
  4. // add all children
  5. opStack.addAll(opSet);
  6. while (!opStack.empty()) {
  7. Operator<?> op = opStack.pop();
  8. returnSet.add(op);
  9. if (op.getChildOperators() != null) {
  10. opStack.addAll(op.getChildOperators());
  11. }
  12. }
  13. return returnSet;
  14. }
  15. }

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

  1. /**
  2. * Leave the current scope
  3. */
  4. public void leaveScope() {
  5. if (!exec.signals.empty()) {
  6. Scope scope = exec.scopes.peek();
  7. Signal signal = exec.signals.peek();
  8. if (exec.conf.onError != OnError.SETERROR) {
  9. runExitHandler();
  10. }
  11. if (signal.type == Signal.Type.LEAVE_ROUTINE && scope.type == Scope.Type.ROUTINE) {
  12. exec.signals.pop();
  13. }
  14. }
  15. exec.currentScope = exec.scopes.pop().getParent();
  16. }

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

  1. /**
  2. * Pop the current label
  3. */
  4. public String labelPop() {
  5. if(!exec.labels.empty()) {
  6. return exec.labels.pop();
  7. }
  8. return "";
  9. }

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

  1. public Message getActivatingMessage() {
  2. if (activationState.empty()) {
  3. return null;
  4. }
  5. return activationState.peek();
  6. }

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

  1. /**
  2. * This function is called while parsing the filterString and an operator is parsed
  3. * <p>
  4. * @param operatorStack the stack containing the operators and parenthesis
  5. * @param filterStack the stack containing the filters
  6. * @param operator the operator found while parsing the filterString
  7. */
  8. public void reduce(Stack<ByteBuffer> operatorStack,
  9. Stack<Filter> filterStack,
  10. ByteBuffer operator) {
  11. while (!operatorStack.empty() &&
  12. !(ParseConstants.LPAREN_BUFFER.equals(operatorStack.peek())) &&
  13. hasHigherPriority(operatorStack.peek(), operator)) {
  14. filterStack.push(popArguments(operatorStack, filterStack));
  15. }
  16. }

代码示例来源: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/drill

  1. private Set<Operator<?>> getAllOperatorsForSimpleFetch(Set<Operator<?>> opSet) {
  2. Set<Operator<?>> returnSet = new LinkedHashSet<Operator<?>>();
  3. Stack<Operator<?>> opStack = new Stack<Operator<?>>();
  4. // add all children
  5. opStack.addAll(opSet);
  6. while (!opStack.empty()) {
  7. Operator<?> op = opStack.pop();
  8. returnSet.add(op);
  9. if (op.getChildOperators() != null) {
  10. opStack.addAll(op.getChildOperators());
  11. }
  12. }
  13. return returnSet;
  14. }
  15. }

代码示例来源:origin: oracle/opengrok

  1. @Override
  2. public void yypop() throws IOException {
  3. onDisjointSpanChanged(null, yychar);
  4. super.yypop();
  5. styleStack.pop();
  6. if (!styleStack.empty()) {
  7. String style = styleStack.peek();
  8. onDisjointSpanChanged(style, yychar);
  9. }
  10. }

代码示例来源:origin: groovy/groovy-core

  1. public GroovySourceAST pop() {
  2. if (!stack.empty()) {
  3. return stack.pop();
  4. }
  5. return null;
  6. }

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

  1. public FunctionStmtToken peekClosure() {
  2. if (closureStack.empty())
  3. return null;
  4. else
  5. return closureStack.peek();
  6. }

代码示例来源:origin: shekhargulati/99-problems

  1. public int firstOffendingParenthesis(String input) {
  2. /*
  3. Algorithm:
  4. 1. Iterate over all the characters of input String
  5. 2. If character is ')' and stack is not empty then remove element from stack
  6. 3. Else add the position into the stack
  7. 4. After iteration, if stack is empty then return -1 else get the first element and return its value.
  8. */
  9. Stack<Integer> stack = new Stack<>();
  10. for (int i = 0; i < input.length(); i++) {
  11. if (input.charAt(i) == ')' && !stack.empty()) {
  12. stack.pop();
  13. } else {
  14. stack.push(i);
  15. }
  16. }
  17. return stack.empty() ? -1 : stack.elementAt(0);
  18. }
  19. }

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

  1. public Set<Operator<?>> getAllOperators() {
  2. Set<Operator<?>> returnSet = new LinkedHashSet<Operator<?>>();
  3. Set<Operator<?>> opSet = getAllRootOperators();
  4. Stack<Operator<?>> opStack = new Stack<Operator<?>>();
  5. // add all children
  6. opStack.addAll(opSet);
  7. while(!opStack.empty()) {
  8. Operator<?> op = opStack.pop();
  9. returnSet.add(op);
  10. if (op.getChildOperators() != null) {
  11. opStack.addAll(op.getChildOperators());
  12. }
  13. }
  14. return returnSet;
  15. }

相关文章