Search in sources :

Example 21 with IntArrayList

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

the class Subterms method indexOf.

/**
 * of all the matches to the predicate, chooses one at random and returns its index
 */
default int indexOf(Predicate<Term> t, Random r) {
    IntArrayList a = indicesOf(t);
    if (a == null)
        return -1;
    int as = a.size();
    if (as == 1)
        return a.get(0);
    else
        return a.get(r.nextInt(as));
}
Also used : IntArrayList(org.eclipse.collections.impl.list.mutable.primitive.IntArrayList)

Example 22 with IntArrayList

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

the class OrderedMapAdapter method collectInt.

@Override
public MutableIntList collectInt(IntFunction<? super V> 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 23 with IntArrayList

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

the class AbstractImmutableSortedSet method collectInt.

@Override
public ImmutableIntList collectInt(IntFunction<? super T> 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 24 with IntArrayList

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

the class AbstractMutableSortedMap method collectInt.

@Override
public MutableIntList collectInt(IntFunction<? super V> 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 25 with IntArrayList

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

the class AbstractRichIterableTestCase method collectIntWithTarget.

@Test
public void collectIntWithTarget() {
    MutableIntCollection target = new IntArrayList();
    IntIterable result = this.newWith(1, 2, 3, 4).collectInt(PrimitiveFunctions.unboxIntegerToInt(), target);
    Assert.assertSame("Target list sent as parameter not returned", target, result);
    Assert.assertEquals(IntHashBag.newBagWith(1, 2, 3, 4), result.toBag());
}
Also used : MutableIntCollection(org.eclipse.collections.api.collection.primitive.MutableIntCollection) IntArrayList(org.eclipse.collections.impl.list.mutable.primitive.IntArrayList) IntIterable(org.eclipse.collections.api.IntIterable) 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