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