use of org.eclipse.collections.api.set.primitive.MutableIntSet 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.api.set.primitive.MutableIntSet 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.api.set.primitive.MutableIntSet in project eclipse-collections by eclipse.
the class IntIntMapLargeStressTest method getJDKSequenceCollisions.
protected MutableList<Integer> getJDKSequenceCollisions(int lower, int upper) {
MutableList<Integer> jdkCollidingNumbers = FastList.newList();
int slots = KEY_COUNT / (1 << 12) + 1;
MutableIntSet indices = new IntHashSet();
for (int i = lower; i < upper && jdkCollidingNumbers.size() < KEY_COUNT; i++) {
int index = this.jdkIndex(i);
if (indices.size() < slots) {
indices.add(index);
jdkCollidingNumbers.add(i);
} else if (indices.contains(index)) {
jdkCollidingNumbers.add(i);
}
}
return jdkCollidingNumbers;
}
use of org.eclipse.collections.api.set.primitive.MutableIntSet in project eclipse-collections by eclipse.
the class IntIntMapSmallStressTest method getJDKSequenceCollisions.
protected MutableList<Integer> getJDKSequenceCollisions(int lower, int upper) {
MutableList<Integer> jdkCollidingNumbers = FastList.newList();
// slots = KEY_COUNT / (1 << 32) / (1 << MAP_SIZE) + 1;
int slots = 1;
MutableIntSet indices = new IntHashSet();
for (int i = lower; i < upper && jdkCollidingNumbers.size() < KEY_COUNT; i++) {
int index = this.jdkIndex(i);
if (indices.size() < slots) {
indices.add(index);
jdkCollidingNumbers.add(i);
} else if (indices.contains(index)) {
jdkCollidingNumbers.add(i);
}
}
return jdkCollidingNumbers;
}
Aggregations