use of gnu.trove.map.TLongLongMap in project deephaven-core by deephaven.
the class TestLongLongMap method do1MRandomOperationsLotsOfCollisions.
@Test
public void do1MRandomOperationsLotsOfCollisions() {
// Standard of correctness: java.util.HashMap
Map<Long, Long> reference = new HashMap<>(initialCapacity, loadFactor);
TLongLongMap test = factory.create(initialCapacity, loadFactor);
Random rng = new Random(12345);
populate(rng, 1000000, 10000, 0.75, reference, test);
TestCase.assertEquals(reference.size(), test.size());
Entries masterEntries = Entries.create(reference);
Entries targetEntries = Entries.create(test);
TestCase.assertTrue(masterEntries.destructivelyEquals(targetEntries));
}
use of gnu.trove.map.TLongLongMap in project deephaven-core by deephaven.
the class TestLongLongMap method iteratorFromEmptyAndNullMap.
@Test
public void iteratorFromEmptyAndNullMap() {
TLongLongMap map = factory.create(initialCapacity, loadFactor);
map.put(0, 1);
map.put(2, 3);
map.clear();
emptyMapHelper(map);
if (factory == troveFactory) {
return;
}
TNullableLongLongMap nullableMap = (TNullableLongLongMap) map;
nullableMap.resetToNull();
emptyMapHelper(map);
}
use of gnu.trove.map.TLongLongMap in project deephaven-core by deephaven.
the class TestLongLongMap method prevValuesOnRemove.
@Test
public void prevValuesOnRemove() {
final long beginKey = 100;
final long endKey = 200;
TLongLongMap map = factory.create(initialCapacity, loadFactor);
final long noEntryValue = map.getNoEntryValue();
for (long key = beginKey; key < endKey; ++key) {
final long previous = map.put(key, key - 10000);
TestCase.assertEquals(previous, noEntryValue);
}
for (long key = beginKey; key < endKey; ++key) {
final long expectedPrevious = key - 10000;
final long actualPrevious = map.remove(key);
TestCase.assertEquals(expectedPrevious, actualPrevious);
}
}
use of gnu.trove.map.TLongLongMap in project deephaven-core by deephaven.
the class TestLongLongMap method putIfAbsent.
@Test
public void putIfAbsent() {
final long beginKey = 100;
final long endKey = 200;
TLongLongMap map = factory.create(initialCapacity, loadFactor);
final long noEntryValue = map.getNoEntryValue();
for (long key = beginKey; key < endKey; key += 2) {
final long previous = map.put(key, key + 5000);
TestCase.assertEquals(previous, noEntryValue);
}
for (long key = beginKey; key < endKey; ++key) {
final long expectedPrevious = (key % 2) == 0 ? key + 5000 : noEntryValue;
final long actualPrevious = map.putIfAbsent(key, key + 10000);
TestCase.assertEquals(expectedPrevious, actualPrevious);
}
for (long key = beginKey; key < endKey; ++key) {
final long expectedValue = (key % 2) == 0 ? key + 5000 : key + 10000;
final long actualValue = map.get(key);
TestCase.assertEquals(expectedValue, actualValue);
}
}
Aggregations