Search in sources :

Example 1 with IntArrayList

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

the class AbstractLazyIterableTestCase method collectIntWithTarget.

@Test
public void collectIntWithTarget() {
    MutableIntCollection target = new IntArrayList();
    MutableIntCollection result = this.lazyIterable.collectInt(PrimitiveFunctions.unboxIntegerToInt(), target);
    Assert.assertEquals(IntArrayList.newListWith(1, 2, 3, 4, 5, 6, 7), result.toList());
    Assert.assertSame("Target list sent as parameter not returned", target, result);
}
Also used : MutableIntCollection(org.eclipse.collections.api.collection.primitive.MutableIntCollection) IntArrayList(org.eclipse.collections.impl.list.mutable.primitive.IntArrayList) Test(org.junit.Test)

Example 2 with IntArrayList

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

the class AbstractImmutableSortedMap method collectInt.

@Override
public ImmutableIntList collectInt(IntFunction<? super V> intFunction) {
    IntArrayList result = new IntArrayList(this.size());
    this.forEach(new CollectIntProcedure<>(intFunction, result));
    return result.toImmutable();
}
Also used : IntArrayList(org.eclipse.collections.impl.list.mutable.primitive.IntArrayList)

Example 3 with IntArrayList

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

the class RandomAccessListAdapter method collectInt.

@Override
public MutableIntList collectInt(IntFunction<? super T> intFunction) {
    IntArrayList result = new IntArrayList(this.size());
    this.forEach(new CollectIntProcedure<>(intFunction, result));
    return result;
}
Also used : IntArrayList(org.eclipse.collections.impl.list.mutable.primitive.IntArrayList)

Example 4 with IntArrayList

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

the class ArrayListIterateTest method collectIntWithTarget.

@Test
public void collectIntWithTarget() {
    ArrayList<Integer> list = this.createIntegerList();
    MutableIntList target = new IntArrayList();
    MutableIntList actual = ArrayListIterate.collectInt(list, PrimitiveFunctions.unboxIntegerToInt(), target);
    Assert.assertSame("Target list sent as parameter not returned", target, actual);
    Assert.assertEquals(IntArrayList.newListWith(-1, 0, 4), actual);
}
Also used : MutableIntList(org.eclipse.collections.api.list.primitive.MutableIntList) IntArrayList(org.eclipse.collections.impl.list.mutable.primitive.IntArrayList) Test(org.junit.Test)

Example 5 with IntArrayList

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

the class IterateTest method collectIntWithTarget.

@Test
public void collectIntWithTarget() {
    this.iterables.each(each -> {
        MutableIntCollection expected = new IntArrayList();
        MutableIntCollection actual = Iterate.collectInt(each, PrimitiveFunctions.unboxIntegerToInt(), expected);
        Assert.assertTrue(actual.containsAll(1, 2, 3, 4, 5));
        Assert.assertSame("Target list sent as parameter not returned", expected, actual);
    });
    Verify.assertThrows(IllegalArgumentException.class, () -> Iterate.collectInt(null, PrimitiveFunctions.unboxIntegerToInt(), new IntArrayList()));
}
Also used : MutableIntCollection(org.eclipse.collections.api.collection.primitive.MutableIntCollection) IntArrayList(org.eclipse.collections.impl.list.mutable.primitive.IntArrayList) Test(org.junit.Test)

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