Search in sources :

Example 1 with Consumer

use of java8.util.function.Consumer in project streamsupport by stefan-zobel.

the class StreamSpliteratorTest method testDoubleSplitting.

// 
public void testDoubleSplitting() {
    List<Consumer<DoubleStream>> terminalOps = Arrays.asList(s -> s.toArray(), s -> s.forEach(e -> {
    }), s -> s.reduce(java8.lang.Doubles::sum));
    List<UnaryOperator<DoubleStream>> intermediateOps = Arrays.asList(s -> s.parallel(), // The following ensures the wrapping spliterator is tested
    s -> s.map(i -> i).parallel());
    for (int i = 0; i < terminalOps.size(); i++) {
        Consumer<DoubleStream> terminalOp = terminalOps.get(i);
        setContext("termOpIndex", i);
        for (int j = 0; j < intermediateOps.size(); j++) {
            UnaryOperator<DoubleStream> intermediateOp = intermediateOps.get(j);
            setContext("intOpIndex", j);
            for (boolean proxyEstimateSize : new boolean[] { false, true }) {
                setContext("proxyEstimateSize", proxyEstimateSize);
                // Size is assumed to be larger than the target size for no splitting
                // @@@ Need way to obtain the target size
                Spliterator.OfDouble sp = intermediateOp.apply(IntStreams.range(0, 1000).asDoubleStream()).spliterator();
                ProxyNoExactSizeSpliterator.OfDouble psp = new ProxyNoExactSizeSpliterator.OfDouble(sp, proxyEstimateSize);
                DoubleStream s = StreamSupport.doubleStream(psp, true);
                terminalOp.accept(s);
                Assert.assertTrue(psp.splits > 0, String.format("Number of splits should be greater that zero when proxyEstimateSize is %s", proxyEstimateSize));
                Assert.assertTrue(psp.prefixSplits > 0, String.format("Number of non-null prefix splits should be greater that zero when proxyEstimateSize is %s", proxyEstimateSize));
                Assert.assertTrue(psp.sizeOnTraversal < 1000, String.format("Size on traversal of last split should be less than the size of the list, %d, when proxyEstimateSize is %s", 1000, proxyEstimateSize));
            }
        }
    }
}
Also used : LongConsumer(java8.util.function.LongConsumer) LambdaTestHelpers.irDoubler(java8.util.stream.LambdaTestHelpers.irDoubler) Arrays(java.util.Arrays) IntConsumer(java8.util.function.IntConsumer) LambdaTestHelpers.countTo(java8.util.stream.LambdaTestHelpers.countTo) LongStreamTestDataProvider(java8.util.stream.LongStreamTestDataProvider) UnaryOperator(java8.util.function.UnaryOperator) Test(org.testng.annotations.Test) LambdaTestHelpers.ipEven(java8.util.stream.LambdaTestHelpers.ipEven) DoubleStreamTestDataProvider(java8.util.stream.DoubleStreamTestDataProvider) TestData(java8.util.stream.TestData) LambdaTestHelpers.lpEven(java8.util.stream.LambdaTestHelpers.lpEven) LambdaTestHelpers.dpEven(java8.util.stream.LambdaTestHelpers.dpEven) Function(java8.util.function.Function) LambdaTestHelpers(java8.util.stream.LambdaTestHelpers) LongStreams(java8.util.stream.LongStreams) Assert(org.testng.Assert) Consumer(java8.util.function.Consumer) StreamTestDataProvider(java8.util.stream.StreamTestDataProvider) LambdaTestHelpers.pEven(java8.util.stream.LambdaTestHelpers.pEven) DoubleStreams(java8.util.stream.DoubleStreams) Spliterator(java8.util.Spliterator) IntStream(java8.util.stream.IntStream) OpTestCase(java8.util.stream.OpTestCase) SpliteratorTestHelper(java8.util.stream.SpliteratorTestHelper) Spliterators(java8.util.Spliterators) LongStream(java8.util.stream.LongStream) StreamSupport(java8.util.stream.StreamSupport) IntStreams(java8.util.stream.IntStreams) List(java.util.List) RefStreams(java8.util.stream.RefStreams) LambdaTestHelpers.mDoubler(java8.util.stream.LambdaTestHelpers.mDoubler) LambdaTestHelpers.permuteStreamFunctions(java8.util.stream.LambdaTestHelpers.permuteStreamFunctions) DoubleStream(java8.util.stream.DoubleStream) Comparator(java.util.Comparator) IntStreamTestDataProvider(java8.util.stream.IntStreamTestDataProvider) DoubleConsumer(java8.util.function.DoubleConsumer) Stream(java8.util.stream.Stream) LongConsumer(java8.util.function.LongConsumer) IntConsumer(java8.util.function.IntConsumer) Consumer(java8.util.function.Consumer) DoubleConsumer(java8.util.function.DoubleConsumer) DoubleStream(java8.util.stream.DoubleStream) UnaryOperator(java8.util.function.UnaryOperator) Spliterator(java8.util.Spliterator)

Example 2 with Consumer

use of java8.util.function.Consumer in project streamsupport by stefan-zobel.

the class Collection8Test method testElementRemovalDuringTraversal.

/**
 * All elements removed in the middle of CONCURRENT traversal.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test(dataProvider = "Source")
public void testElementRemovalDuringTraversal(String description, Supplier<CollectionImplementation> sci) {
    CollectionImplementation impl = sci.get();
    if (HAS_JAVA8_SPLITERATOR_BUG && LinkedBlockingQueue.class.equals(impl.klazz())) {
        // https://bugs.openjdk.java.net/browse/JDK-8171051
        return;
    }
    Collection<Object> c = impl.emptyCollection();
    ThreadLocalRandom rnd = ThreadLocalRandom.current();
    int n = rnd.nextInt(6);
    ArrayList copy = new ArrayList();
    for (int i = 0; i < n; i++) {
        Object x = impl.makeElement(i);
        copy.add(x);
        c.add(x);
    }
    ArrayList iterated = new ArrayList();
    ArrayList spliterated = new ArrayList();
    Spliterator<?> s = Spliterators.spliterator(c);
    Iterator<?> it = c.iterator();
    for (int i = rnd.nextInt(n + 1); --i >= 0; ) {
        assertTrue(s.tryAdvance(spliterated::add));
        if (rnd.nextBoolean())
            assertTrue(it.hasNext());
        iterated.add(it.next());
    }
    Consumer alwaysThrows = e -> {
        throw new AssertionError();
    };
    if (s.hasCharacteristics(Spliterator.CONCURRENT)) {
        // TODO: many more removal methods
        c.clear();
        if (testImplementationDetails && !(c instanceof java.util.concurrent.ArrayBlockingQueue)) {
            if (rnd.nextBoolean())
                assertFalse(s.tryAdvance(alwaysThrows));
            else
                s.forEachRemaining(alwaysThrows);
        }
        if (it.hasNext())
            iterated.add(it.next());
        if (rnd.nextBoolean())
            assertIteratorExhausted(it);
    }
    assertTrue(copy.containsAll(iterated));
    assertTrue(copy.containsAll(spliterated));
}
Also used : Arrays(java.util.Arrays) DataProvider(org.testng.annotations.DataProvider) PriorityQueue(java.util.PriorityQueue) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Test(org.testng.annotations.Test) Iterables(java8.lang.Iterables) Deque(java.util.Deque) Predicate(java8.util.function.Predicate) AtomicReference(java.util.concurrent.atomic.AtomicReference) ArrayList(java.util.ArrayList) PriorityBlockingQueue(java.util.concurrent.PriorityBlockingQueue) HashSet(java.util.HashSet) Phaser(java8.util.concurrent.Phaser) Iterators(java8.util.Iterators) Future(java.util.concurrent.Future) J8Arrays(java8.util.J8Arrays) Vector(java.util.Vector) Consumer(java8.util.function.Consumer) LinkedList(java.util.LinkedList) NoSuchElementException(java.util.NoSuchElementException) ExecutorService(java.util.concurrent.ExecutorService) Iterator(java.util.Iterator) BlockingDeque(java.util.concurrent.BlockingDeque) Collection(java.util.Collection) Spliterator(java8.util.Spliterator) Set(java.util.Set) BlockingQueue(java.util.concurrent.BlockingQueue) Collectors(java8.util.stream.Collectors) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) Spliterators(java8.util.Spliterators) CopyOnWriteArraySet(java.util.concurrent.CopyOnWriteArraySet) StreamSupport(java8.util.stream.StreamSupport) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Executors(java.util.concurrent.Executors) Supplier(java8.util.function.Supplier) CountDownLatch(java.util.concurrent.CountDownLatch) AtomicLong(java.util.concurrent.atomic.AtomicLong) List(java.util.List) ThreadLocalRandom(java8.util.concurrent.ThreadLocalRandom) LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) HOURS(java.util.concurrent.TimeUnit.HOURS) Queue(java.util.Queue) ArrayDeque(java.util.ArrayDeque) Collections(java.util.Collections) ConcurrentModificationException(java.util.ConcurrentModificationException) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Consumer(java8.util.function.Consumer) ThreadLocalRandom(java8.util.concurrent.ThreadLocalRandom) Test(org.testng.annotations.Test)

Example 3 with Consumer

use of java8.util.function.Consumer in project streamsupport by stefan-zobel.

the class Collection8Test method emptyMeansEmpty.

@SuppressWarnings({ "rawtypes", "unchecked" })
void emptyMeansEmpty(Collection<?> c, Supplier<CollectionImplementation> sci) throws InterruptedException {
    assertTrue(c.isEmpty());
    assertEquals(0, c.size());
    assertEquals("[]", c.toString());
    if (c instanceof List<?>) {
        List x = (List) c;
        assertEquals(1, x.hashCode());
        assertEquals(x, Collections.emptyList());
        assertEquals(Collections.emptyList(), x);
        assertEquals(-1, x.indexOf(sci.get().makeElement(86)));
        assertEquals(-1, x.lastIndexOf(sci.get().makeElement(99)));
        assertThrows(IndexOutOfBoundsException.class, () -> x.get(0), () -> x.set(0, sci.get().makeElement(42)));
    } else if (c instanceof Set<?>) {
        assertEquals(0, c.hashCode());
        assertEquals(c, Collections.emptySet());
        assertEquals(Collections.emptySet(), c);
    }
    {
        Object[] a = c.toArray();
        assertEquals(0, a.length);
        assertSame(Object[].class, a.getClass());
    }
    {
        Object[] a = new Object[0];
        assertSame(a, c.toArray(a));
    }
    {
        Integer[] a = new Integer[0];
        assertSame(a, c.toArray(a));
    }
    {
        Integer[] a = { 1, 2, 3 };
        assertSame(a, c.toArray(a));
        assertNull(a[0]);
        assertSame(2, a[1]);
        assertSame(3, a[2]);
    }
    assertIteratorExhausted(c.iterator());
    Consumer alwaysThrows = e -> {
        throw new AssertionError();
    };
    Iterables.forEach(c, alwaysThrows);
    Iterators.forEachRemaining(c.iterator(), alwaysThrows);
    Spliterators.spliterator(c).forEachRemaining(alwaysThrows);
    assertFalse(Spliterators.spliterator(c).tryAdvance(alwaysThrows));
    if (Spliterators.spliterator(c).hasCharacteristics(Spliterator.SIZED))
        assertEquals(0, Spliterators.spliterator(c).estimateSize());
    assertFalse(c.contains(bomb()));
    assertFalse(c.remove(bomb()));
    if (c instanceof Queue) {
        Queue<?> q = (Queue<?>) c;
        assertNull(q.peek());
        assertNull(q.poll());
    }
    if (c instanceof Deque) {
        Deque<?> d = (Deque<?>) c;
        assertNull(d.peekFirst());
        assertNull(d.peekLast());
        assertNull(d.pollFirst());
        assertNull(d.pollLast());
        assertIteratorExhausted(d.descendingIterator());
        Iterators.forEachRemaining(d.descendingIterator(), alwaysThrows);
        assertFalse(d.removeFirstOccurrence(bomb()));
        assertFalse(d.removeLastOccurrence(bomb()));
    }
    if (c instanceof BlockingQueue) {
        BlockingQueue<?> q = (BlockingQueue<?>) c;
        assertNull(q.poll(randomExpiredTimeout(), randomTimeUnit()));
    }
    if (c instanceof BlockingDeque) {
        BlockingDeque<?> q = (BlockingDeque<?>) c;
        assertNull(q.pollFirst(randomExpiredTimeout(), randomTimeUnit()));
        assertNull(q.pollLast(randomExpiredTimeout(), randomTimeUnit()));
    }
}
Also used : Arrays(java.util.Arrays) DataProvider(org.testng.annotations.DataProvider) PriorityQueue(java.util.PriorityQueue) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Test(org.testng.annotations.Test) Iterables(java8.lang.Iterables) Deque(java.util.Deque) Predicate(java8.util.function.Predicate) AtomicReference(java.util.concurrent.atomic.AtomicReference) ArrayList(java.util.ArrayList) PriorityBlockingQueue(java.util.concurrent.PriorityBlockingQueue) HashSet(java.util.HashSet) Phaser(java8.util.concurrent.Phaser) Iterators(java8.util.Iterators) Future(java.util.concurrent.Future) J8Arrays(java8.util.J8Arrays) Vector(java.util.Vector) Consumer(java8.util.function.Consumer) LinkedList(java.util.LinkedList) NoSuchElementException(java.util.NoSuchElementException) ExecutorService(java.util.concurrent.ExecutorService) Iterator(java.util.Iterator) BlockingDeque(java.util.concurrent.BlockingDeque) Collection(java.util.Collection) Spliterator(java8.util.Spliterator) Set(java.util.Set) BlockingQueue(java.util.concurrent.BlockingQueue) Collectors(java8.util.stream.Collectors) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) Spliterators(java8.util.Spliterators) CopyOnWriteArraySet(java.util.concurrent.CopyOnWriteArraySet) StreamSupport(java8.util.stream.StreamSupport) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Executors(java.util.concurrent.Executors) Supplier(java8.util.function.Supplier) CountDownLatch(java.util.concurrent.CountDownLatch) AtomicLong(java.util.concurrent.atomic.AtomicLong) List(java.util.List) ThreadLocalRandom(java8.util.concurrent.ThreadLocalRandom) LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) HOURS(java.util.concurrent.TimeUnit.HOURS) Queue(java.util.Queue) ArrayDeque(java.util.ArrayDeque) Collections(java.util.Collections) ConcurrentModificationException(java.util.ConcurrentModificationException) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) PriorityBlockingQueue(java.util.concurrent.PriorityBlockingQueue) BlockingQueue(java.util.concurrent.BlockingQueue) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Deque(java.util.Deque) BlockingDeque(java.util.concurrent.BlockingDeque) LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) ArrayDeque(java.util.ArrayDeque) Consumer(java8.util.function.Consumer) BlockingDeque(java.util.concurrent.BlockingDeque) LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) PriorityQueue(java.util.PriorityQueue) PriorityBlockingQueue(java.util.concurrent.PriorityBlockingQueue) BlockingQueue(java.util.concurrent.BlockingQueue) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Queue(java.util.Queue) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue)

Example 4 with Consumer

use of java8.util.function.Consumer in project streamsupport by stefan-zobel.

the class Collection8Test method testStickySpliteratorExhaustion.

/**
 * Concurrent Spliterators, once exhausted, stay exhausted.
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test(dataProvider = "Source")
public void testStickySpliteratorExhaustion(String description, Supplier<CollectionImplementation> sci) throws Throwable {
    CollectionImplementation impl = sci.get();
    if (HAS_JAVA8_SPLITERATOR_BUG && PriorityBlockingQueue.class.equals(impl.klazz())) {
        // https://bugs.openjdk.java.net/browse/JDK-8172023
        return;
    }
    if (!impl.isConcurrent())
        return;
    if (!testImplementationDetails)
        return;
    final ThreadLocalRandom rnd = ThreadLocalRandom.current();
    final Consumer<?> alwaysThrows = e -> {
        throw new AssertionError();
    };
    final Collection c = impl.emptyCollection();
    final Spliterator s = Spliterators.spliterator(c);
    if (rnd.nextBoolean()) {
        assertFalse(s.tryAdvance(alwaysThrows));
    } else {
        s.forEachRemaining(alwaysThrows);
    }
    final Object one = impl.makeElement(1);
    // Spliterator should not notice added element
    c.add(one);
    if (rnd.nextBoolean()) {
        assertFalse(s.tryAdvance(alwaysThrows));
    } else {
        s.forEachRemaining(alwaysThrows);
    }
}
Also used : Arrays(java.util.Arrays) DataProvider(org.testng.annotations.DataProvider) PriorityQueue(java.util.PriorityQueue) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Test(org.testng.annotations.Test) Iterables(java8.lang.Iterables) Deque(java.util.Deque) Predicate(java8.util.function.Predicate) AtomicReference(java.util.concurrent.atomic.AtomicReference) ArrayList(java.util.ArrayList) PriorityBlockingQueue(java.util.concurrent.PriorityBlockingQueue) HashSet(java.util.HashSet) Phaser(java8.util.concurrent.Phaser) Iterators(java8.util.Iterators) Future(java.util.concurrent.Future) J8Arrays(java8.util.J8Arrays) Vector(java.util.Vector) Consumer(java8.util.function.Consumer) LinkedList(java.util.LinkedList) NoSuchElementException(java.util.NoSuchElementException) ExecutorService(java.util.concurrent.ExecutorService) Iterator(java.util.Iterator) BlockingDeque(java.util.concurrent.BlockingDeque) Collection(java.util.Collection) Spliterator(java8.util.Spliterator) Set(java.util.Set) BlockingQueue(java.util.concurrent.BlockingQueue) Collectors(java8.util.stream.Collectors) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) Spliterators(java8.util.Spliterators) CopyOnWriteArraySet(java.util.concurrent.CopyOnWriteArraySet) StreamSupport(java8.util.stream.StreamSupport) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Executors(java.util.concurrent.Executors) Supplier(java8.util.function.Supplier) CountDownLatch(java.util.concurrent.CountDownLatch) AtomicLong(java.util.concurrent.atomic.AtomicLong) List(java.util.List) ThreadLocalRandom(java8.util.concurrent.ThreadLocalRandom) LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) HOURS(java.util.concurrent.TimeUnit.HOURS) Queue(java.util.Queue) ArrayDeque(java.util.ArrayDeque) Collections(java.util.Collections) ConcurrentModificationException(java.util.ConcurrentModificationException) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ThreadLocalRandom(java8.util.concurrent.ThreadLocalRandom) Collection(java.util.Collection) PriorityBlockingQueue(java.util.concurrent.PriorityBlockingQueue) Spliterator(java8.util.Spliterator) Test(org.testng.annotations.Test)

Example 5 with Consumer

use of java8.util.function.Consumer in project streamsupport by stefan-zobel.

the class Collection8Test method testForEach.

/**
 * collection.forEach returns elements in the collection
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test(dataProvider = "Source")
public void testForEach(String description, Supplier<CollectionImplementation> sci) throws Throwable {
    CollectionImplementation impl = sci.get();
    final Collection c = impl.emptyCollection();
    // final AtomicLong count = new AtomicLong(0L);
    final Object x = impl.makeElement(1);
    final Object y = impl.makeElement(2);
    final ArrayList found = new ArrayList();
    Consumer<Object> spy = o -> found.add(o);
    Iterables.forEach(c, spy);
    assertTrue(found.isEmpty());
    assertTrue(c.add(x));
    Iterables.forEach(c, spy);
    assertEquals(Collections.singletonList(x), found);
    found.clear();
    assertTrue(c.add(y));
    Iterables.forEach(c, spy);
    assertEquals(2, found.size());
    assertTrue(found.contains(x));
    assertTrue(found.contains(y));
    found.clear();
    c.clear();
    Iterables.forEach(c, spy);
    assertTrue(found.isEmpty());
}
Also used : Arrays(java.util.Arrays) DataProvider(org.testng.annotations.DataProvider) PriorityQueue(java.util.PriorityQueue) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Test(org.testng.annotations.Test) Iterables(java8.lang.Iterables) Deque(java.util.Deque) Predicate(java8.util.function.Predicate) AtomicReference(java.util.concurrent.atomic.AtomicReference) ArrayList(java.util.ArrayList) PriorityBlockingQueue(java.util.concurrent.PriorityBlockingQueue) HashSet(java.util.HashSet) Phaser(java8.util.concurrent.Phaser) Iterators(java8.util.Iterators) Future(java.util.concurrent.Future) J8Arrays(java8.util.J8Arrays) Vector(java.util.Vector) Consumer(java8.util.function.Consumer) LinkedList(java.util.LinkedList) NoSuchElementException(java.util.NoSuchElementException) ExecutorService(java.util.concurrent.ExecutorService) Iterator(java.util.Iterator) BlockingDeque(java.util.concurrent.BlockingDeque) Collection(java.util.Collection) Spliterator(java8.util.Spliterator) Set(java.util.Set) BlockingQueue(java.util.concurrent.BlockingQueue) Collectors(java8.util.stream.Collectors) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) Spliterators(java8.util.Spliterators) CopyOnWriteArraySet(java.util.concurrent.CopyOnWriteArraySet) StreamSupport(java8.util.stream.StreamSupport) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Executors(java.util.concurrent.Executors) Supplier(java8.util.function.Supplier) CountDownLatch(java.util.concurrent.CountDownLatch) AtomicLong(java.util.concurrent.atomic.AtomicLong) List(java.util.List) ThreadLocalRandom(java8.util.concurrent.ThreadLocalRandom) LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) HOURS(java.util.concurrent.TimeUnit.HOURS) Queue(java.util.Queue) ArrayDeque(java.util.ArrayDeque) Collections(java.util.Collections) ConcurrentModificationException(java.util.ConcurrentModificationException) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Collection(java.util.Collection) Test(org.testng.annotations.Test)

Aggregations

Consumer (java8.util.function.Consumer)11 List (java.util.List)10 StreamSupport (java8.util.stream.StreamSupport)10 Test (org.testng.annotations.Test)10 Arrays (java.util.Arrays)9 Spliterator (java8.util.Spliterator)9 Spliterators (java8.util.Spliterators)9 Iterator (java.util.Iterator)7 LinkedList (java.util.LinkedList)7 NoSuchElementException (java.util.NoSuchElementException)7 AtomicLong (java.util.concurrent.atomic.AtomicLong)7 ArrayDeque (java.util.ArrayDeque)6 ArrayList (java.util.ArrayList)6 Collection (java.util.Collection)6 Collections (java.util.Collections)6 ConcurrentModificationException (java.util.ConcurrentModificationException)6 Deque (java.util.Deque)6 HashSet (java.util.HashSet)6 PriorityQueue (java.util.PriorityQueue)6 Queue (java.util.Queue)6