forked from Speiger/Primitive-Collections
Maps.get function is no longer using Suffixes unless its absolutely
necessary.
This commit is contained in:
parent
357b40e670
commit
ce8f49cd1f
|
@ -7,3 +7,4 @@
|
||||||
- Removed: Suffixes for unmodifiable & synchronize functions.
|
- Removed: Suffixes for unmodifiable & synchronize functions.
|
||||||
- Changed: Primitive Stacks no longer depend on the base Stack class. Because seriously not needed.
|
- Changed: Primitive Stacks no longer depend on the base Stack class. Because seriously not needed.
|
||||||
- Changed: PriorityQueues no longer extends Object Variant.
|
- Changed: PriorityQueues no longer extends Object Variant.
|
||||||
|
- Changed: Maps.get function is no longer using Suffixes unless its absolutely necessary.
|
|
@ -230,7 +230,8 @@ public class GlobalVariables
|
||||||
addFunctionMappers("ENTRY_KEY", "get%sKey");
|
addFunctionMappers("ENTRY_KEY", "get%sKey");
|
||||||
addFunctionValueMappers("ENTRY_VALUE", "get%sValue");
|
addFunctionValueMappers("ENTRY_VALUE", "get%sValue");
|
||||||
addFunctionMapper("GET_KEY", "get");
|
addFunctionMapper("GET_KEY", "get");
|
||||||
addFunctionValueMapper("GET_VALUE", valueType.isObject() ? "getObject" : "get");
|
if(type.isObject()) addFunctionValueMapper("GET_VALUE", valueType.isObject() ? "getObject" : "get");
|
||||||
|
else addSimpleMapper("GET_VALUE", "get");
|
||||||
addFunctionMapper("LAST_KEY", "last");
|
addFunctionMapper("LAST_KEY", "last");
|
||||||
addFunctionValueMapper("MERGE", "merge");
|
addFunctionValueMapper("MERGE", "merge");
|
||||||
addFunctionMapper("NEXT", "next");
|
addFunctionMapper("NEXT", "next");
|
||||||
|
|
|
@ -33,7 +33,7 @@ public abstract class BaseInt2IntMapTest
|
||||||
Assert.assertEquals(1, putMap.put(513, 2));
|
Assert.assertEquals(1, putMap.put(513, 2));
|
||||||
Assert.assertEquals(PUT_ARRAY.length + 1, putMap.size());
|
Assert.assertEquals(PUT_ARRAY.length + 1, putMap.size());
|
||||||
Assert.assertEquals(512, putMap.addTo(0, 1));
|
Assert.assertEquals(512, putMap.addTo(0, 1));
|
||||||
Assert.assertEquals(513, putMap.getInt(0));
|
Assert.assertEquals(513, putMap.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -70,13 +70,13 @@ public abstract class BaseInt2IntMapTest
|
||||||
if(!getValidMapTests().contains(MapTests.REPLACE)) return;
|
if(!getValidMapTests().contains(MapTests.REPLACE)) return;
|
||||||
Int2IntMap map = createMap(TEST_ARRAY, TEST_ARRAY);
|
Int2IntMap map = createMap(TEST_ARRAY, TEST_ARRAY);
|
||||||
Assert.assertEquals(0, map.replace(0, 512));
|
Assert.assertEquals(0, map.replace(0, 512));
|
||||||
Assert.assertEquals(512, map.getInt(0));
|
Assert.assertEquals(512, map.get(0));
|
||||||
Assert.assertTrue(map.replace(0, 512, 0));
|
Assert.assertTrue(map.replace(0, 512, 0));
|
||||||
Assert.assertFalse(map.replace(0, 512, 0));
|
Assert.assertFalse(map.replace(0, 512, 0));
|
||||||
map = createMap(TEST_ARRAY, TEST_ARRAY);
|
map = createMap(TEST_ARRAY, TEST_ARRAY);
|
||||||
map.replaceInts((K, V) -> 99 - V);
|
map.replaceInts((K, V) -> 99 - V);
|
||||||
Assert.assertEquals(99, map.getInt(0));
|
Assert.assertEquals(99, map.get(0));
|
||||||
Assert.assertEquals(0, map.getInt(99));
|
Assert.assertEquals(0, map.get(99));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -85,7 +85,7 @@ public abstract class BaseInt2IntMapTest
|
||||||
if(!getValidMapTests().contains(MapTests.COMPUTE)) return;
|
if(!getValidMapTests().contains(MapTests.COMPUTE)) return;
|
||||||
Int2IntMap map = createMap(TEST_ARRAY, TEST_ARRAY);
|
Int2IntMap map = createMap(TEST_ARRAY, TEST_ARRAY);
|
||||||
Assert.assertEquals(512, map.computeInt(0, (K, V) -> 512));
|
Assert.assertEquals(512, map.computeInt(0, (K, V) -> 512));
|
||||||
Assert.assertEquals(512, map.getInt(0));
|
Assert.assertEquals(512, map.get(0));
|
||||||
Assert.assertEquals(512, map.computeIntIfAbsent(0, T -> 0));
|
Assert.assertEquals(512, map.computeIntIfAbsent(0, T -> 0));
|
||||||
Assert.assertEquals(0, map.computeIntIfPresent(0, (T, V) -> 0));
|
Assert.assertEquals(0, map.computeIntIfPresent(0, (T, V) -> 0));
|
||||||
Assert.assertEquals(0, map.computeIntIfAbsent(-10, T -> 0));
|
Assert.assertEquals(0, map.computeIntIfAbsent(-10, T -> 0));
|
||||||
|
@ -107,7 +107,7 @@ public abstract class BaseInt2IntMapTest
|
||||||
Int2IntMap map = createMap(TEST_ARRAY, TEST_ARRAY);
|
Int2IntMap map = createMap(TEST_ARRAY, TEST_ARRAY);
|
||||||
for(int i = 0;i<TEST_ARRAY.length;i++)
|
for(int i = 0;i<TEST_ARRAY.length;i++)
|
||||||
{
|
{
|
||||||
Assert.assertEquals(i, map.getInt(i));
|
Assert.assertEquals(i, map.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue