Search in sources :

Example 16 with MutableIntList

use of org.eclipse.collections.api.list.primitive.MutableIntList in project eclipse-collections by eclipse.

the class IntLongMapProbeTest method getSmallCollidingNumbers.

private MutableIntList getSmallCollidingNumbers() {
    int lower = Integer.MIN_VALUE;
    int upper = Integer.MAX_VALUE;
    MutableIntList collidingNumbers = new IntArrayList();
    int numberOne = this.smallMask(SpreadFunctions.intSpreadOne(0xABCDEF1));
    int numberTwo = this.smallMask(SpreadFunctions.intSpreadTwo(0xABCDEF1));
    for (int i = lower; i < upper && collidingNumbers.size() < SMALL_COLLIDING_KEY_COUNT; i++) {
        if (this.smallMask(SpreadFunctions.intSpreadOne(i)) == numberOne && this.smallMask(SpreadFunctions.intSpreadTwo(i)) == numberTwo) {
            collidingNumbers.add(i);
        }
    }
    return collidingNumbers;
}
Also used : MutableIntList(org.eclipse.collections.api.list.primitive.MutableIntList) IntArrayList(org.eclipse.collections.impl.list.mutable.primitive.IntArrayList)

Example 17 with MutableIntList

use of org.eclipse.collections.api.list.primitive.MutableIntList in project eclipse-collections by eclipse.

the class CodePointAdapter method chunk.

@Override
public RichIterable<IntIterable> chunk(int size) {
    if (size <= 0) {
        throw new IllegalArgumentException("Size for groups must be positive but was: " + size);
    }
    MutableList<IntIterable> result = Lists.mutable.empty();
    if (this.notEmpty()) {
        if (this.size() <= size) {
            result.add(IntLists.immutable.withAll(this));
        } else {
            IntIterator iterator = this.intIterator();
            while (iterator.hasNext()) {
                MutableIntList batch = IntLists.mutable.empty();
                for (int i = 0; i < size && iterator.hasNext(); i++) {
                    batch.add(iterator.next());
                }
                result.add(CodePointList.from(batch));
            }
        }
    }
    return result.toImmutable();
}
Also used : IntIterator(org.eclipse.collections.api.iterator.IntIterator) MutableIntList(org.eclipse.collections.api.list.primitive.MutableIntList) IntIterable(org.eclipse.collections.api.IntIterable) AbstractIntIterable(org.eclipse.collections.impl.primitive.AbstractIntIterable) ReverseIntIterable(org.eclipse.collections.impl.lazy.primitive.ReverseIntIterable) LazyIntIterable(org.eclipse.collections.api.LazyIntIterable)

Example 18 with MutableIntList

use of org.eclipse.collections.api.list.primitive.MutableIntList in project eclipse-collections by eclipse.

the class AbstractListTestCase method collectInt.

@Override
public void collectInt() {
    super.collectInt();
    MutableIntList result = this.newWith(1, 2, 3, 4).collectInt(PrimitiveFunctions.unboxIntegerToInt());
    Assert.assertEquals(IntLists.mutable.of(1, 2, 3, 4), result);
}
Also used : MutableIntList(org.eclipse.collections.api.list.primitive.MutableIntList)

Example 19 with MutableIntList

use of org.eclipse.collections.api.list.primitive.MutableIntList in project neo4j by neo4j.

the class PartitionedSeekTest method assertEntries.

private static IntList assertEntries(long from, long to, Collection<Seeker<MutableLong, MutableLong>> seekers) throws IOException {
    long nextExpected = from;
    MutableIntList entryCountPerSeeker = IntLists.mutable.empty();
    for (Seeker<MutableLong, MutableLong> seeker : seekers) {
        int count = 0;
        while (nextExpected < to && seeker.next()) {
            assertEquals(nextExpected, seeker.key().longValue());
            nextExpected++;
            count++;
        }
        entryCountPerSeeker.add(count);
    }
    assertEquals(to, nextExpected);
    return entryCountPerSeeker;
}
Also used : MutableLong(org.apache.commons.lang3.mutable.MutableLong) MutableIntList(org.eclipse.collections.api.list.primitive.MutableIntList)

Aggregations

MutableIntList (org.eclipse.collections.api.list.primitive.MutableIntList)19 IntArrayList (org.eclipse.collections.impl.list.mutable.primitive.IntArrayList)8 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)2 IntIterable (org.eclipse.collections.api.IntIterable)2 LazyIntIterable (org.eclipse.collections.api.LazyIntIterable)2 IntIterator (org.eclipse.collections.api.iterator.IntIterator)2 ReverseIntIterable (org.eclipse.collections.impl.lazy.primitive.ReverseIntIterable)2 BooleanArrayList (org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList)2 ByteArrayList (org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList)2 CharArrayList (org.eclipse.collections.impl.list.mutable.primitive.CharArrayList)2 DoubleArrayList (org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList)2 FloatArrayList (org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList)2 LongArrayList (org.eclipse.collections.impl.list.mutable.primitive.LongArrayList)2 ShortArrayList (org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList)2 MutableLong (org.apache.commons.lang3.mutable.MutableLong)1 SelectIntIterable (org.eclipse.collections.impl.lazy.primitive.SelectIntIterable)1 AbstractIntIterable (org.eclipse.collections.impl.primitive.AbstractIntIterable)1 Test (org.junit.jupiter.api.Test)1 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)1