Java Code Examples for java.util.Set#spliterator()

The following examples show how to use java.util.Set#spliterator() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CollectionsTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * Checks a Set that may or may not be instanceof SortedSet / NavigableSet
 * for adherence to a specified iteration order.
 */
private static <K> void check_orderedSet(
        Set<K> set, List<K> expectedElementsInOrder) {
    assertEquals(expectedElementsInOrder, new ArrayList<>(set));
    Set<K> copy = new HashSet<>(expectedElementsInOrder);
    assertEquals(copy, set);
    assertEquals(copy.hashCode(), set.hashCode());

    int numElements = set.size();
    assertEquals(expectedElementsInOrder.size(), numElements);
    Spliterator<K> spliterator = set.spliterator();
    SpliteratorTester.runBasicIterationTests(spliterator, expectedElementsInOrder);
    if (spliterator.hasCharacteristics(SIZED)) {
        SpliteratorTester.runSizedTests(set, numElements);
    }
    if (spliterator.hasCharacteristics(SUBSIZED)) {
        SpliteratorTester.runSubSizedTests(set, numElements);
    }
    assertHasCharacteristics(ORDERED | DISTINCT, spliterator);
    SpliteratorTester.runOrderedTests(set);
}
 
Example 2
Source File: HashSetIterationTest.java    From hellokoding-courses with MIT License 5 votes vote down vote up
@Test
public void iterateWithSplitIterator() {
    Set<Integer> set = new HashSet<>(Set.of(3, 1, 2));
    Spliterator<Integer> spliterator = set.spliterator();

    spliterator.tryAdvance(ele -> System.out.printf("%d ", ele));
}
 
Example 3
Source File: Int2ObjectHashMultimap.java    From metanome-algorithms with Apache License 2.0 4 votes vote down vote up
@Override
public Spliterator<Entry<Collection<T>>> spliterator() {
	Set<Entry<Collection<T>>> entries = entries();
	return entries.spliterator();
}