Search in sources :

Example 16 with LongIterator

use of org.eclipse.collections.api.iterator.LongIterator in project neo4j by neo4j.

the class PrimitiveLongCollectionsTest method arrayOfItemsAsIterator.

@Test
void arrayOfItemsAsIterator() {
    // GIVEN
    long[] items = new long[] { 2, 5, 234 };
    // WHEN
    LongIterator iterator = PrimitiveLongCollections.iterator(items);
    // THEN
    assertItems(iterator, items);
}
Also used : LongIterator(org.eclipse.collections.api.iterator.LongIterator) Test(org.junit.jupiter.api.Test)

Example 17 with LongIterator

use of org.eclipse.collections.api.iterator.LongIterator in project neo4j by neo4j.

the class PrimitiveLongCollectionsTest method singleIterator.

@Test
void singleIterator() {
    LongIterator iterator = PrimitiveLongCollections.single(42);
    assertTrue(iterator.hasNext());
    assertEquals(42, iterator.next());
    assertFalse(iterator.hasNext());
    assertThrows(NoSuchElementException.class, iterator::next);
}
Also used : LongIterator(org.eclipse.collections.api.iterator.LongIterator) Test(org.junit.jupiter.api.Test)

Example 18 with LongIterator

use of org.eclipse.collections.api.iterator.LongIterator in project neo4j by neo4j.

the class PrimitiveLongCollectionsTest method asArray.

@Test
void asArray() {
    // GIVEN
    LongIterator items = PrimitiveLongCollections.iterator(1, 2, 3);
    // WHEN
    long[] array = PrimitiveLongCollections.asArray(items);
    // THEN
    assertArrayEquals(new long[] { 1, 2, 3 }, array);
}
Also used : LongIterator(org.eclipse.collections.api.iterator.LongIterator) Test(org.junit.jupiter.api.Test)

Example 19 with LongIterator

use of org.eclipse.collections.api.iterator.LongIterator in project neo4j by neo4j.

the class PrimitiveLongArrayQueueTest method tailBeforeHeadCorrectIteration.

@Test
void tailBeforeHeadCorrectIteration() {
    PrimitiveLongArrayQueue queue = createQueue();
    for (int i = 0; i < 14; i++) {
        queue.enqueue(i);
    }
    for (int i = 0; i < 10; i++) {
        assertEquals(i, queue.dequeue());
    }
    for (int i = 14; i < 24; i++) {
        queue.enqueue(i);
    }
    assertEquals(14, queue.size());
    LongIterator iterator = queue.longIterator();
    for (int j = 10; j < 24; j++) {
        assertTrue(iterator.hasNext());
        assertEquals(j, iterator.next());
    }
    assertFalse(iterator.hasNext());
}
Also used : LongIterator(org.eclipse.collections.api.iterator.LongIterator) Test(org.junit.jupiter.api.Test)

Example 20 with LongIterator

use of org.eclipse.collections.api.iterator.LongIterator in project neo4j by neo4j.

the class DocValuesCollectorTest method shouldReturnDocValuesInRelevanceOrder.

@Test
void shouldReturnDocValuesInRelevanceOrder() throws Exception {
    // given
    DocValuesCollector collector = new DocValuesCollector(true);
    IndexReaderStub readerStub = indexReaderWithMaxDocs(42);
    // when
    collector.doSetNextReader(readerStub.getContext());
    collector.setScorer(constantScorer(1.0f));
    collector.collect(1);
    collector.setScorer(constantScorer(2.0f));
    collector.collect(2);
    // then
    LongIterator valuesIterator = collector.getValuesSortedByRelevance("id");
    assertEquals(2, valuesIterator.next());
    assertEquals(1, valuesIterator.next());
    assertFalse(valuesIterator.hasNext());
}
Also used : IndexReaderStub(org.neo4j.kernel.api.impl.index.IndexReaderStub) LongIterator(org.eclipse.collections.api.iterator.LongIterator) Test(org.junit.jupiter.api.Test)

Aggregations

LongIterator (org.eclipse.collections.api.iterator.LongIterator)45 Test (org.junit.Test)16 Test (org.junit.jupiter.api.Test)15 MutableLongSet (org.eclipse.collections.api.set.primitive.MutableLongSet)9 MutableLongIterator (org.eclipse.collections.api.iterator.MutableLongIterator)5 MutableLongCollection (org.eclipse.collections.api.collection.primitive.MutableLongCollection)4 LongSet (org.eclipse.collections.api.set.primitive.LongSet)3 IndexReaderStub (org.neo4j.kernel.api.impl.index.IndexReaderStub)3 LazyLongIterable (org.eclipse.collections.api.LazyLongIterable)2 LongIterable (org.eclipse.collections.api.LongIterable)2 LongArrayList (org.eclipse.collections.impl.list.mutable.primitive.LongArrayList)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 RelationshipChangesForNode.createRelationshipChangesForNode (org.neo4j.kernel.impl.api.state.RelationshipChangesForNode.createRelationshipChangesForNode)2 IOException (java.io.IOException)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 MutableLongList (org.eclipse.collections.api.list.primitive.MutableLongList)1 ImmutableEmptyLongIterator (org.eclipse.collections.impl.iterator.ImmutableEmptyLongIterator)1 AbstractPrimitiveLongBaseIterator (org.neo4j.collection.PrimitiveLongCollections.AbstractPrimitiveLongBaseIterator)1 RangeLongIterator (org.neo4j.collection.RangeLongIterator)1