Java Code Examples for java.util.concurrent.ConcurrentSkipListMap#subMap()
The following examples show how to use
java.util.concurrent.ConcurrentSkipListMap#subMap() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConcurrentSkipListMapTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * subMap returns map with keys in requested range */ public void testSubMapContents() { ConcurrentSkipListMap map = map5(); NavigableMap sm = map.subMap(two, true, four, false); assertEquals(two, sm.firstKey()); assertEquals(three, sm.lastKey()); assertEquals(2, sm.size()); assertFalse(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(two, k); k = (Integer)(i.next()); assertEquals(three, k); assertFalse(i.hasNext()); Iterator r = sm.descendingKeySet().iterator(); k = (Integer)(r.next()); assertEquals(three, k); k = (Integer)(r.next()); assertEquals(two, k); assertFalse(r.hasNext()); Iterator j = sm.keySet().iterator(); j.next(); j.remove(); assertFalse(map.containsKey(two)); assertEquals(4, map.size()); assertEquals(1, sm.size()); assertEquals(three, sm.firstKey()); assertEquals(three, sm.lastKey()); assertEquals("C", sm.remove(three)); assertTrue(sm.isEmpty()); assertEquals(3, map.size()); }
Example 2
Source File: ConcurrentSkipListMapTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public void testSubMapContents2() { ConcurrentSkipListMap map = map5(); NavigableMap sm = map.subMap(two, true, three, false); assertEquals(1, sm.size()); assertEquals(two, sm.firstKey()); assertEquals(two, sm.lastKey()); assertFalse(sm.containsKey(one)); assertTrue(sm.containsKey(two)); assertFalse(sm.containsKey(three)); assertFalse(sm.containsKey(four)); assertFalse(sm.containsKey(five)); Iterator i = sm.keySet().iterator(); Object k; k = (Integer)(i.next()); assertEquals(two, k); assertFalse(i.hasNext()); Iterator r = sm.descendingKeySet().iterator(); k = (Integer)(r.next()); assertEquals(two, k); assertFalse(r.hasNext()); Iterator j = sm.keySet().iterator(); j.next(); j.remove(); assertFalse(map.containsKey(two)); assertEquals(4, map.size()); assertEquals(0, sm.size()); assertTrue(sm.isEmpty()); assertSame(sm.remove(three), null); assertEquals(4, map.size()); }
Example 3
Source File: ConcurrentSkipListSubMapTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Returns a new map from Integers 1-5 to Strings "A"-"E". */ private static ConcurrentNavigableMap map5() { ConcurrentSkipListMap map = new ConcurrentSkipListMap(); assertTrue(map.isEmpty()); map.put(zero, "Z"); map.put(one, "A"); map.put(five, "E"); map.put(three, "C"); map.put(two, "B"); map.put(four, "D"); map.put(seven, "F"); assertFalse(map.isEmpty()); assertEquals(7, map.size()); return map.subMap(one, true, seven, false); }
Example 4
Source File: ConcurrentSkipListMapTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * subMap returns map with keys in requested range */ public void testSubMapContents() { ConcurrentSkipListMap map = map5(); NavigableMap sm = map.subMap(two, true, four, false); assertEquals(two, sm.firstKey()); assertEquals(three, sm.lastKey()); assertEquals(2, sm.size()); assertFalse(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(two, k); k = (Integer)(i.next()); assertEquals(three, k); assertFalse(i.hasNext()); Iterator r = sm.descendingKeySet().iterator(); k = (Integer)(r.next()); assertEquals(three, k); k = (Integer)(r.next()); assertEquals(two, k); assertFalse(r.hasNext()); Iterator j = sm.keySet().iterator(); j.next(); j.remove(); assertFalse(map.containsKey(two)); assertEquals(4, map.size()); assertEquals(1, sm.size()); assertEquals(three, sm.firstKey()); assertEquals(three, sm.lastKey()); assertEquals("C", sm.remove(three)); assertTrue(sm.isEmpty()); assertEquals(3, map.size()); }
Example 5
Source File: ConcurrentSkipListMapTest.java From j2objc with Apache License 2.0 | 5 votes |
public void testSubMapContents2() { ConcurrentSkipListMap map = map5(); NavigableMap sm = map.subMap(two, true, three, false); assertEquals(1, sm.size()); assertEquals(two, sm.firstKey()); assertEquals(two, sm.lastKey()); assertFalse(sm.containsKey(one)); assertTrue(sm.containsKey(two)); assertFalse(sm.containsKey(three)); assertFalse(sm.containsKey(four)); assertFalse(sm.containsKey(five)); Iterator i = sm.keySet().iterator(); Object k; k = (Integer)(i.next()); assertEquals(two, k); assertFalse(i.hasNext()); Iterator r = sm.descendingKeySet().iterator(); k = (Integer)(r.next()); assertEquals(two, k); assertFalse(r.hasNext()); Iterator j = sm.keySet().iterator(); j.next(); j.remove(); assertFalse(map.containsKey(two)); assertEquals(4, map.size()); assertEquals(0, sm.size()); assertTrue(sm.isEmpty()); assertSame(sm.remove(three), null); assertEquals(4, map.size()); }
Example 6
Source File: ConcurrentSkipListSubMapTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * Returns a new map from Integers 1-5 to Strings "A"-"E". */ private static ConcurrentNavigableMap map5() { ConcurrentSkipListMap map = new ConcurrentSkipListMap(); assertTrue(map.isEmpty()); map.put(zero, "Z"); map.put(one, "A"); map.put(five, "E"); map.put(three, "C"); map.put(two, "B"); map.put(four, "D"); map.put(seven, "F"); assertFalse(map.isEmpty()); assertEquals(7, map.size()); return map.subMap(one, true, seven, false); }