本文整理汇总了Java中java.util.Stack.search方法的典型用法代码示例。如果您正苦于以下问题:Java Stack.search方法的具体用法?Java Stack.search怎么用?Java Stack.search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Stack
的用法示例。
在下文中一共展示了Stack.search方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addCycle
import java.util.Stack; //导入方法依赖的package包/类
public void addCycle(Stack<SootMethod> stack, SootMethod sm) {
// check that there is a cycle with m
if (stack.search(sm) == -1)
throw new RuntimeException("error: method not in stack. No cycle!"+ printMethodAndStack(sm, stack));
// check that there are not more than one
if (stack.lastIndexOf(sm) != stack.indexOf(sm))
throw new RuntimeException("error: a method cannot be more than twice in the stack! "+ printMethodAndStack(sm, stack));
// two cycles with the same method is not possible since we memorize already computed methods
//if (cycle2Methods.containsKey(sm))
// throw new RuntimeException("error: there already exist a cycle with the same method! "+ printMethodAndStack(sm, stack));
// At this point the stack looks like this:
// 0 1 2 n-1
// M1|M2|M3|.....|Mn
// sm = M3
// sm is at depth n in the stack, but is not in the stack.
// Methods M3, M4, ... Mn have to be saved to be later
// updated with the correct permission set of M3.
Set<SootMethod> methods = new HashSet<SootMethod>();
int startIndex = stack.indexOf(sm);
for (int i=startIndex+1; i<stack.size(); i++)
methods.add(stack.elementAt(i));
CycleKey ck = new CycleKey(sm, stack.size()+1); // +1 since sm is not in the stack
if (cycle2Methods.keySet().contains(ck)){
cycle2Methods.get(ck).addAll(methods);
}
else{
cycle2Methods.put(ck, methods);
}
cache.addAll(methods);
System.out.println("[cycle] add at depth '"+ stack.size() +"' for method '"+ sm +"'");
}
示例2: showsearch
import java.util.Stack; //导入方法依赖的package包/类
static void showsearch(Stack st, int i) {
System.out.print("search -> " + i);
Integer index = (Integer) st.search(i);
System.out.println("--index -> " + index);
System.out.println("stack: " + st);
}
示例3: isEnabled
import java.util.Stack; //导入方法依赖的package包/类
/**
* Indicates whether the this behaviour is current enabled or not
*
* @return true if the behaviour is enabled, false otherwise
*/
public boolean isEnabled()
{
Stack<Integer> stack = disabled.get();
return stack.search(hashCode()) == -1;
}