本文整理汇总了Java中org.opendaylight.yangtools.triemap.TrieMap类的典型用法代码示例。如果您正苦于以下问题:Java TrieMap类的具体用法?Java TrieMap怎么用?Java TrieMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TrieMap类属于org.opendaylight.yangtools.triemap包,在下文中一共展示了TrieMap类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateStatistics
import org.opendaylight.yangtools.triemap.TrieMap; //导入依赖的package包/类
private void updateStatistics(final String entityType, final String candidateName, final long count) {
TrieMap<String, Long> map = statistics.get(entityType);
if (map == null) {
map = TrieMap.create();
map.put(candidateName, count);
statistics.put(entityType, map);
} else {
Long candidateOwnedEntities = map.get(candidateName);
if (candidateOwnedEntities == null) {
map.put(candidateName, count);
} else {
map.put(candidateName, candidateOwnedEntities + count);
}
}
}
示例2: ReadWriteTrieMap
import org.opendaylight.yangtools.triemap.TrieMap; //导入依赖的package包/类
ReadWriteTrieMap() {
this.delegate = TrieMap.create();
this.size = 0;
}
示例3: testMethodsOfReadWriteTrieMap
import org.opendaylight.yangtools.triemap.TrieMap; //导入依赖的package包/类
@Test
public void testMethodsOfReadWriteTrieMap() {
final MutableTrieMap<String, String> trieMap = TrieMap.create();
trieMap.put("0", "zero");
trieMap.put("1", "one");
final ReadWriteTrieMap<String, String> readWriteTrieMap = new ReadWriteTrieMap<>(trieMap, 5);
assertNotNull("Object readOnlyTrieMap shouldn't be 'null'.", readWriteTrieMap);
assertEquals("Size of readOnlyTrieMap should be '5'.", 5, readWriteTrieMap.size());
assertFalse("Object readOnlyTrieMap shouldn't be empty.", readWriteTrieMap.isEmpty());
assertTrue("Object readOnlyTrieMap should have key '0'.", readWriteTrieMap.containsKey("0"));
assertTrue("Object readOnlyTrieMap should have value 'zero'.", readWriteTrieMap.containsValue("zero"));
assertEquals("Object readOnlyTrieMap should have value 'zero'.", "zero", readWriteTrieMap.get("0"));
final Map<String, String> rwMap = readWriteTrieMap;
rwMap.put("2", "two");
rwMap.put("3", "three");
assertEquals("Removed value from readOnlyTrieMap should be 'one'.", "one", rwMap.remove("1"));
final Set<String> trieMapKeySet = readWriteTrieMap.keySet();
assertEquals("Size of keySet should be '3'.", 3, trieMapKeySet.size());
final Collection<String> trieMapValues = readWriteTrieMap.values();
assertEquals("Size of values should be '3'.", 3, trieMapValues.size());
assertEquals(convertSetEntryToMap(readWriteTrieMap.entrySet()), trieMap);
trieMap.put("2", "two");
final ReadWriteTrieMap<String, String> readWriteTrieMap2 = new ReadWriteTrieMap<>(trieMap, 4);
assertNotEquals(readWriteTrieMap, readWriteTrieMap2);
assertEquals(readWriteTrieMap.hashCode(), readWriteTrieMap2.hashCode());
final Map<String, String> readOnlyTrieMap = readWriteTrieMap.toReadOnly();
readWriteTrieMap.clear();
assertEquals(0, readWriteTrieMap.size());
assertEquals(6, readOnlyTrieMap.size());
}