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

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

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

Stack.search介绍

[英]Returns the index of the first occurrence of the object, starting from the top of the stack.
[中]返回对象第一次出现的索引,从堆栈顶部开始。

代码示例

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

  1. /**
  2. * Check to see if this is a recursive attribute definition.
  3. *
  4. * @param attrSet A non-null ElemAttributeSet reference.
  5. *
  6. * @return true if the attribute set is recursive.
  7. */
  8. public boolean isRecursiveAttrSet(ElemAttributeSet attrSet)
  9. {
  10. if (null == m_attrSetStack)
  11. {
  12. m_attrSetStack = new Stack();
  13. }
  14. if (!m_attrSetStack.empty())
  15. {
  16. int loc = m_attrSetStack.search(attrSet);
  17. if (loc > -1)
  18. {
  19. return true;
  20. }
  21. }
  22. return false;
  23. }

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

  1. /**
  2. * Check to see if this is a recursive attribute definition.
  3. *
  4. * @param attrSet A non-null ElemAttributeSet reference.
  5. *
  6. * @return true if the attribute set is recursive.
  7. */
  8. public boolean isRecursiveAttrSet(ElemAttributeSet attrSet)
  9. {
  10. if (null == m_attrSetStack)
  11. {
  12. m_attrSetStack = new Stack();
  13. }
  14. if (!m_attrSetStack.empty())
  15. {
  16. int loc = m_attrSetStack.search(attrSet);
  17. if (loc > -1)
  18. {
  19. return true;
  20. }
  21. }
  22. return false;
  23. }

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

  1. /**
  2. * DFS of dependency graph formed by Property annotations and dependsUpon parameter
  3. * This is used to create a list of Properties in dependency order
  4. */
  5. static void addPropertyToDependencyList(List<AccessibleObject> orderedList, Map<String, AccessibleObject> props, Stack<AccessibleObject> stack, AccessibleObject obj) {
  6. if (orderedList.contains(obj))
  7. return ;
  8. if (stack.search(obj) > 0) {
  9. throw new RuntimeException("Deadlock in @Property dependency processing") ;
  10. }
  11. // record the fact that we are processing obj
  12. stack.push(obj) ;
  13. // process dependencies for this object before adding it to the list
  14. Property annotation = obj.getAnnotation(Property.class) ;
  15. String dependsClause = annotation.dependsUpon() ;
  16. StringTokenizer st = new StringTokenizer(dependsClause, ",") ;
  17. while (st.hasMoreTokens()) {
  18. String token = st.nextToken().trim();
  19. AccessibleObject dep = props.get(token) ;
  20. // if null, throw exception
  21. addPropertyToDependencyList(orderedList, props, stack, dep) ;
  22. }
  23. // indicate we're done with processing dependencies
  24. stack.pop() ;
  25. // we can now add in dependency order
  26. orderedList.add(obj) ;
  27. }

代码示例来源:origin: sakaiproject/sakai

  1. public synchronized int search(Object arg0)
  2. {
  3. // TODO Auto-generated method stub
  4. return stack.search(arg0);
  5. }

代码示例来源:origin: org.apache.tapestry/com.springsource.org.apache.tapestry

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public int renderStackSearch(IRender render)
  5. {
  6. return _renderStack.search(render);
  7. }

代码示例来源:origin: org.apache.tapestry/tapestry-framework

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public int renderStackSearch(IRender render)
  5. {
  6. return _renderStack.search(render);
  7. }

代码示例来源:origin: org.jacorb/jacorb-idl-compiler

  1. public static boolean isRecursionScope( String typeName )
  2. {
  3. return ( recursionStack.search( typeName ) != -1 );
  4. }

代码示例来源:origin: org.jacorb/idl-compiler

  1. public static boolean isRecursionScope( String typeName )
  2. {
  3. return ( recursionStack.search( typeName ) != -1 );
  4. }

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

  1. public static boolean isRecursionScope( String typeName )
  2. {
  3. return ( recursionStack.search( typeName ) != -1 );
  4. }

代码示例来源:origin: hltfbk/Excitement-Open-Platform

  1. @Override synchronized public int search(Object o){return super.search(o);}
  2. }

代码示例来源:origin: stackoverflow.com

  1. public static Stack<String> deleteFrom(Stack<String> stack, String obj) {
  2. if (stack.search(obj) == -1) {
  3. System.out.println("Element doesn't exists in stack.");
  4. return stack;
  5. }
  6. Stack<String> stack2 = new Stack<String>();
  7. while (stack.search(obj) != -1)
  8. stack2.push(stack.pop());
  9. stack2.pop();
  10. while (stack2.size() != 0)
  11. stack.push(stack2.pop());
  12. return stack;
  13. }

代码示例来源:origin: org.alfresco/alfresco-repository

  1. /**
  2. * Indicates whether the this behaviour is current enabled or not
  3. *
  4. * @return true if the behaviour is enabled, false otherwise
  5. */
  6. public boolean isEnabled()
  7. {
  8. Stack<Integer> stack = disabled.get();
  9. return stack.search(hashCode()) == -1;
  10. }

代码示例来源:origin: Alfresco/alfresco-repository

  1. /**
  2. * Indicates whether the this behaviour is current enabled or not
  3. *
  4. * @return true if the behaviour is enabled, false otherwise
  5. */
  6. public boolean isEnabled()
  7. {
  8. Stack<Integer> stack = disabled.get();
  9. return stack.search(hashCode()) == -1;
  10. }

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

  1. private void pushInlineContainers(List<InlineParent> ich) {
  2. LinkedList<InlineParent> icl = new LinkedList<InlineParent>();
  3. for (InlineParent ic : ich) {
  4. if (icOrig.search(ic) >= 0) {
  5. break;
  6. } else {
  7. icl.addFirst(ic);
  8. }
  9. }
  10. for (InlineParent ic : icl) {
  11. icOrig.push(ic);
  12. icNew.push(generateInlineContainer(ic));
  13. }
  14. }
  15. private void pushTextContainer(TextArea tc, InlineArea ia) {

代码示例来源:origin: stackoverflow.com

  1. //in class A
  2. @Override
  3. String toString(){
  4. return toString(new Stack<Object>());
  5. }
  6. /**
  7. @Param stack Holds all objects that have been called
  8. */
  9. String toString(Stack stack){
  10. String text = /* details from current class */;
  11. if (bRef != null && stack != null && stack.search(bRef) == -1)
  12. {
  13. stack.push(bRef);
  14. text += bRef.toString(stack);
  15. }
  16. return text;
  17. }

代码示例来源:origin: com.opensymphony/webwork

  1. /**
  2. * Finds the nearest ancestor of this component stack.
  3. * @param clazz the class to look for, or if assignable from.
  4. * @return the component if found, <tt>null</tt> if not.
  5. */
  6. protected Component findAncestor(Class clazz) {
  7. Stack componentStack = getComponentStack();
  8. int currPosition = componentStack.search(this);
  9. if (currPosition >= 0) {
  10. int start = componentStack.size() - currPosition - 1;
  11. //for (int i = componentStack.size() - 2; i >= 0; i--) {
  12. for (int i = start; i >=0; i--) {
  13. Component component = (Component) componentStack.get(i);
  14. if (clazz.isAssignableFrom(component.getClass()) && component != this) {
  15. return component;
  16. }
  17. }
  18. }
  19. return null;
  20. }

代码示例来源:origin: org.eclipse.equinox.p2/repository

  1. public void end(String name) {
  2. if (this.elements.empty()) {
  3. throw new EndWithoutStartError();
  4. }
  5. int index = this.elements.search(name);
  6. if (index == -1) {
  7. throw new EndWithoutStartError(name);
  8. }
  9. for (int i = 0; i < index; i += 1) {
  10. end();
  11. }
  12. }

代码示例来源:origin: com.github.veithen.cosmos.bootstrap/org.eclipse.equinox.p2.repository

  1. public void end(String name) {
  2. if (this.elements.empty()) {
  3. throw new EndWithoutStartError();
  4. }
  5. int index = this.elements.search(name);
  6. if (index == -1) {
  7. throw new EndWithoutStartError(name);
  8. }
  9. for (int i = 0; i < index; i += 1) {
  10. end();
  11. }
  12. }

代码示例来源:origin: de.jflex/jflex

  1. private void includeFile(String filePath) {
  2. File f = new File(file.getParentFile(), filePath);
  3. if ( !f.canRead() )
  4. throw new ScannerException(file,ErrorMessages.NOT_READABLE, yyline);
  5. // check for cycle
  6. if (files.search(f) > 0)
  7. throw new ScannerException(file,ErrorMessages.FILE_CYCLE, yyline);
  8. try {
  9. yypushStream( new FileReader(f) );
  10. files.push(file);
  11. file = f;
  12. Out.println("Including \""+file+"\"");
  13. }
  14. catch (FileNotFoundException e) {
  15. throw new ScannerException(file,ErrorMessages.NOT_READABLE, yyline);
  16. }
  17. }

代码示例来源:origin: octo-online/reactive-audit

  1. @Test(expected = ReactiveAuditException.class)
  2. public void search()
  3. {
  4. ReactiveAudit.off.commit();
  5. Stack stack=new Stack();
  6. TestTools.strict.commit();
  7. stack.search(null);
  8. }
  9. }

相关文章