当前位置: 首页>>代码示例>>Java>>正文


Java Stack.indexOf方法代码示例

本文整理汇总了Java中java.util.Stack.indexOf方法的典型用法代码示例。如果您正苦于以下问题:Java Stack.indexOf方法的具体用法?Java Stack.indexOf怎么用?Java Stack.indexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Stack的用法示例。


在下文中一共展示了Stack.indexOf方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addFragment

import java.util.Stack; //导入方法依赖的package包/类
/**
 * Adds the fragment as the child of parent, and shows it. If parent already has a child (and
 * possibly sub-children), those are removed.
 *
 * @param parent The parent of the added fragment
 * @param child  The fragment to add
 */
public void addFragment(@NonNull MainFragment parent, @NonNull MainFragment child) {
    for (int tabIndex = 0; tabIndex < mFragments.length; tabIndex++) {
        Stack<MainFragment> tabStack = mFragments[tabIndex];
        for (int level = 0; level < tabStack.size(); level++) {
            MainFragment fragment = tabStack.get(level);
            if (parent.equals(fragment)) {
                int diff = tabStack.size() - tabStack.indexOf(parent) - 1;
                for (int k = 0; k < diff; k++)
                    tabStack.pop();
                tabStack.push(child);
                showFragment(tabIndex, TAB_LEVEL_LAST, false);
                return;
            }
        }
    }
}
 
开发者ID:schul-cloud,项目名称:schulcloud-mobile-android,代码行数:24,代码来源:MainPresenter.java

示例2: addStackToCycle

import java.util.Stack; //导入方法依赖的package包/类
/**
 * 
 * @param stack
 * @param sm
 */
public void addStackToCycle(Stack<SootMethod> stack, SootMethod sm) {
  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)) {
    String s = "\n";
    for (int i=0; i<stack.size(); i++)
      s += i +"> "+ stack.elementAt(i) +"\n";
    throw new RuntimeException("error: cyclekey not in stack! "+ ck + s);
  }
  cycle2Methods.get(ck).addAll(methods);
  cache.addAll(methods);
  System.out.println("[cycle] add at depth '"+ stack.size() +"' for method '"+ sm +"'");
}
 
开发者ID:Alexandre-Bartel,项目名称:permission-map,代码行数:23,代码来源:Cycles.java

示例3: discoverWithDependencies

import java.util.Stack; //导入方法依赖的package包/类
private void discoverWithDependencies(Class<? extends F> type, Stack<F> stack) {
    final F facet = facet(type);
    if(!ordered.contains(facet)) {
        final int index = stack.indexOf(facet);
        if(index != -1) {
            // Guice supports this with proxies, but we don't, for now
            throw new IllegalStateException(
                "Circular facet dependency: " +
                Stream.concat(stack.subList(index, stack.size()).stream(), Stream.of(facet))
                      .map(f -> f.getClass().getSimpleName())
                      .collect(Collectors.joining(" -> "))
            );
        }

        stack.push(facet);
        try {
            Injection.dependencies(type).forEach(dependency -> {
                final Class<?> depType = Injection.dependencyType(dependency.getKey().getTypeLiteral()).getRawType();
                if(baseType.isAssignableFrom(depType)) {
                    discoverWithDependencies(depType.asSubclass(baseType), stack);
                }
            });
        } finally {
            stack.pop();
        }

        ordered.add(facet);
        discover(facet);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:31,代码来源:FacetContext.java

示例4: 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 +"'");

}
 
开发者ID:Alexandre-Bartel,项目名称:permission-map,代码行数:37,代码来源:Cycles.java


注:本文中的java.util.Stack.indexOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。