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

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

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

Stack.contains介绍

暂无

代码示例

代码示例来源:origin: JingYeoh/FragmentRigger

  1. /**
  2. * Pushes the specified object onto the top of the stack.
  3. *
  4. * @param fragmentTag Fragment's tag
  5. * @param containerViewId the containerView that fragment is added.
  6. */
  7. public boolean push(String fragmentTag, @IdRes int containerViewId) {
  8. if (mFragmentStack.contains(fragmentTag)) return false;
  9. mFragmentStack.push(fragmentTag);
  10. mFragmentContainerMap.put(fragmentTag, containerViewId);
  11. return true;
  12. }

代码示例来源:origin: org.testng/testng

  1. private void run(Graph<T> graph, T v) {
  2. m_indices.put(v, m_index);
  3. m_lowlinks.put(v, m_index);
  4. m_index++;
  5. m_s.push(v);
  6. for (T vprime : graph.getPredecessors(v)) {
  7. if (! m_indices.containsKey(vprime)) {
  8. run(graph, vprime);
  9. int min = Math.min(m_lowlinks.get(v), m_lowlinks.get(vprime));
  10. m_lowlinks.put(v, min);
  11. }
  12. else if (m_s.contains(vprime)) {
  13. m_lowlinks.put(v, Math.min(m_lowlinks.get(v), m_indices.get(vprime)));
  14. }
  15. }
  16. if (Objects.equals(m_lowlinks.get(v), m_indices.get(v))) {
  17. m_cycle = Lists.newArrayList();
  18. T n;
  19. do {
  20. n = m_s.pop();
  21. m_cycle.add(n);
  22. } while (! n.equals(v));
  23. }
  24. }

代码示例来源:origin: cbeust/testng

  1. private void run(Graph<T> graph, T v) {
  2. m_indices.put(v, m_index);
  3. m_lowlinks.put(v, m_index);
  4. m_index++;
  5. m_s.push(v);
  6. for (T vprime : graph.getPredecessors(v)) {
  7. if (!m_indices.containsKey(vprime)) {
  8. run(graph, vprime);
  9. int min = Math.min(m_lowlinks.get(v), m_lowlinks.get(vprime));
  10. m_lowlinks.put(v, min);
  11. } else if (m_s.contains(vprime)) {
  12. m_lowlinks.put(v, Math.min(m_lowlinks.get(v), m_indices.get(vprime)));
  13. }
  14. }
  15. if (Objects.equals(m_lowlinks.get(v), m_indices.get(v))) {
  16. m_cycle = Lists.newArrayList();
  17. T n;
  18. do {
  19. n = m_s.pop();
  20. m_cycle.add(n);
  21. } while (!n.equals(v));
  22. }
  23. }

代码示例来源:origin: Sable/soot

  1. lowlinkForNode.put(v, lowLinkForNodeV = index);
  2. index++;
  3. s.push(v);
  4. recurse(succ);
  5. lowlinkForNode.put(v, lowLinkForNodeV = Math.min(lowLinkForNodeV, lowlinkForNode.get(succ)));
  6. } else if (s.contains(succ)) {
  7. lowlinkForNode.put(v, lowLinkForNodeV = Math.min(lowLinkForNodeV, indexForNodeSucc));

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

  1. lowLinks.put(o, index.get());
  2. index.incrementAndGet();
  3. nodes.push(o);
  4. connect(child, index, nodes, indexes, lowLinks, components);
  5. lowLinks.put(o, Math.min(lowLinks.get(o), lowLinks.get(child)));
  6. } else if (nodes.contains(child)) {
  7. lowLinks.put(o, Math.min(lowLinks.get(o), indexes.get(child)));

代码示例来源:origin: Sable/soot

  1. lowlinkForNode.put(v, index);
  2. index++;
  3. s.push(v);
  4. isForward = true;
  5. } else if (isForward && s.contains(succ)) {
  6. int lowLinkForNodeV = lowlinkForNode.get(v);
  7. lowlinkForNode.put(v, Math.min(lowLinkForNodeV, indexForNodeSucc));

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

  1. lowLinks.put(o, index.get());
  2. index.incrementAndGet();
  3. nodes.push(o);
  4. connect(child, index, nodes, indexes, lowLinks, components);
  5. lowLinks.put(o, Math.min(lowLinks.get(o), lowLinks.get(child)));
  6. } else if (nodes.contains(child)) {
  7. lowLinks.put(o, Math.min(lowLinks.get(o), indexes.get(child)));

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

  1. lowLinks.put(o, index.get());
  2. index.incrementAndGet();
  3. nodes.push(o);
  4. connect(child, index, nodes, indexes, lowLinks, components, parseContext);
  5. lowLinks.put(o, Math.min(lowLinks.get(o), lowLinks.get(child)));
  6. } else if (nodes.contains(child)) {
  7. lowLinks.put(o, Math.min(lowLinks.get(o), indexes.get(child)));

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

  1. lowLinks.put(o, index.get());
  2. index.incrementAndGet();
  3. nodes.push(o);
  4. connect(child, index, nodes, indexes, lowLinks, components, parseContext);
  5. lowLinks.put(o, Math.min(lowLinks.get(o), lowLinks.get(child)));
  6. } else if (nodes.contains(child)) {
  7. lowLinks.put(o, Math.min(lowLinks.get(o), indexes.get(child)));

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

  1. if (!bonesStack.contains(bone)) {
  2. bonesStack.push(bone);
  3. BoneContext boneContext = blenderContext.getBoneContext(bone);
  4. if (!applied.contains(boneContext.getBoneOma())) {

代码示例来源:origin: weexteam/weex-hackernews

  1. @Override
  2. public V put(K key, V value) {
  3. if (key != null && key.toString() != null) {
  4. if (instancesStack.contains(key)) {
  5. instancesStack.remove(key);
  6. }
  7. instancesStack.push(key.toString());
  8. }
  9. return super.put(key, value);
  10. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. @Override
  2. public boolean visit(AutoBean<?> bean, Context ctx) {
  3. if (state.seen.contains(bean)) {
  4. throw new HaltException(new UnsupportedOperationException("Cycles not supported"));
  5. }
  6. state.seen.push(bean);
  7. state.sb.append("{");
  8. return true;
  9. }

代码示例来源:origin: cincheo/jsweet

  1. private static <T> void dumpCycles(List<Node<T>> nodes, Stack<Node<T>> path, Function<T, String> toString) {
  2. path.peek().outEdges.stream().map(e -> e.to).forEach(node -> {
  3. if (nodes.contains(node)) {
  4. if (path.contains(node)) {
  5. System.out.println(
  6. "cycle: " + path.stream().map(n -> toString.apply(n.element)).collect(Collectors.toList()));
  7. } else {
  8. path.push(node);
  9. dumpCycles(nodes, path, toString);
  10. path.pop();
  11. }
  12. }
  13. });
  14. ;
  15. }

代码示例来源:origin: zstackio/zstack

  1. private void buildObject(Object obj) throws IllegalAccessException {
  2. if (paths.contains(obj)) {
  3. paths.push(obj);
  4. throw new CloudRuntimeException(String.format("recursive object graph: %s", StringUtils.join(paths, " --> ")));
  5. paths.push(obj);
  6. List<Field> fs = FieldUtils.getAllFields(obj.getClass());
  7. for (Field f : fs) {
  8. trace.push(f.getName());
  9. take(f, obj);
  10. trace.pop();

代码示例来源:origin: zstackio/zstack

  1. private static JSONObject dumpObject(Class<?> clazz, Stack<Class> hasDone) throws JSONException {
  2. JSONObject jo = nj();
  3. if (hasDone.contains(clazz)) {
  4. jo.put("refer to", clazz.getName());
  5. return jo;
  6. hasDone.push(clazz);

代码示例来源:origin: zstackio/zstack

  1. private void buildList(Field f, Object obj) throws IllegalAccessException {
  2. CollectionGenericType type = (CollectionGenericType) FieldUtils.inferGenericTypeOnMapOrCollectionField(f);
  3. DebugUtils.Assert(List.class.isAssignableFrom(f.getType()), String.format("Collection must be List, but %s is %s", makePath(), type.getValueType().getName()));
  4. DebugUtils.Assert(type.isInferred(), String.format("Collection must use Generic, %s is not", makePath()));
  5. if (isNullValue(f, obj)) {
  6. return;
  7. }
  8. Object value = getValue(f, obj);
  9. List col = (List) value;
  10. if (col.isEmpty()) {
  11. return;
  12. }
  13. if (paths.contains(value)) {
  14. paths.push(value);
  15. throw new CloudRuntimeException(String.format("recursive object graph: %s", StringUtils.join(paths, " --> ")));
  16. }
  17. paths.push(value);
  18. for (Object item : col) {
  19. String itemName = String.format("%s[%s]", f.getName(), col.indexOf(item));
  20. trace.push(itemName);
  21. if (canDeserialize(type.getValueType())) {
  22. take(item);
  23. } else {
  24. buildObject(item);
  25. }
  26. trace.pop();
  27. }
  28. paths.pop();
  29. }

代码示例来源:origin: zstackio/zstack

  1. if (paths.contains(value)) {
  2. paths.push(value);
  3. throw new CloudRuntimeException(String.format("recursive object graph: %s", StringUtils.join(paths, " --> ")));
  4. paths.push(obj);
  5. Iterator<Entry> it = map.entrySet().iterator();
  6. while (it.hasNext()) {
  7. Object item = e.getValue();
  8. String itemName = String.format("%s[\"%s\"]", f.getName(), key);
  9. trace.push(itemName);
  10. if (canDeserialize(type.getValueType())) {
  11. take(item);

代码示例来源:origin: SpigotMC/BungeeCord

  1. if ( dependStack.contains( depend ) )
  2. } else
  3. dependStack.push( plugin );
  4. dependStatus = this.enablePlugin( pluginStatuses, dependStack, depend );
  5. dependStack.pop();

代码示例来源:origin: TEAMMATES/teammates

  1. /**
  2. * Switches to new browser window for browsing.
  3. */
  4. public void switchToNewWindow() {
  5. String curWin = driver.getWindowHandle();
  6. for (String handle : driver.getWindowHandles()) {
  7. if (!handle.equals(curWin) && !windowHandles.contains(curWin)) {
  8. windowHandles.push(curWin);
  9. driver.switchTo().window(handle);
  10. break;
  11. }
  12. }
  13. }

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

  1. if (processingTypes.contains(assignedName)) {
  2. if (LOGGER.isLoggable(Level.FINE)) {
  3. LOGGER.fine("Recursion found for type " + assignedName + ". Proxying it.");
  4. return attType;
  5. processingTypes.push(assignedName);

相关文章