当前位置: 首页>>代码示例>>Java>>正文


Java TrieMap类代码示例

本文整理汇总了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);
        }
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:16,代码来源:EntityOwnershipStatistics.java

示例2: ReadWriteTrieMap

import org.opendaylight.yangtools.triemap.TrieMap; //导入依赖的package包/类
ReadWriteTrieMap() {
    this.delegate = TrieMap.create();
    this.size = 0;
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:5,代码来源:ReadWriteTrieMap.java

示例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());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:43,代码来源:ReadWriteTrieMapTest.java


注:本文中的org.opendaylight.yangtools.triemap.TrieMap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。