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

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

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

Stack.elementAt介绍

暂无

代码示例

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

  1. /**
  2. * Utility function to see if the stack contains the given URL.
  3. *
  4. * @param stack non-null reference to a Stack.
  5. * @param url URL string on which an equality test will be performed.
  6. *
  7. * @return true if the stack contains the url argument.
  8. */
  9. private boolean stackContains(Stack stack, String url)
  10. {
  11. int n = stack.size();
  12. boolean contains = false;
  13. for (int i = 0; i < n; i++)
  14. {
  15. String url2 = (String) stack.elementAt(i);
  16. if (url2.equals(url))
  17. {
  18. contains = true;
  19. break;
  20. }
  21. }
  22. return contains;
  23. }

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

  1. /**
  2. * Utility function to see if the stack contains the given URL.
  3. *
  4. * @param stack non-null reference to a Stack.
  5. * @param url URL string on which an equality test will be performed.
  6. *
  7. * @return true if the stack contains the url argument.
  8. */
  9. private boolean stackContains(Stack stack, String url)
  10. {
  11. int n = stack.size();
  12. boolean contains = false;
  13. for (int i = 0; i < n; i++)
  14. {
  15. String url2 = (String) stack.elementAt(i);
  16. if (url2.equals(url))
  17. {
  18. contains = true;
  19. break;
  20. }
  21. }
  22. return contains;
  23. }

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

  1. /** Do debug output for stack state. [CSA]
  2. */
  3. public void debug_stack() {
  4. StringBuffer sb=new StringBuffer("## STACK:");
  5. for (int i=0; i<stack.size(); i++) {
  6. Symbol s = (Symbol) stack.elementAt(i);
  7. sb.append(" <state "+s.parse_state+", sym "+s.sym+">");
  8. if ((i%3)==2 || (i==(stack.size()-1))) {
  9. debug_message(sb.toString());
  10. sb = new StringBuffer(" ");
  11. }
  12. }
  13. }

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

  1. /**
  2. * Retrieves the Lambda argument associated with a formal parameter.
  3. * If the Lambda expression is nested within other Lambda expressions, the
  4. * arguments for the current Lambda expression is first searched, and if
  5. * not found, the arguments for the immediate nesting Lambda expression
  6. * then searched, and so on.
  7. *
  8. * @param arg The formal parameter for the Lambda argument
  9. * @return The object associated with formal parameter. Null if
  10. * no object has been associated with the parameter.
  11. * @since EL 3.0
  12. */
  13. public Object getLambdaArgument(String arg) {
  14. if (lambdaArgs == null) {
  15. return null;
  16. }
  17. for (int i = lambdaArgs.size() - 1; i >= 0; i--) {
  18. Map<String, Object> lmap = lambdaArgs.elementAt(i);
  19. Object v = lmap.get(arg);
  20. if (v != null) {
  21. return v;
  22. }
  23. }
  24. return null;
  25. }

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

  1. if (s.size() < 2) {
  2. for (int i = 0; i < s.size(); i++) {
  3. if (i > 1) {
  4. sb.append(s.elementAt(i));

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

  1. /** Dump the parse stack for debugging purposes. */
  2. public void dump_stack()
  3. {
  4. if (stack == null)
  5. {
  6. debug_message("# Stack dump requested, but stack is null");
  7. return;
  8. }
  9. debug_message("============ Parse Stack Dump ============");
  10. /* dump the stack */
  11. for (int i=0; i<stack.size(); i++)
  12. {
  13. debug_message("Symbol: " + ((Symbol)stack.elementAt(i)).sym +
  14. " State: " + ((Symbol)stack.elementAt(i)).parse_state);
  15. }
  16. debug_message("==========================================");
  17. }

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

  1. if (s.size() < 2) {
  2. final int size = s.size();
  3. for (int i = 0; i < size; i++) {
  4. if (i > 1) {
  5. sb.append(s.elementAt(i));

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

  1. int depth = namespaces.size();
  2. NameSpace ns = (NameSpace) namespaces.elementAt(i);

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

  1. int depth = namespaces.size();
  2. NameSpace ns = (NameSpace) namespaces.elementAt(i);

代码示例来源:origin: oubowu/OuNews

  1. public Activity getPreActivity() {
  2. if (mActivityStack == null) {
  3. return null;
  4. }
  5. int size = mActivityStack.size();
  6. if (size < 2) {
  7. return null;
  8. }
  9. return mActivityStack.elementAt(size - 2);
  10. }

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

  1. /**
  2. * @param level nesting level, i.e., 0 returns the direct predecessor
  3. * @return container of current entitity, i.e., predecessor during traversal
  4. */
  5. public Object predecessor(int level) {
  6. int size = stack.size();
  7. if((size < 2) || (level < 0))
  8. return null;
  9. else
  10. return stack.elementAt(size - (level + 2)); // size - 1 == current
  11. }

代码示例来源:origin: com.sun.xml.parsers/jaxp-ri

  1. /**
  2. * @param level nesting level, i.e., 0 returns the direct predecessor
  3. * @return container of current entitity, i.e., predecessor during traversal
  4. */
  5. public Object predecessor(int level) {
  6. int size = stack.size();
  7. if((size < 2) || (level < 0))
  8. return null;
  9. else
  10. return stack.elementAt(size - (level + 2)); // size - 1 == current
  11. }

代码示例来源:origin: org.eclipse.epsilon/epsilon-core

  1. /**
  2. * @return the executable template specification
  3. * that is one below the top() of the stack.
  4. */
  5. public ExecutableTemplateSpecification second() {
  6. return specs.elementAt(specs.size()-2);
  7. }

代码示例来源:origin: com.thaiopensource/jing

  1. public String getNamespaceUri(String prefix) {
  2. for (int i = prefixes.size(); i > 0; i -= 2) {
  3. if (prefixes.elementAt(i - 2).equals(prefix))
  4. return (String)prefixes.elementAt(i - 1);
  5. }
  6. return null;
  7. }

代码示例来源:origin: org.daisy.libs/jing

  1. public String getNamespaceUri(String prefix) {
  2. for (int i = prefixes.size(); i > 0; i -= 2) {
  3. if (prefixes.elementAt(i - 2).equals(prefix))
  4. return (String)prefixes.elementAt(i - 1);
  5. }
  6. return null;
  7. }

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

  1. /**
  2. * Returns the most recently pushed context which implements the specified class.
  3. * Will return null if no matching context is found.
  4. */
  5. public Object getClosestContext( Class matchingClass ) {
  6. for (int i = _traversalContext.size()-1; i >= 0; i-- ) {
  7. Object o = _traversalContext.elementAt( i );
  8. if (matchingClass.isInstance(o)) return o;
  9. }
  10. return null;
  11. }

代码示例来源:origin: org.jboss.jbossts.xts/jbossxts

  1. public String toString ()
  2. {
  3. String toReturn = "Activity context:";
  4. if ((_hierarchy == null) || (_hierarchy.size() == 0))
  5. toReturn += " null";
  6. else
  7. {
  8. for (int i = 0; i < _hierarchy.size(); i++)
  9. toReturn += " "+_hierarchy.elementAt(i);
  10. }
  11. return toReturn;
  12. }

代码示例来源:origin: org.jboss.jbossts/jbossxts

  1. public String toString ()
  2. {
  3. String toReturn = "Activity context:";
  4. if ((_hierarchy == null) || (_hierarchy.size() == 0))
  5. toReturn += " null";
  6. else
  7. {
  8. for (int i = 0; i < _hierarchy.size(); i++)
  9. toReturn += " "+_hierarchy.elementAt(i);
  10. }
  11. return toReturn;
  12. }

相关文章