Search in sources :

Example 26 with IntArrayList

use of org.eclipse.collections.impl.list.mutable.primitive.IntArrayList in project eclipse-collections by eclipse.

the class ArrayIterateTest method collectIntWithTarget.

@Test
public void collectIntWithTarget() {
    Integer[] objectArray = { -1, 0, 42 };
    IntArrayList target = new IntArrayList();
    IntArrayList result = ArrayIterate.collectInt(objectArray, PrimitiveFunctions.unboxIntegerToInt(), target);
    Assert.assertEquals(this.getExpectedIntResults(), result);
    Assert.assertSame("Target List not returned as result", target, result);
}
Also used : BigInteger(java.math.BigInteger) IntArrayList(org.eclipse.collections.impl.list.mutable.primitive.IntArrayList) Test(org.junit.Test)

Example 27 with IntArrayList

use of org.eclipse.collections.impl.list.mutable.primitive.IntArrayList in project eclipse-collections by eclipse.

the class ArrayListIterateTest method collectIntOverOptimizeLimit.

@Test
public void collectIntOverOptimizeLimit() {
    ArrayList<Integer> list = new ArrayList<>(Interval.zeroTo(OVER_OPTIMIZED_LIMIT));
    MutableIntList actual = ArrayListIterate.collectInt(list, PrimitiveFunctions.unboxIntegerToInt());
    IntArrayList expected = new IntArrayList(list.size());
    for (int i = 0; i <= OVER_OPTIMIZED_LIMIT; i++) {
        expected.add(i);
    }
    Assert.assertEquals(expected, actual);
}
Also used : MutableIntList(org.eclipse.collections.api.list.primitive.MutableIntList) DoubleArrayList(org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList) ShortArrayList(org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList) IntArrayList(org.eclipse.collections.impl.list.mutable.primitive.IntArrayList) ByteArrayList(org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList) CharArrayList(org.eclipse.collections.impl.list.mutable.primitive.CharArrayList) FloatArrayList(org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList) LongArrayList(org.eclipse.collections.impl.list.mutable.primitive.LongArrayList) ArrayList(java.util.ArrayList) BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) IntArrayList(org.eclipse.collections.impl.list.mutable.primitive.IntArrayList) Test(org.junit.Test)

Example 28 with IntArrayList

use of org.eclipse.collections.impl.list.mutable.primitive.IntArrayList in project eclipse-collections by eclipse.

the class ArrayListIterateTest method collectIntWithTargetOverOptimizeLimit.

@Test
public void collectIntWithTargetOverOptimizeLimit() {
    ArrayList<Integer> list = new ArrayList<>(Interval.zeroTo(OVER_OPTIMIZED_LIMIT));
    MutableIntList target = new IntArrayList();
    MutableIntList actual = ArrayListIterate.collectInt(list, PrimitiveFunctions.unboxIntegerToInt(), target);
    IntArrayList expected = new IntArrayList(list.size());
    for (int i = 0; i <= OVER_OPTIMIZED_LIMIT; i++) {
        expected.add(i);
    }
    Assert.assertEquals(expected, actual);
    Assert.assertSame("Target sent as parameter was not returned as result", target, actual);
}
Also used : MutableIntList(org.eclipse.collections.api.list.primitive.MutableIntList) DoubleArrayList(org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList) ShortArrayList(org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList) IntArrayList(org.eclipse.collections.impl.list.mutable.primitive.IntArrayList) ByteArrayList(org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList) CharArrayList(org.eclipse.collections.impl.list.mutable.primitive.CharArrayList) FloatArrayList(org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList) LongArrayList(org.eclipse.collections.impl.list.mutable.primitive.LongArrayList) ArrayList(java.util.ArrayList) BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) IntArrayList(org.eclipse.collections.impl.list.mutable.primitive.IntArrayList) Test(org.junit.Test)

Example 29 with IntArrayList

use of org.eclipse.collections.impl.list.mutable.primitive.IntArrayList 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 30 with IntArrayList

use of org.eclipse.collections.impl.list.mutable.primitive.IntArrayList in project eclipse-collections by eclipse.

the class CodePointAdapter method toList.

@Override
public MutableIntList toList() {
    IntArrayList list = new IntArrayList(this.adapted.length());
    for (int i = 0; i < this.adapted.length(); ) {
        int codePoint = this.adapted.codePointAt(i);
        list.add(codePoint);
        i += Character.charCount(codePoint);
    }
    return list;
}
Also used : IntArrayList(org.eclipse.collections.impl.list.mutable.primitive.IntArrayList)

Aggregations

IntArrayList (org.eclipse.collections.impl.list.mutable.primitive.IntArrayList)35 Test (org.junit.Test)10 MutableIntList (org.eclipse.collections.api.list.primitive.MutableIntList)8 MutableIntCollection (org.eclipse.collections.api.collection.primitive.MutableIntCollection)3 ArrayList (java.util.ArrayList)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 Nullable (org.jetbrains.annotations.Nullable)2 FingerPrint (il.technion.tinytable.hash.FingerPrint)1 java.io (java.io)1 BigInteger (java.math.BigInteger)1 java.util (java.util)1 BitSet (java.util.BitSet)1 Predicate (java.util.function.Predicate)1 ScriptException (javax.script.ScriptException)1