Refine search
/** * Pushes the specified object onto the top of the stack. * * @param fragmentTag Fragment's tag * @param containerViewId the containerView that fragment is added. */ public boolean push(String fragmentTag, @IdRes int containerViewId) { if (mFragmentStack.contains(fragmentTag)) return false; mFragmentStack.push(fragmentTag); mFragmentContainerMap.put(fragmentTag, containerViewId); return true; }
private void run(Graph<T> graph, T v) { m_indices.put(v, m_index); m_lowlinks.put(v, m_index); m_index++; m_s.push(v); for (T vprime : graph.getPredecessors(v)) { if (! m_indices.containsKey(vprime)) { run(graph, vprime); int min = Math.min(m_lowlinks.get(v), m_lowlinks.get(vprime)); m_lowlinks.put(v, min); } else if (m_s.contains(vprime)) { m_lowlinks.put(v, Math.min(m_lowlinks.get(v), m_indices.get(vprime))); } } if (Objects.equals(m_lowlinks.get(v), m_indices.get(v))) { m_cycle = Lists.newArrayList(); T n; do { n = m_s.pop(); m_cycle.add(n); } while (! n.equals(v)); } }
private void run(Graph<T> graph, T v) { m_indices.put(v, m_index); m_lowlinks.put(v, m_index); m_index++; m_s.push(v); for (T vprime : graph.getPredecessors(v)) { if (!m_indices.containsKey(vprime)) { run(graph, vprime); int min = Math.min(m_lowlinks.get(v), m_lowlinks.get(vprime)); m_lowlinks.put(v, min); } else if (m_s.contains(vprime)) { m_lowlinks.put(v, Math.min(m_lowlinks.get(v), m_indices.get(vprime))); } } if (Objects.equals(m_lowlinks.get(v), m_indices.get(v))) { m_cycle = Lists.newArrayList(); T n; do { n = m_s.pop(); m_cycle.add(n); } while (!n.equals(v)); } }
lowLinks.put(o, index.get()); index.incrementAndGet(); nodes.push(o); connect(child, index, nodes, indexes, lowLinks, components, parseContext); lowLinks.put(o, Math.min(lowLinks.get(o), lowLinks.get(child))); } else if (nodes.contains(child)) { lowLinks.put(o, Math.min(lowLinks.get(o), indexes.get(child)));
lowLinks.put(o, index.get()); index.incrementAndGet(); nodes.push(o); connect(child, index, nodes, indexes, lowLinks, components, parseContext); lowLinks.put(o, Math.min(lowLinks.get(o), lowLinks.get(child))); } else if (nodes.contains(child)) { lowLinks.put(o, Math.min(lowLinks.get(o), indexes.get(child)));
private static <T> void dumpCycles(List<Node<T>> nodes, Stack<Node<T>> path, Function<T, String> toString) { path.peek().outEdges.stream().map(e -> e.to).forEach(node -> { if (nodes.contains(node)) { if (path.contains(node)) { System.out.println( "cycle: " + path.stream().map(n -> toString.apply(n.element)).collect(Collectors.toList())); } else { path.push(node); dumpCycles(nodes, path, toString); path.pop(); } } }); ; }
private void buildObject(Object obj) throws IllegalAccessException { if (paths.contains(obj)) { paths.push(obj); throw new CloudRuntimeException(String.format("recursive object graph: %s", StringUtils.join(paths, " --> "))); paths.push(obj); List<Field> fs = FieldUtils.getAllFields(obj.getClass()); for (Field f : fs) { trace.push(f.getName()); take(f, obj); trace.pop();
private void buildList(Field f, Object obj) throws IllegalAccessException { CollectionGenericType type = (CollectionGenericType) FieldUtils.inferGenericTypeOnMapOrCollectionField(f); DebugUtils.Assert(List.class.isAssignableFrom(f.getType()), String.format("Collection must be List, but %s is %s", makePath(), type.getValueType().getName())); DebugUtils.Assert(type.isInferred(), String.format("Collection must use Generic, %s is not", makePath())); if (isNullValue(f, obj)) { return; } Object value = getValue(f, obj); List col = (List) value; if (col.isEmpty()) { return; } if (paths.contains(value)) { paths.push(value); throw new CloudRuntimeException(String.format("recursive object graph: %s", StringUtils.join(paths, " --> "))); } paths.push(value); for (Object item : col) { String itemName = String.format("%s[%s]", f.getName(), col.indexOf(item)); trace.push(itemName); if (canDeserialize(type.getValueType())) { take(item); } else { buildObject(item); } trace.pop(); } paths.pop(); }
if (paths.contains(value)) { paths.push(value); throw new CloudRuntimeException(String.format("recursive object graph: %s", StringUtils.join(paths, " --> "))); paths.push(obj); Iterator<Entry> it = map.entrySet().iterator(); while (it.hasNext()) { Object item = e.getValue(); String itemName = String.format("%s[\"%s\"]", f.getName(), key); trace.push(itemName); if (canDeserialize(type.getValueType())) { take(item);
/** * Switches to new browser window for browsing. */ public void switchToNewWindow() { String curWin = driver.getWindowHandle(); for (String handle : driver.getWindowHandles()) { if (!handle.equals(curWin) && !windowHandles.contains(curWin)) { windowHandles.push(curWin); driver.switchTo().window(handle); break; } } }