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

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

本文整理了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

/**
 * Peek the last signal
 */
public Signal signalPeek() {
 if (!exec.signals.empty()) {
  return exec.signals.peek();
 }
 return null;
}

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

/**
 * Pop the last signal
 */
public Signal signalPop() {
 if (!exec.signals.empty()) {
  return exec.signals.pop();
 }
 return null;
}

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

private GroovySourceAST getParentNode() {
  GroovySourceAST parentNode = null;
  GroovySourceAST currentNode = stack.pop();
  if (!stack.empty()) {
    parentNode = stack.peek();
  }
  stack.push(currentNode);
  return parentNode;
}

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

private Set<Class> findAllInterfacesInHierarchy(Class candidateGoExtensionClass) {
  Stack<Class> classesInHierarchy = new Stack<>();
  classesInHierarchy.add(candidateGoExtensionClass);
  Set<Class> interfaces = new HashSet<>();
  while (!classesInHierarchy.empty()) {
    Class classToCheckFor = classesInHierarchy.pop();
    if (classToCheckFor.isInterface()) {
      interfaces.add(classToCheckFor);
    }
    classesInHierarchy.addAll(Arrays.asList(classToCheckFor.getInterfaces()));
    if (classToCheckFor.getSuperclass() != null) {
      classesInHierarchy.add(classToCheckFor.getSuperclass());
    }
  }
  return interfaces;
}

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

private void validateRootExists(CaseInsensitiveString root, PipelineDependencyState pipelineDependencyState, Stack<CaseInsensitiveString> visiting) throws Exception {
  if (!pipelineDependencyState.hasPipeline(root)) {
    StringBuffer sb = new StringBuffer("Pipeline \"");
    sb.append(root);
    sb.append("\" does not exist.");
    visiting.pop();
    if (!visiting.empty()) {
      CaseInsensitiveString parent = visiting.peek();
      sb.append(" It is used from pipeline \"");
      sb.append(parent);
      sb.append("\".");
    }
    throw new Exception(sb.toString());
  }
}

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

@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;
}

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

public Scope addScope(boolean isRoot) {
  Scope scope = new Scope(scopeStack.empty() ? null : scopeStack.peek());
  scopeStack.push(scope);
  if (isRoot)
    rootScopeStack.push(scope);
  return scope;
}

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

private GroovySourceAST getGrandParentNode() {
  GroovySourceAST grandParentNode = null;
  GroovySourceAST parentNode;
  GroovySourceAST currentNode = stack.pop();
  if (!stack.empty()) {
    parentNode = stack.pop();
    if (!stack.empty()) {
      grandParentNode = stack.peek();
    }
    stack.push(parentNode);
  }
  stack.push(currentNode);
  return grandParentNode;
}

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

private Set<Operator<?>> getAllOperatorsForSimpleFetch(Set<Operator<?>> opSet) {
  Set<Operator<?>> returnSet = new LinkedHashSet<Operator<?>>();
  Stack<Operator<?>> opStack = new Stack<Operator<?>>();
  // add all children
  opStack.addAll(opSet);
  while (!opStack.empty()) {
   Operator<?> op = opStack.pop();
   returnSet.add(op);
   if (op.getChildOperators() != null) {
    opStack.addAll(op.getChildOperators());
   }
  }
  return returnSet;
 }
}

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

/**
 * Leave the current scope
 */
public void leaveScope() {
 if (!exec.signals.empty()) {
  Scope scope = exec.scopes.peek();
  Signal signal = exec.signals.peek();
  if (exec.conf.onError != OnError.SETERROR) {
   runExitHandler();
  }
  if (signal.type == Signal.Type.LEAVE_ROUTINE && scope.type == Scope.Type.ROUTINE) {
   exec.signals.pop();
  }
 }
 exec.currentScope = exec.scopes.pop().getParent();
}

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

/**
 * Pop the current label
 */
public String labelPop() {
 if(!exec.labels.empty()) {
  return exec.labels.pop();
 }
 return "";
}

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

public Message getActivatingMessage() {
  if (activationState.empty()) {
    return null;
  }
  return activationState.peek();
}

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

/**
 * This function is called while parsing the filterString and an operator is parsed
 * <p>
 * @param operatorStack the stack containing the operators and parenthesis
 * @param filterStack the stack containing the filters
 * @param operator the operator found while parsing the filterString
 */
 public void reduce(Stack<ByteBuffer> operatorStack,
           Stack<Filter> filterStack,
           ByteBuffer operator) {
  while (!operatorStack.empty() &&
      !(ParseConstants.LPAREN_BUFFER.equals(operatorStack.peek())) &&
      hasHigherPriority(operatorStack.peek(), operator)) {
   filterStack.push(popArguments(operatorStack, filterStack));
  }
 }

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

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;
}

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

private Set<Operator<?>> getAllOperatorsForSimpleFetch(Set<Operator<?>> opSet) {
  Set<Operator<?>> returnSet = new LinkedHashSet<Operator<?>>();
  Stack<Operator<?>> opStack = new Stack<Operator<?>>();
  // add all children
  opStack.addAll(opSet);
  while (!opStack.empty()) {
   Operator<?> op = opStack.pop();
   returnSet.add(op);
   if (op.getChildOperators() != null) {
    opStack.addAll(op.getChildOperators());
   }
  }
  return returnSet;
 }
}

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

@Override
public void yypop() throws IOException {
  onDisjointSpanChanged(null, yychar);
  super.yypop();
  styleStack.pop();
  if (!styleStack.empty()) {
    String style = styleStack.peek();
    onDisjointSpanChanged(style, yychar);
  }
}

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

public GroovySourceAST pop() {
  if (!stack.empty()) {
    return stack.pop();
  }
  return null;
}

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

public FunctionStmtToken peekClosure() {
  if (closureStack.empty())
    return null;
  else
    return closureStack.peek();
}

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

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

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

public Set<Operator<?>> getAllOperators() {
 Set<Operator<?>> returnSet = new LinkedHashSet<Operator<?>>();
 Set<Operator<?>> opSet = getAllRootOperators();
 Stack<Operator<?>> opStack = new Stack<Operator<?>>();
 // add all children
 opStack.addAll(opSet);
 while(!opStack.empty()) {
  Operator<?> op = opStack.pop();
  returnSet.add(op);
  if (op.getChildOperators() != null) {
   opStack.addAll(op.getChildOperators());
  }
 }
 return returnSet;
}

相关文章