use of org.eclipse.collections.impl.set.mutable.primitive.IntHashSet 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.impl.set.mutable.primitive.IntHashSet 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;
}
use of org.eclipse.collections.impl.set.mutable.primitive.IntHashSet in project eclipse-collections by eclipse.
the class IntIntMapProbeTest method testRandomGet.
private void testRandomGet(MutableIntIntMap intIntMap, 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++) {
intIntMap.put(randomNumbersForMap[i], randomNumbersForMap[i] * 10);
}
for (int i = 0; i < intIntMap.size(); i++) {
Assert.assertEquals((long) (randomNumbersForMap[i] * 10), intIntMap.get(randomNumbersForMap[i]));
}
}
use of org.eclipse.collections.impl.set.mutable.primitive.IntHashSet in project eclipse-collections by eclipse.
the class IntLongMapProbeTest method testRandomRemove.
private void testRandomRemove(MutableIntLongMap intlongMap, 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++) {
intlongMap.put(intKeysForMap[i], (long) (intKeysForMap[i] * 10));
}
this.shuffle(intKeysForMap, random);
for (int i = 0; i < intKeysForMap.length; i++) {
intlongMap.remove(intKeysForMap[i]);
for (int j = i + 1; j < intKeysForMap.length; j++) {
Assert.assertEquals((long) (intKeysForMap[j] * 10), intlongMap.get(intKeysForMap[j]));
}
}
}
use of org.eclipse.collections.impl.set.mutable.primitive.IntHashSet in project eclipse-collections by eclipse.
the class CodePointAdapter method toSet.
@Override
public MutableIntSet toSet() {
IntHashSet set = new IntHashSet(this.adapted.length());
for (int i = 0; i < this.adapted.length(); ) {
int codePoint = this.adapted.codePointAt(i);
set.add(codePoint);
i += Character.charCount(codePoint);
}
return set;
}
Aggregations