本文整理匯總了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());
}