use of org.eclipse.collections.api.set.primitive.MutableIntSet in project eclipse-collections by eclipse.
the class PrimitiveStreamsTest method toIntSet.
@Test
public void toIntSet() {
MutableIntSet set = PrimitiveStreams.mIntSet(IntStream.rangeClosed(1, 10));
Assert.assertEquals(IntInterval.oneTo(10).toSet(), set);
Assert.assertEquals(IntSets.immutable.ofAll(IntStream.rangeClosed(1, 10)), set);
}
use of org.eclipse.collections.api.set.primitive.MutableIntSet in project eclipse-collections by eclipse.
the class IntIntMapProbeTest method testRandomRemove.
private void testRandomRemove(MutableIntIntMap intIntMap, int keyCount) {
Random random = new Random(0x123456789ABCDL);
MutableIntSet set = new IntHashSet(keyCount);
while (set.size() < keyCount) {
set.add(random.nextInt());
}
int[] intKeysForMap = set.toArray();
this.shuffle(intKeysForMap, random);
for (int i = 0; i < keyCount; i++) {
intIntMap.put(intKeysForMap[i], intKeysForMap[i] * 10);
}
this.shuffle(intKeysForMap, random);
for (int i = 0; i < intKeysForMap.length; i++) {
intIntMap.remove(intKeysForMap[i]);
for (int j = i + 1; j < intKeysForMap.length; j++) {
Assert.assertEquals((long) (intKeysForMap[j] * 10), intIntMap.get(intKeysForMap[j]));
}
}
}
use of org.eclipse.collections.api.set.primitive.MutableIntSet in project eclipse-collections by eclipse.
the class IntLongMapProbeTest method testRandomGet.
private void testRandomGet(MutableIntLongMap intlongMap, int keyCount) {
Random random = new Random(0x123456789ABCDL);
MutableIntSet set = new IntHashSet(keyCount);
while (set.size() < keyCount) {
set.add(random.nextInt());
}
int[] randomNumbersForMap = set.toArray();
this.shuffle(randomNumbersForMap, random);
for (int i = 0; i < keyCount; i++) {
intlongMap.put(randomNumbersForMap[i], (long) (randomNumbersForMap[i] * 10));
}
for (int i = 0; i < intlongMap.size(); i++) {
Assert.assertEquals((long) (randomNumbersForMap[i] * 10), intlongMap.get(randomNumbersForMap[i]));
}
}
use of org.eclipse.collections.api.set.primitive.MutableIntSet in project eclipse-collections by eclipse.
the class AbstractImmutableSet method collectInt.
@Override
public ImmutableIntSet collectInt(IntFunction<? super T> intFunction) {
MutableIntSet result = new IntHashSet(this.size());
this.forEach(new CollectIntProcedure<>(intFunction, result));
return result.toImmutable();
}
use of org.eclipse.collections.api.set.primitive.MutableIntSet in project eclipse-collections by eclipse.
the class AbstractMutableSet method collectInt.
@Override
public MutableIntSet collectInt(IntFunction<? super T> intFunction) {
MutableIntSet result = new IntHashSet(this.size());
this.forEach(new CollectIntProcedure<>(intFunction, result));
return result;
}
Aggregations