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));
}
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;
}
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();
}
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;
}
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());
}
Aggregations