@Override public Iterable<N> depthFirstPreOrder(final Iterable<? extends N> startNodes) { checkNotNull(startNodes); if (Iterables.isEmpty(startNodes)) { return ImmutableSet.of(); } for (N node : startNodes) { checkThatNodeIsInTree(node); } return new Iterable<N>() { @Override public Iterator<N> iterator() { return new DepthFirstPreOrderIterator(startNodes); } }; }
@Override public Iterable<N> depthFirstPostOrder(final Iterable<? extends N> startNodes) { checkNotNull(startNodes); if (Iterables.isEmpty(startNodes)) { return ImmutableSet.of(); } for (N startNode : startNodes) { checkThatNodeIsInTree(startNode); } return new Iterable<N>() { @Override public Iterator<N> iterator() { return new DepthFirstPostOrderIterator(startNodes); } }; }
@Override public Iterable<N> breadthFirst(final Iterable<? extends N> startNodes) { checkNotNull(startNodes); if (Iterables.isEmpty(startNodes)) { return ImmutableSet.of(); } for (N startNode : startNodes) { checkThatNodeIsInGraph(startNode); } return new Iterable<N>() { @Override public Iterator<N> iterator() { return new BreadthFirstIterator(startNodes); } }; }
@Override public Iterable<N> depthFirstPreOrder(final Iterable<? extends N> startNodes) { checkNotNull(startNodes); if (Iterables.isEmpty(startNodes)) { return ImmutableSet.of(); } for (N startNode : startNodes) { checkThatNodeIsInGraph(startNode); } return new Iterable<N>() { @Override public Iterator<N> iterator() { return new DepthFirstIterator(startNodes, Order.PREORDER); } }; }
@Override public Iterable<N> depthFirstPostOrder(final Iterable<? extends N> startNodes) { checkNotNull(startNodes); if (Iterables.isEmpty(startNodes)) { return ImmutableSet.of(); } for (N startNode : startNodes) { checkThatNodeIsInGraph(startNode); } return new Iterable<N>() { @Override public Iterator<N> iterator() { return new DepthFirstIterator(startNodes, Order.POSTORDER); } }; }
@Override public Iterable<N> breadthFirst(final Iterable<? extends N> startNodes) { checkNotNull(startNodes); if (Iterables.isEmpty(startNodes)) { return ImmutableSet.of(); } for (N startNode : startNodes) { checkThatNodeIsInTree(startNode); } return new Iterable<N>() { @Override public Iterator<N> iterator() { return new BreadthFirstIterator(startNodes); } }; }
/** * Returns the most preferrable expression to be used as the canonical expression */ private static Expression getCanonical(Iterable<Expression> expressions) { if (Iterables.isEmpty(expressions)) { return null; } return CANONICAL_ORDERING.min(expressions); }
public static QualifiedName of(Iterable<String> originalParts) { requireNonNull(originalParts, "originalParts is null"); checkArgument(!isEmpty(originalParts), "originalParts is empty"); List<String> parts = ImmutableList.copyOf(transform(originalParts, part -> part.toLowerCase(ENGLISH))); return new QualifiedName(ImmutableList.copyOf(originalParts), parts); }
/** * Returns {@code true} if every element in {@code values} is {@linkplain #contains contained} in * this range. */ public boolean containsAll(Iterable<? extends C> values) { if (Iterables.isEmpty(values)) { return true; } // this optimizes testing equality of two range-backed sets if (values instanceof SortedSet) { SortedSet<? extends C> set = cast(values); Comparator<?> comparator = set.comparator(); if (Ordering.natural().equals(comparator) || comparator == null) { return contains(set.first()) && contains(set.last()); } } for (C value : values) { if (!contains(value)) { return false; } } return true; }
public static boolean isEmpty(Object obj) { Preconditions.checkArgument(obj != null); if (obj instanceof Traversal) return !((Traversal) obj).hasNext(); else if (obj instanceof Collection) return ((Collection)obj).isEmpty(); else if (obj instanceof Iterable) return Iterables.isEmpty((Iterable)obj); else if (obj instanceof Iterator) return !((Iterator)obj).hasNext(); else if (obj.getClass().isArray()) return Array.getLength(obj)==0; throw new IllegalArgumentException("Cannot determine size of: " + obj); }
@Override public Iterable<N> depthFirstPostOrder(final Iterable<? extends N> startNodes) { checkNotNull(startNodes); if (Iterables.isEmpty(startNodes)) { return ImmutableSet.of(); } for (N startNode : startNodes) { checkThatNodeIsInTree(startNode); } return new Iterable<N>() { @Override public Iterator<N> iterator() { return new DepthFirstPostOrderIterator(startNodes); } }; }
public static boolean hasAnyIndex(PropertyKey key) { InternalRelationType type = (InternalRelationType) key; return !Iterables.isEmpty(type.getKeyIndexes()) || Iterables.size(type.getRelationIndexes())>1; //The type itself is also returned as an index }
@Override public void visitFile(Component file) { Iterable<Duplication> duplications = duplicationRepository.getDuplications(file); if (!isEmpty(duplications)) { computeDuplications(file, duplications); } }
public void testSkip_structurallyModifiedSkipAllList() throws Exception { List<String> list = newArrayList("a", "b", "c"); Iterable<String> tail = skip(list, 2); list.subList(0, 2).clear(); assertTrue(Iterables.isEmpty(tail)); }
public void testPartition_empty() { Iterable<Integer> source = Collections.emptySet(); Iterable<List<Integer>> partitions = Iterables.partition(source, 1); assertTrue(Iterables.isEmpty(partitions)); }
private static void waitForSync(BatchServerInventoryView batchServerInventoryView, Set<DataSegment> testSegments) throws Exception { final Timing forWaitingTiming = timing.forWaiting(); Stopwatch stopwatch = Stopwatch.createStarted(); while (Iterables.isEmpty(batchServerInventoryView.getInventory()) || Iterables.size(Iterables.get(batchServerInventoryView.getInventory(), 0).getSegments()) != testSegments.size()) { Thread.sleep(100); if (stopwatch.elapsed(TimeUnit.MILLISECONDS) > forWaitingTiming.milliseconds()) { throw new ISE("BatchServerInventoryView is not updating"); } } }
@Test(timeOut = 20000) void testZNodeBypassed() throws Exception { ManagedLedger ledger = factory.open("my_test_ledger"); ManagedCursor c1 = ledger.newNonDurableCursor(PositionImpl.earliest); assertTrue(Iterables.isEmpty(ledger.getCursors())); c1.close(); ledger.close(); // Re-open ManagedLedger ledger2 = factory.open("my_test_ledger"); assertTrue(Iterables.isEmpty(ledger2.getCursors())); }
@Test public void testEmptySet() { SortedRangeSet rangeSet = SortedRangeSet.none(BIGINT); assertEquals(rangeSet.getType(), BIGINT); assertTrue(rangeSet.isNone()); assertFalse(rangeSet.isAll()); assertFalse(rangeSet.isSingleValue()); assertTrue(Iterables.isEmpty(rangeSet.getOrderedRanges())); assertEquals(rangeSet.getRangeCount(), 0); assertEquals(rangeSet.complement(), SortedRangeSet.all(BIGINT)); assertFalse(rangeSet.includesMarker(Marker.lowerUnbounded(BIGINT))); assertFalse(rangeSet.includesMarker(Marker.exactly(BIGINT, 0L))); assertFalse(rangeSet.includesMarker(Marker.upperUnbounded(BIGINT))); }
private void addDuplication(Component file, CloneGroup duplication) { ClonePart originPart = duplication.getOriginPart(); Iterable<Duplicate> duplicates = convertClonePartsToDuplicates(file, duplication); if (!Iterables.isEmpty(duplicates)) { duplicationRepository.add( file, new Duplication(new TextBlock(originPart.getStartLine(), originPart.getEndLine()), duplicates)); } }