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

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

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

Stack.size介绍

暂无

代码示例

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

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

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

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

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

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

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

  1. /**
  2. * Gets the nth ancestor (the parent being the 1st ancestor) in the traversal
  3. * path. n=0 returns the currently visited node.
  4. *
  5. * @param st The stack that encodes the traversal path.
  6. * @param n The value of n (n=0 is the currently visited node).
  7. *
  8. * @return Node The Nth ancestor in the path with respect to the current node.
  9. */
  10. public static Node getNthAncestor(Stack<Node> st, int n) {
  11. assert(st.size() - 1 >= n);
  12. Stack<Node> tmpStack = new Stack<Node>();
  13. for(int i=0; i<=n; i++)
  14. tmpStack.push(st.pop());
  15. Node ret_nd = tmpStack.peek();
  16. for(int i=0; i<=n; i++)
  17. st.push(tmpStack.pop());
  18. assert(tmpStack.isEmpty());
  19. return ret_nd;
  20. }

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

  1. @Override
  2. protected File computeNext() {
  3. while(stack.size() > 0) {
  4. File f = stack.pop();
  5. if(f.isDirectory()) {
  6. for(File sub: f.listFiles())
  7. stack.push(sub);
  8. } else {
  9. return f;
  10. }
  11. }
  12. return endOfData();
  13. }

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

  1. if(isCase || isSwitch){ //$NON-NLS-1$
  2. attrsMap.clear();
  3. boolean top = stack.size() == 0 || isTopCase();
  4. parseAttributes(attrsMap);
  5. RenderingRule renderingRule = new RenderingRule(attrsMap, isSwitch, RenderingRulesStorage.this);
  6. renderingRule.storeAttributes(attrsMap);
  7. if (stack.size() > 0 && stack.peek() instanceof RenderingRule) {
  8. RenderingRule parent = ((RenderingRule) stack.peek());
  9. parent.addIfElseChildren(renderingRule);
  10. stack.push(renderingRule);
  11. } else if(isApply(name)){ //$NON-NLS-1$
  12. attrsMap.clear();
  13. renderingRule.storeAttributes(attrsMap);
  14. if (stack.size() > 0 && stack.peek() instanceof RenderingRule) {
  15. ((RenderingRule) stack.peek()).addIfChildren(renderingRule);
  16. } else {
  17. throw new XmlPullParserException("Apply (groupFilter) without parent");
  18. stack.push(renderingRule);
  19. } else if("order".equals(name)){ //$NON-NLS-1$
  20. state = ORDER_RULES;

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

  1. public void pop() {
  2. if (mWhichStack.size() == 0) return;
  3. switch (mWhichStack.peek()) {
  4. case 0:
  5. mPathStack.pop();
  6. break;
  7. case 1:
  8. mPointStack.pop();
  9. break;
  10. }
  11. mWhichStack.pop();
  12. }

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

  1. private List<Matcher> popLastArgumentMatchers(int count) {
  2. List<Matcher> result = new LinkedList<Matcher>();
  3. result.addAll(matcherStack.subList(matcherStack.size() - count, matcherStack.size()));
  4. for (int i = 0; i < count; i++) {
  5. matcherStack.pop();
  6. }
  7. return result;
  8. }

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

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

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

  1. /** Transfer an element from the real to the virtual stack. This assumes
  2. * that the virtual stack is currently empty.
  3. */
  4. @SuppressWarnings("unchecked")
  5. protected void get_from_real()
  6. {
  7. Symbol stack_sym;
  8. /* don't transfer if the real stack is empty */
  9. if (real_next >= real_stack.size()) return;
  10. /* get a copy of the first Symbol we have not transfered */
  11. stack_sym = (Symbol)real_stack.elementAt(real_stack.size()-1-real_next);
  12. /* record the transfer */
  13. real_next++;
  14. /* put the state number from the Symbol onto the virtual stack */
  15. vstack.push(new Integer(stack_sym.parse_state));
  16. }

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

  1. /**
  2. * Inquires if the name is a LambdaArgument
  3. * @param arg A possible Lambda formal parameter name
  4. * @return true if arg is a LambdaArgument, false otherwise.
  5. */
  6. public boolean isLambdaArgument(String arg) {
  7. if (lambdaArgs == null) {
  8. return false;
  9. }
  10. for (int i = lambdaArgs.size() - 1; i >= 0; i--) {
  11. Map<String, Object> lmap = lambdaArgs.elementAt(i);
  12. if (lmap.containsKey(arg)) {
  13. return true;
  14. }
  15. }
  16. return false;
  17. }

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

  1. /**
  2. * Gets the nth ancestor (the parent being the 1st ancestor) in the traversal
  3. * path. n=0 returns the currently visited node.
  4. *
  5. * @param st The stack that encodes the traversal path.
  6. * @param n The value of n (n=0 is the currently visited node).
  7. *
  8. * @return Node The Nth ancestor in the path with respect to the current node.
  9. */
  10. public static Node getNthAncestor(Stack<Node> st, int n) {
  11. assert(st.size() - 1 >= n);
  12. Stack<Node> tmpStack = new Stack<Node>();
  13. for(int i=0; i<=n; i++)
  14. tmpStack.push(st.pop());
  15. Node ret_nd = tmpStack.peek();
  16. for(int i=0; i<=n; i++)
  17. st.push(tmpStack.pop());
  18. assert(tmpStack.isEmpty());
  19. return ret_nd;
  20. }

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

  1. for (int i=0; i<c.length;i++) {
  2. if (i==0 && c[i].equals("")) continue;
  3. name.push(c[i]);
  4. if (name.size() == 0) {
  5. throw new IllegalArgumentException(String.format(
  6. "Illegal relative path '%s' within context '%s'", path, context.getFullName()
  7. ));
  8. name.pop();
  9. continue;
  10. continue;
  11. name.push(p[i]);

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

  1. @Override
  2. public void startElement(String uri, String localName, String qName, Attributes attribs) throws SAXException {
  3. if (qName.equals("scene")) {
  4. if (elementStack.size() != 0) {
  5. throw new SAXException("dotScene parse error: 'scene' element must be the root XML element");
  6. String curElement = elementStack.peek();
  7. if (!curElement.equals("node") && !curElement.equals("nodes")) {
  8. throw new SAXException("dotScene parse error: "
  9. parseCameraClipping(attribs);
  10. } else if (qName.equals("position")) {
  11. if (elementStack.peek().equals("node")) {
  12. node.setLocalTranslation(SAXUtil.parseVector3(attribs));
  13. } else if (elementStack.peek().equals("camera")) {
  14. cameraNode.setLocalTranslation(SAXUtil.parseVector3(attribs));
  15. elementStack.push(qName);

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

  1. /**
  2. * Calculates the length of the the sub-path in a _transition path, that is used only by a given string.
  3. *
  4. * @param str a String corresponding to a _transition path from sourceNode
  5. * @return an int denoting the size of the sub-path in the _transition path
  6. * corresponding to {@code str} that is only used by {@code str}
  7. */
  8. private int calculateSoleTransitionPathLength(String str)
  9. {
  10. Stack<MDAGNode> transitionPathNodeStack = sourceNode.getTransitionPathNodes(str);
  11. transitionPathNodeStack.pop(); //The MDAGNode at the top of the stack is not needed
  12. //(we are processing the outgoing transitions of nodes inside str's _transition path,
  13. //the outgoing transitions of the MDAGNode at the top of the stack are outside this path)
  14. transitionPathNodeStack.trimToSize();
  15. //Process each node in transitionPathNodeStack, using each to determine whether the
  16. //_transition path corresponding to str is only used by str. This is true if and only if
  17. //each node in the _transition path has a single outgoing _transition and is not an accept state.
  18. while (!transitionPathNodeStack.isEmpty())
  19. {
  20. MDAGNode currentNode = transitionPathNodeStack.peek();
  21. if (currentNode.getOutgoingTransitions().size() <= 1 && !currentNode.isAcceptNode())
  22. transitionPathNodeStack.pop();
  23. else
  24. break;
  25. }
  26. /////
  27. return (transitionPathNodeStack.capacity() - transitionPathNodeStack.size());
  28. }

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

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

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

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

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

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

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

  1. private State currentState() {
  2. if (myStates.size() > 0) {
  3. return myStates.peek();
  4. }
  5. else {
  6. return myDefaultState;
  7. }
  8. }

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

  1. /**
  2. * 获取当前Activity的前一个Activity
  3. */
  4. public Activity preActivity() {
  5. int index = activityStack.size() - 2;
  6. if (index < 0) {
  7. return null;
  8. }
  9. Activity activity = activityStack.get(index);
  10. return activity;
  11. }

相关文章