本文整理汇总了Java中java.util.Stack.contains方法的典型用法代码示例。如果您正苦于以下问题:Java Stack.contains方法的具体用法?Java Stack.contains怎么用?Java Stack.contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Stack
的用法示例。
在下文中一共展示了Stack.contains方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: walk
import java.util.Stack; //导入方法依赖的package包/类
private void walk ( final Stack<DataSourceNode> stack, final DataSourceNode node )
{
if ( stack.contains ( node ) )
{
this.logStream.println ( "Loop found: " + StringHelper.join ( stack, " -> " ) );
// loop found
return;
}
stack.push ( node );
for ( final DataSourceNode ref : node.getReferences () )
{
walk ( stack, ref );
}
stack.pop ();
}
示例2: addCycleIfNecessary
import java.util.Stack; //导入方法依赖的package包/类
public boolean addCycleIfNecessary(Stack<SootMethod> stack, SootMethod m) {
// check if m is in the stack
if (stack.contains(m)) {
addCycle(stack, m);
return true;
}
// check if m is in cache
if (!cache.contains(m))
return false;
// check if m is in registered cycles
for (CycleKey k: cycle2Methods.keySet())
for (SootMethod tgt: cycle2Methods.get(k))
if (m.toString().equals(tgt.toString())) {
addStackToCycle(stack, k.bottomMethod()); // add the stack to k, *not* m
break;
}
return false;
}
示例3: hasLoopHashtable
import java.util.Stack; //导入方法依赖的package包/类
public boolean hasLoopHashtable() {
Node temp = head;
Stack<Node> stack = new Stack<>();
while (temp != null) {
if (stack.contains(temp)) {
temp.next = null;
return true;
}
stack.add(temp);
temp = temp.next;
}
return false;
}
示例4: _stackContains
import java.util.Stack; //导入方法依赖的package包/类
private static boolean _stackContains(
Stack<String> stack,
Object value)
{
if (stack == null)
return false;
return stack.contains(value);
}
示例5: _resolveReferenceIcon
import java.util.Stack; //导入方法依赖的package包/类
/**
* Helper for resolveReferenceIcon which uses a Stack of icon names to detect circular
* dependencies.
*
* @param skin the Skin to use when resolving the ReferenceIcon
* @param refIcon a ReferenceIcon instance
* @param referencedIconStack The stack of reference icon names which have already been visited.
* Used to detect circular dependencies.
* @return icon which is resolved. i.e., it is not a ReferenceIcon.
*/
static private Icon _resolveReferenceIcon(
Skin skin,
ReferenceIcon refIcon,
Stack<String> referencedIconStack)
{
String refName = refIcon.getName();
// make sure we don't have a circular dependency
if ((referencedIconStack != null) && referencedIconStack.contains(refName))
{
if (_LOG.isWarning())
_LOG.warning("SKIN_CIRCULAR_INCLUDE_ERROR", refName);
return null;
}
if (referencedIconStack == null)
{
referencedIconStack = new Stack<String>();
}
referencedIconStack.push(refName);
Icon icon = skin.getIcon(refName, false);
if ((icon instanceof ReferenceIcon) && (icon != null))
{
return _resolveReferenceIcon(skin,
(ReferenceIcon) icon,
referencedIconStack);
}
return icon;
}
示例6: reachable
import java.util.Stack; //导入方法依赖的package包/类
/**
* Return true if the name sought is reachable via the next set of names passed using
* the dependency map. The stack passed records the path taken to find a cycle.
*/
private boolean reachable(TCNameToken sought, TCNameSet nextset,
Map<TCNameToken, TCNameSet> dependencies, Stack<TCNameToken> stack)
{
if (nextset == null)
{
return false;
}
if (nextset.contains(sought))
{
stack.push(sought);
return true;
}
for (TCNameToken nextname: nextset)
{
if (stack.contains(nextname)) // Been here before!
{
return false;
}
stack.push(nextname);
if (reachable(sought, dependencies.get(nextname), dependencies, stack))
{
return true;
}
stack.pop();
}
return false;
}
示例7: handle
import java.util.Stack; //导入方法依赖的package包/类
@Override
public DSubTree handle() {
DSubTree tree = new DSubTree();
// add the expression's subtree (e.g: foo(..).bar() should handle foo(..) first)
DSubTree Texp = new DOMExpression(invocation.getExpression()).handle();
tree.addNodes(Texp.getNodes());
// evaluate arguments first
for (Object o : invocation.arguments()) {
DSubTree Targ = new DOMExpression((Expression) o).handle();
tree.addNodes(Targ.getNodes());
}
IMethodBinding binding = invocation.resolveMethodBinding();
// get to the generic declaration, if this binding is an instantiation
while (binding != null && binding.getMethodDeclaration() != binding)
binding = binding.getMethodDeclaration();
MethodDeclaration localMethod = Utils.checkAndGetLocalMethod(binding);
if (localMethod != null) {
Stack<MethodDeclaration> callStack = Visitor.V().callStack;
if (! callStack.contains(localMethod)) {
callStack.push(localMethod);
DSubTree Tmethod = new DOMMethodDeclaration(localMethod).handle();
callStack.pop();
tree.addNodes(Tmethod.getNodes());
}
}
else if (Utils.isRelevantCall(binding))
tree.addNode(new DAPICall(binding, Visitor.V().getLineNumber(invocation)));
return tree;
}
示例8: search
import java.util.Stack; //导入方法依赖的package包/类
private static void search(CallGraph cg, SootMethod l, Stack<SootMethod> stack, int depth) {
logger.debug(" <"+ depth +"> propagate from "+ l);
if (depth == 1)
currentWrapper = l;
if (depth == 2) {
currentEntryPoint = l;
if (currentEntryPoint.toString().contains("GenerationGG") ||
//currentEntryPoint.toString().contains("init>") ||
currentEntryPoint.toString().contains("ServicesInit:")) {
} else {
if (!currentEntryPoint.toString().contains("DumbClass:")) {
EntryPointKey epk = new EntryPointKey(currentWrapper, currentEntryPoint);
entryPointsToPermissionSet.put(epk, null);
}
}
}
if (alreadyComputed.contains(l)) {
addPermissionsToStack(stack, l);
return;
}
Iterator<Edge> it = cg.edgesOutOf(l);
while (it.hasNext()) {
Edge e = it.next();
SootMethod outMethod = e.tgt();
if (outMethod.toString().equals(l.toString())){
logger.warn("outMethod same as l: "+ l);
continue;
}
if (stack.contains(outMethod))
throw new RuntimeException("cycle in stack!\n" + outMethod +"\n"+ Util.printStack(stack));
addPermissionsToStack(stack, outMethod);
stack.push(outMethod);
search(cg, outMethod, stack, depth+1);
stack.pop();
}
alreadyComputed.add(l);
if (!methodToPermissionSet.containsKey(l))
methodToPermissionSet.put(l, new HashSet<String>());
}