本文整理汇总了Java中java.util.NavigableMap.clear方法的典型用法代码示例。如果您正苦于以下问题:Java NavigableMap.clear方法的具体用法?Java NavigableMap.clear怎么用?Java NavigableMap.clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.NavigableMap
的用法示例。
在下文中一共展示了NavigableMap.clear方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testHeadMapContents
import java.util.NavigableMap; //导入方法依赖的package包/类
/**
* headMap returns map with keys in requested range
*/
public void testHeadMapContents() {
ConcurrentSkipListMap map = map5();
NavigableMap sm = map.headMap(four, false);
assertTrue(sm.containsKey(one));
assertTrue(sm.containsKey(two));
assertTrue(sm.containsKey(three));
assertFalse(sm.containsKey(four));
assertFalse(sm.containsKey(five));
Iterator i = sm.keySet().iterator();
Object k;
k = (Integer)(i.next());
assertEquals(one, k);
k = (Integer)(i.next());
assertEquals(two, k);
k = (Integer)(i.next());
assertEquals(three, k);
assertFalse(i.hasNext());
sm.clear();
assertTrue(sm.isEmpty());
assertEquals(2, map.size());
assertEquals(four, map.firstKey());
}
示例2: testHeadMapContents
import java.util.NavigableMap; //导入方法依赖的package包/类
/**
* headMap returns map with keys in requested range
*/
public void testHeadMapContents() {
TreeMap map = map5();
NavigableMap sm = map.headMap(four, false);
assertTrue(sm.containsKey(one));
assertTrue(sm.containsKey(two));
assertTrue(sm.containsKey(three));
assertFalse(sm.containsKey(four));
assertFalse(sm.containsKey(five));
Iterator i = sm.keySet().iterator();
Object k;
k = (Integer)(i.next());
assertEquals(one, k);
k = (Integer)(i.next());
assertEquals(two, k);
k = (Integer)(i.next());
assertEquals(three, k);
assertFalse(i.hasNext());
sm.clear();
assertTrue(sm.isEmpty());
assertEquals(2, map.size());
assertEquals(four, map.firstKey());
}
示例3: test_getVersions_String
import java.util.NavigableMap; //导入方法依赖的package包/类
@Test
public void test_getVersions_String() {
NavigableMap<String, ZoneRules> versions = ZoneRulesProvider.getVersions("Europe/London");
assertTrue(versions.size() >= 1);
ZoneRules rules = ZoneRulesProvider.getRules("Europe/London", false);
assertEquals(versions.lastEntry().getValue(), rules);
NavigableMap<String, ZoneRules> copy = new TreeMap<>(versions);
versions.clear();
assertEquals(versions.size(), 0);
NavigableMap<String, ZoneRules> versions2 = ZoneRulesProvider.getVersions("Europe/London");
assertEquals(versions2, copy);
}
示例4: testSerialization
import java.util.NavigableMap; //导入方法依赖的package包/类
/**
* A deserialized/reserialized map equals original
*/
public void testSerialization() throws Exception {
NavigableMap x = map5();
NavigableMap y = serialClone(x);
assertNotSame(x, y);
assertEquals(x.size(), y.size());
assertEquals(x.toString(), y.toString());
assertEquals(x, y);
assertEquals(y, x);
y.clear();
assertTrue(y.isEmpty());
assertFalse(x.equals(y));
}
示例5: testEquals
import java.util.NavigableMap; //导入方法依赖的package包/类
/**
* Maps with same contents are equal
*/
public void testEquals() {
NavigableMap map1 = map5();
NavigableMap map2 = map5();
assertEquals(map1, map2);
assertEquals(map2, map1);
map1.clear();
assertFalse(map1.equals(map2));
assertFalse(map2.equals(map1));
}
示例6: testDescendingEquals
import java.util.NavigableMap; //导入方法依赖的package包/类
/**
* Maps with same contents are equal
*/
public void testDescendingEquals() {
NavigableMap map1 = dmap5();
NavigableMap map2 = dmap5();
assertEquals(map1, map2);
assertEquals(map2, map1);
map1.clear();
assertFalse(map1.equals(map2));
assertFalse(map2.equals(map1));
}
示例7: testClear
import java.util.NavigableMap; //导入方法依赖的package包/类
/**
* clear removes all pairs
*/
public void testClear() {
NavigableMap map = map5();
map.clear();
assertEquals(0, map.size());
}
示例8: testDescendingClear
import java.util.NavigableMap; //导入方法依赖的package包/类
/**
* clear removes all pairs
*/
public void testDescendingClear() {
NavigableMap map = dmap5();
map.clear();
assertEquals(0, map.size());
}