@Test
public void test(){
MultiKey key1 = new MultiKey(32, "test");
MultiKey key2 = new MultiKey("test", 32);
Assert.assertEquals(key1.hashCode(), key2.hashCode());
Assert.assertNotEquals(key1, key2);
MultiKeyMap map = new MultiKeyMap();
map.put(key1, "test");
String value = (String)map.get(key1);
String value2 = (String)map.get(key1);
Assert.assertEquals(value, value2);
}
/**
* 联合多个Key来定位Value的HashMap.
*
* 普通HashMap,需要将多个Key拼装成一个字符串作为主键,因此MultiKeyMap尤其适合于这几个Key的类型不是String时.
*
* @param map 被包裹的底层HashMap,可先定义HashMap的初始大小和加载因子,可使用类型为LinkedMap
*/
public static <K, V> MultiKeyMap<K, V> multiKeyMap(final AbstractHashedMap<MultiKey<? extends K>, V> map) {
return MultiKeyMap.multiKeyMap(map);
}