本文整理匯總了Java中java.util.concurrent.ConcurrentNavigableMap.tailMap方法的典型用法代碼示例。如果您正苦於以下問題:Java ConcurrentNavigableMap.tailMap方法的具體用法?Java ConcurrentNavigableMap.tailMap怎麽用?Java ConcurrentNavigableMap.tailMap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.concurrent.ConcurrentNavigableMap
的用法示例。
在下文中一共展示了ConcurrentNavigableMap.tailMap方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testTailMapContents
import java.util.concurrent.ConcurrentNavigableMap; //導入方法依賴的package包/類
/**
* headMap returns map with keys in requested range
*/
public void testTailMapContents() {
ConcurrentNavigableMap map = map5();
SortedMap sm = map.tailMap(two);
assertFalse(sm.containsKey(one));
assertTrue(sm.containsKey(two));
assertTrue(sm.containsKey(three));
assertTrue(sm.containsKey(four));
assertTrue(sm.containsKey(five));
Iterator i = sm.keySet().iterator();
Object k;
k = (Integer)(i.next());
assertEquals(two, k);
k = (Integer)(i.next());
assertEquals(three, k);
k = (Integer)(i.next());
assertEquals(four, k);
k = (Integer)(i.next());
assertEquals(five, k);
assertFalse(i.hasNext());
Iterator ei = sm.entrySet().iterator();
Map.Entry e;
e = (Map.Entry)(ei.next());
assertEquals(two, e.getKey());
assertEquals("B", e.getValue());
e = (Map.Entry)(ei.next());
assertEquals(three, e.getKey());
assertEquals("C", e.getValue());
e = (Map.Entry)(ei.next());
assertEquals(four, e.getKey());
assertEquals("D", e.getValue());
e = (Map.Entry)(ei.next());
assertEquals(five, e.getKey());
assertEquals("E", e.getValue());
assertFalse(i.hasNext());
SortedMap ssm = sm.tailMap(four);
assertEquals(four, ssm.firstKey());
assertEquals(five, ssm.lastKey());
assertEquals("D", ssm.remove(four));
assertEquals(1, ssm.size());
assertEquals(3, sm.size());
assertEquals(4, map.size());
}
示例2: testDescendingTailMapContents
import java.util.concurrent.ConcurrentNavigableMap; //導入方法依賴的package包/類
/**
* headMap returns map with keys in requested range
*/
public void testDescendingTailMapContents() {
ConcurrentNavigableMap map = dmap5();
SortedMap sm = map.tailMap(m2);
assertFalse(sm.containsKey(m1));
assertTrue(sm.containsKey(m2));
assertTrue(sm.containsKey(m3));
assertTrue(sm.containsKey(m4));
assertTrue(sm.containsKey(m5));
Iterator i = sm.keySet().iterator();
Object k;
k = (Integer)(i.next());
assertEquals(m2, k);
k = (Integer)(i.next());
assertEquals(m3, k);
k = (Integer)(i.next());
assertEquals(m4, k);
k = (Integer)(i.next());
assertEquals(m5, k);
assertFalse(i.hasNext());
Iterator ei = sm.entrySet().iterator();
Map.Entry e;
e = (Map.Entry)(ei.next());
assertEquals(m2, e.getKey());
assertEquals("B", e.getValue());
e = (Map.Entry)(ei.next());
assertEquals(m3, e.getKey());
assertEquals("C", e.getValue());
e = (Map.Entry)(ei.next());
assertEquals(m4, e.getKey());
assertEquals("D", e.getValue());
e = (Map.Entry)(ei.next());
assertEquals(m5, e.getKey());
assertEquals("E", e.getValue());
assertFalse(i.hasNext());
SortedMap ssm = sm.tailMap(m4);
assertEquals(m4, ssm.firstKey());
assertEquals(m5, ssm.lastKey());
assertEquals("D", ssm.remove(m4));
assertEquals(1, ssm.size());
assertEquals(3, sm.size());
assertEquals(4, map.size());
}