org.apache.commons.collections4.map.MultiKeyMap Java Examples
The following examples show how to use
org.apache.commons.collections4.map.MultiKeyMap.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MultiKeysTest.java From onetwo with Apache License 2.0 | 5 votes |
@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); }
Example #2
Source File: CommonCollections.java From j360-dubbo-app-all with Apache License 2.0 | 2 votes |
/** * 联合多个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); }