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

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

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

Stack.size介绍

暂无

代码示例

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

public XStreamDOM getOutput() {
    if (pendings.size()!=1)     throw new IllegalStateException();
    return pendings.peek().children.get(0);
  }
}

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

private static String getStackString(KsonCharInput in) {
  if ( in instanceof KsonStringCharInput && ((KsonStringCharInput) in).stack != null) {
    final Stack<KsonDeserializer.ParseStep> stack = ((KsonStringCharInput) in).stack;
    StringBuilder res = new StringBuilder("\n\n");
    for (int i = stack.size()-1; i >= 0; i--) {
      KsonDeserializer.ParseStep parseStep = stack.get(i);
      res.append("  ").append(parseStep).append("\n");
    }
    return res.toString();
  }
  return null;
}

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

/**
 * Push the current stylesheet being constructed. If no other stylesheets
 * have been pushed onto the stack, assume the argument is a stylesheet
 * root, and also set the stylesheet root member.
 *
 * @param s non-null reference to a stylesheet.
 */
public void pushStylesheet(Stylesheet s)
{
 if (m_stylesheets.size() == 0)
  m_stylesheetRoot = (StylesheetRoot) s;
 m_stylesheets.push(s);
}

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

/**
 * Gets the nth ancestor (the parent being the 1st ancestor) in the traversal
 * path. n=0 returns the currently visited node.
 * 
 * @param st The stack that encodes the traversal path.
 * @param n The value of n (n=0 is the currently visited node).
 * 
 * @return Node The Nth ancestor in the path with respect to the current node.
 */
public static Node getNthAncestor(Stack<Node> st, int n) {
 assert(st.size() - 1 >= n);
 
 Stack<Node> tmpStack = new Stack<Node>();
 for(int i=0; i<=n; i++)
  tmpStack.push(st.pop());
  Node ret_nd = tmpStack.peek();
 
 for(int i=0; i<=n; i++)
  st.push(tmpStack.pop());
 
 assert(tmpStack.isEmpty());
 
 return ret_nd;
}

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

@Override
protected File computeNext() {
  while(stack.size() > 0) {
    File f = stack.pop();
    if(f.isDirectory()) {
      for(File sub: f.listFiles())
        stack.push(sub);
    } else {
      return f;
    }
  }
  return endOfData();
}

代码示例来源:origin: osmandapp/Osmand

if(isCase || isSwitch){ //$NON-NLS-1$
  attrsMap.clear();
  boolean top = stack.size() == 0 || isTopCase();
  parseAttributes(attrsMap);
  RenderingRule renderingRule = new RenderingRule(attrsMap, isSwitch, RenderingRulesStorage.this);
    renderingRule.storeAttributes(attrsMap);
  if (stack.size() > 0 && stack.peek() instanceof RenderingRule) {
    RenderingRule parent = ((RenderingRule) stack.peek());
    parent.addIfElseChildren(renderingRule);
  stack.push(renderingRule);
} else if(isApply(name)){ //$NON-NLS-1$
  attrsMap.clear();
    renderingRule.storeAttributes(attrsMap);
  if (stack.size() > 0 && stack.peek() instanceof RenderingRule) {
    ((RenderingRule) stack.peek()).addIfChildren(renderingRule);
  } else {
    throw new XmlPullParserException("Apply (groupFilter) without parent");
  stack.push(renderingRule);
} else if("order".equals(name)){ //$NON-NLS-1$
  state = ORDER_RULES;

代码示例来源:origin: ankidroid/Anki-Android

public void pop() {
  if (mWhichStack.size() == 0) return;
  switch (mWhichStack.peek()) {
    case 0:
      mPathStack.pop();
      break;
    case 1:
      mPointStack.pop();
      break;
  }
  mWhichStack.pop();
}

代码示例来源:origin: google/j2objc

private List<Matcher> popLastArgumentMatchers(int count) {
  List<Matcher> result = new LinkedList<Matcher>();
  result.addAll(matcherStack.subList(matcherStack.size() - count, matcherStack.size()));
  for (int i = 0; i < count; i++) {
    matcherStack.pop();
  }
  return result;
}

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

public static File normalize(final String path) {
  Stack s = new Stack();
  String[] dissect = dissect(path);
  s.push(dissect[0]);
      if (s.size() < 2) {
      s.pop();
    } else { // plain component
      s.push(thisToken);
  for (int i = 0; i < s.size(); i++) {
    if (i > 1) {
    sb.append(s.elementAt(i));

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

/** Transfer an element from the real to the virtual stack.  This assumes 
  *  that the virtual stack is currently empty.  
  */
 @SuppressWarnings("unchecked")
protected void get_from_real()
  {
   Symbol stack_sym;

   /* don't transfer if the real stack is empty */
   if (real_next >= real_stack.size()) return;

   /* get a copy of the first Symbol we have not transfered */
   stack_sym = (Symbol)real_stack.elementAt(real_stack.size()-1-real_next);

   /* record the transfer */
   real_next++;

   /* put the state number from the Symbol onto the virtual stack */
   vstack.push(new Integer(stack_sym.parse_state));
  }

代码示例来源:origin: javax.el/javax.el-api

/**
 * Inquires if the name is a LambdaArgument
 * @param arg A possible Lambda formal parameter name
 * @return true if arg is a LambdaArgument, false otherwise.
 */
public boolean isLambdaArgument(String arg) {
  if (lambdaArgs == null) {
    return false;
  }
  for (int i = lambdaArgs.size() - 1; i >= 0; i--) {
    Map<String, Object> lmap = lambdaArgs.elementAt(i);
    if (lmap.containsKey(arg)) {
      return true;
    }
  }
  return false;
}

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

/**
 * Gets the nth ancestor (the parent being the 1st ancestor) in the traversal
 * path. n=0 returns the currently visited node.
 * 
 * @param st The stack that encodes the traversal path.
 * @param n The value of n (n=0 is the currently visited node).
 * 
 * @return Node The Nth ancestor in the path with respect to the current node.
 */
public static Node getNthAncestor(Stack<Node> st, int n) {
 assert(st.size() - 1 >= n);
 
 Stack<Node> tmpStack = new Stack<Node>();
 for(int i=0; i<=n; i++)
  tmpStack.push(st.pop());
  Node ret_nd = tmpStack.peek();
 
 for(int i=0; i<=n; i++)
  st.push(tmpStack.pop());
 
 assert(tmpStack.isEmpty());
 
 return ret_nd;
}

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

for (int i=0; i<c.length;i++) {
  if (i==0 && c[i].equals("")) continue;
  name.push(c[i]);
    if (name.size() == 0) {
      throw new IllegalArgumentException(String.format(
          "Illegal relative path '%s' within context '%s'", path, context.getFullName()
      ));
    name.pop();
    continue;
    continue;
  name.push(p[i]);

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@Override
public void startElement(String uri, String localName, String qName, Attributes attribs) throws SAXException {
  if (qName.equals("scene")) {
    if (elementStack.size() != 0) {
      throw new SAXException("dotScene parse error: 'scene' element must be the root XML element");
    String curElement = elementStack.peek();
    if (!curElement.equals("node") && !curElement.equals("nodes")) {
      throw new SAXException("dotScene parse error: "
    parseCameraClipping(attribs);
  } else if (qName.equals("position")) {
    if (elementStack.peek().equals("node")) {
      node.setLocalTranslation(SAXUtil.parseVector3(attribs));
    } else if (elementStack.peek().equals("camera")) {
      cameraNode.setLocalTranslation(SAXUtil.parseVector3(attribs));
  elementStack.push(qName);

代码示例来源:origin: hankcs/HanLP

/**
 * Calculates the length of the the sub-path in a _transition path, that is used only by a given string.
 *
 * @param str a String corresponding to a _transition path from sourceNode
 * @return an int denoting the size of the sub-path in the _transition path
 * corresponding to {@code str} that is only used by {@code str}
 */
private int calculateSoleTransitionPathLength(String str)
{
  Stack<MDAGNode> transitionPathNodeStack = sourceNode.getTransitionPathNodes(str);
  transitionPathNodeStack.pop();  //The MDAGNode at the top of the stack is not needed
  //(we are processing the outgoing transitions of nodes inside str's _transition path,
  //the outgoing transitions of the MDAGNode at the top of the stack are outside this path)
  transitionPathNodeStack.trimToSize();
  //Process each node in transitionPathNodeStack, using each to determine whether the
  //_transition path corresponding to str is only used by str.  This is true if and only if
  //each node in the _transition path has a single outgoing _transition and is not an accept state.
  while (!transitionPathNodeStack.isEmpty())
  {
    MDAGNode currentNode = transitionPathNodeStack.peek();
    if (currentNode.getOutgoingTransitions().size() <= 1 && !currentNode.isAcceptNode())
      transitionPathNodeStack.pop();
    else
      break;
  }
  /////
  return (transitionPathNodeStack.capacity() - transitionPathNodeStack.size());
}

代码示例来源:origin: com.novocode/junit-interface

void popCurrentTestClassName()
{
 if(currentTestClassName.size() > 1) currentTestClassName.pop();
}

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

/**
 * Push the current stylesheet being constructed. If no other stylesheets
 * have been pushed onto the stack, assume the argument is a stylesheet
 * root, and also set the stylesheet root member.
 *
 * @param s non-null reference to a stylesheet.
 */
public void pushStylesheet(Stylesheet s)
{
 if (m_stylesheets.size() == 0)
  m_stylesheetRoot = (StylesheetRoot) s;
 m_stylesheets.push(s);
}

代码示例来源:origin: org.apache.ant/ant

Stack<String> s = new Stack<>();
String[] dissect = dissect(path);
s.push(dissect[0]);
    if (s.size() < 2) {
    s.pop();
  } else { // plain component
    s.push(thisToken);
final int size = s.size();
for (int i = 0; i < size; i++) {
  if (i > 1) {
  sb.append(s.elementAt(i));

代码示例来源:origin: JetBrains/ideavim

private State currentState() {
 if (myStates.size() > 0) {
  return myStates.peek();
 }
 else {
  return myDefaultState;
 }
}

代码示例来源:origin: jaydenxiao2016/AndroidFire

/**
 * 获取当前Activity的前一个Activity
 */
public Activity preActivity() {
  int index = activityStack.size() - 2;
  if (index < 0) {
    return null;
  }
  Activity activity = activityStack.get(index);
  return activity;
}

相关文章