use of gnu.trove.map.TLongLongMap in project deephaven-core by deephaven.
the class TestLongLongMap method prevValuesOnInsert.
@Test
public void prevValuesOnInsert() {
final long beginKey = 100;
final long endKey = 200;
final long beginValue = 5000;
final long endValue = 5010;
TLongLongMap map = factory.create(initialCapacity, loadFactor);
final long noEntryValue = map.getNoEntryValue();
for (long valueBase = beginValue; valueBase < endValue; ++valueBase) {
for (long key = beginKey; key < endKey; ++key) {
final long expectedPrevious = valueBase == beginValue ? noEntryValue : key + valueBase - 1;
final long actualPrevious = map.put(key, key + valueBase);
TestCase.assertEquals(expectedPrevious, actualPrevious);
}
}
}
use of gnu.trove.map.TLongLongMap in project deephaven-core by deephaven.
the class TestLongLongMap method zeroComesBackThroughKeys.
@Test
public void zeroComesBackThroughKeys() {
TLongLongMap map = factory.create(initialCapacity, loadFactor);
final long specialKey = HashMapBase.SPECIAL_KEY_FOR_EMPTY_SLOT;
map.put(specialKey, 12345);
long[] keys = map.keys();
TestCase.assertEquals(keys.length, 1);
TestCase.assertEquals(keys[0], specialKey);
}
use of gnu.trove.map.TLongLongMap in project deephaven-core by deephaven.
the class TestLongLongMap method badKeys.
@Test
public void badKeys() {
// Trove doesn't have key limitations
if (factory == troveFactory) {
return;
}
TLongLongMap map = factory.create(initialCapacity, loadFactor);
try {
map.put(HashMapBase.SPECIAL_KEY_FOR_DELETED_SLOT, 12345);
TestCase.fail("SPECIAL_KEY_FOR_DELETED_SLOT should not be accepted");
} catch (io.deephaven.base.verify.AssertionFailure e) {
// do nothing
}
try {
map.put(HashMapBase.REDIRECTED_KEY_FOR_EMPTY_SLOT, 12345);
TestCase.fail("REDIRECTED_KEY_FOR_EMPTY_SLOT should not be accepted");
} catch (io.deephaven.base.verify.AssertionFailure e) {
// do nothing
}
}
use of gnu.trove.map.TLongLongMap in project SkyBot by DuncteBot.
the class GuildSettingsUtils method loadVcAutoRoles.
public static void loadVcAutoRoles(Variables variables) {
final DatabaseAdapter adapter = variables.getDatabaseAdapter();
final TLongObjectMap<TLongLongMap> vcAutoRoleCache = variables.getVcAutoRoleCache();
LOGGER.info("Loading vc auto roles.");
adapter.getVcAutoRoles((items) -> {
items.forEach((item) -> {
final TLongLongMap cache = Optional.ofNullable(vcAutoRoleCache.get(item.getGuildId())).orElseGet(() -> {
// This returns the old value which was null
vcAutoRoleCache.put(item.getGuildId(), new TLongLongHashMap());
return vcAutoRoleCache.get(item.getGuildId());
});
cache.put(item.getVoiceChannelId(), item.getRoleId());
});
LOGGER.info("Loaded " + items.size() + " vc auto roles.");
return null;
});
}
use of gnu.trove.map.TLongLongMap in project deephaven-core by deephaven.
the class TestLongLongMap method zeroKey.
@Test
public void zeroKey() {
TLongLongMap map = factory.create(initialCapacity, loadFactor);
map.put(0, 12345);
TestCase.assertEquals(map.get(0), 12345);
TestCase.assertEquals(map.size(), 1);
}
Aggregations