Java Code Examples for java.util.concurrent.ConcurrentNavigableMap#headMap()

The following examples show how to use java.util.concurrent.ConcurrentNavigableMap#headMap() . 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: ConcurrentSkipListSubMapTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * headMap returns map with keys in requested range
 */
public void testHeadMapContents() {
    ConcurrentNavigableMap map = map5();
    SortedMap sm = map.headMap(four);
    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());
}
 
Example 2
Source File: ConcurrentSkipListSubMapTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * headMap returns map with keys in requested range
 */
public void testDescendingHeadMapContents() {
    ConcurrentNavigableMap map = dmap5();
    SortedMap sm = map.headMap(m4);
    assertTrue(sm.containsKey(m1));
    assertTrue(sm.containsKey(m2));
    assertTrue(sm.containsKey(m3));
    assertFalse(sm.containsKey(m4));
    assertFalse(sm.containsKey(m5));
    Iterator i = sm.keySet().iterator();
    Object k;
    k = (Integer)(i.next());
    assertEquals(m1, k);
    k = (Integer)(i.next());
    assertEquals(m2, k);
    k = (Integer)(i.next());
    assertEquals(m3, k);
    assertFalse(i.hasNext());
    sm.clear();
    assertTrue(sm.isEmpty());
    assertEquals(2, map.size());
    assertEquals(m4, map.firstKey());
}
 
Example 3
Source File: BTreeMapTest5.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * headMap returns map with keys in requested range
 */
public void testHeadMapContents() {
    ConcurrentNavigableMap map = map5();
    SortedMap sm = map.headMap(four);
    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());
}
 
Example 4
Source File: ConcurrentSkipListSubMapJUnitTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * headMap returns map with keys in requested range
 */
public void testHeadMapContents() {
    ConcurrentNavigableMap map = map5();
    SortedMap sm = map.headMap(four);
    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());
}
 
Example 5
Source File: ConcurrentSkipListSubMapJUnitTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * headMap returns map with keys in requested range
 */
public void testDescendingHeadMapContents() {
    ConcurrentNavigableMap map = dmap5();
    SortedMap sm = map.headMap(m4);
    assertTrue(sm.containsKey(m1));
    assertTrue(sm.containsKey(m2));
    assertTrue(sm.containsKey(m3));
    assertFalse(sm.containsKey(m4));
    assertFalse(sm.containsKey(m5));
    Iterator i = sm.keySet().iterator();
    Object k;
    k = (Integer)(i.next());
    assertEquals(m1, k);
    k = (Integer)(i.next());
    assertEquals(m2, k);
    k = (Integer)(i.next());
    assertEquals(m3, k);
    assertFalse(i.hasNext());
    sm.clear();
    assertTrue(sm.isEmpty());
    assertEquals(2, map.size());
    assertEquals(m4, map.firstKey());
}
 
Example 6
Source File: ConcurrentSkipListSubMapJUnitTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * headMap returns map with keys in requested range
 */
public void testHeadMapContents() {
    ConcurrentNavigableMap map = map5();
    SortedMap sm = map.headMap(four);
    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());
}
 
Example 7
Source File: ConcurrentSkipListSubMapJUnitTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * headMap returns map with keys in requested range
 */
public void testDescendingHeadMapContents() {
    ConcurrentNavigableMap map = dmap5();
    SortedMap sm = map.headMap(m4);
    assertTrue(sm.containsKey(m1));
    assertTrue(sm.containsKey(m2));
    assertTrue(sm.containsKey(m3));
    assertFalse(sm.containsKey(m4));
    assertFalse(sm.containsKey(m5));
    Iterator i = sm.keySet().iterator();
    Object k;
    k = (Integer)(i.next());
    assertEquals(m1, k);
    k = (Integer)(i.next());
    assertEquals(m2, k);
    k = (Integer)(i.next());
    assertEquals(m3, k);
    assertFalse(i.hasNext());
    sm.clear();
    assertTrue(sm.isEmpty());
    assertEquals(2, map.size());
    assertEquals(m4, map.firstKey());
}
 
Example 8
Source File: DeltaStoreBasedWaveletState.java    From swellrt with Apache License 2.0 6 votes vote down vote up
private static void readDeltasCacheDescending(
    ConcurrentNavigableMap<HashedVersion, WaveletDeltaRecord> cachedDeltas,
    HashedVersion startVersion, HashedVersion endVersion, DeltaRecordTrackerReceiver receiver) {

  Preconditions.checkArgument(startVersion.getVersion() > endVersion.getVersion(),
      "Delta start version must be greater than end version");
  ConcurrentNavigableMap<HashedVersion, WaveletDeltaRecord> subCachedDeltas = cachedDeltas
      .headMap(startVersion);

  Iterator<HashedVersion> viterator = subCachedDeltas.navigableKeySet().descendingIterator();
  while (viterator.hasNext()) {
    boolean stop = receiver.put(subCachedDeltas.get(viterator.next()));
    stop = stop || receiver.halted
        || receiver.lastDelta.getResultingVersion().getVersion() <= endVersion.getVersion();
    if (stop)
      return;
  }

}
 
Example 9
Source File: ConcurrentSkipListSubMapTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * headMap returns map with keys in requested range
 */
public void testHeadMapContents() {
    ConcurrentNavigableMap map = map5();
    SortedMap sm = map.headMap(four);
    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());
}
 
Example 10
Source File: ConcurrentSkipListSubMapTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * headMap returns map with keys in requested range
 */
public void testDescendingHeadMapContents() {
    ConcurrentNavigableMap map = dmap5();
    SortedMap sm = map.headMap(m4);
    assertTrue(sm.containsKey(m1));
    assertTrue(sm.containsKey(m2));
    assertTrue(sm.containsKey(m3));
    assertFalse(sm.containsKey(m4));
    assertFalse(sm.containsKey(m5));
    Iterator i = sm.keySet().iterator();
    Object k;
    k = (Integer)(i.next());
    assertEquals(m1, k);
    k = (Integer)(i.next());
    assertEquals(m2, k);
    k = (Integer)(i.next());
    assertEquals(m3, k);
    assertFalse(i.hasNext());
    sm.clear();
    assertTrue(sm.isEmpty());
    assertEquals(2, map.size());
    assertEquals(m4, map.firstKey());
}