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

The following examples show how to use java.util.concurrent.ConcurrentNavigableMap#keySet() . 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: ConcurrentSkipListSubMapJUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * keySet returns a Set containing all the keys
 */
public void testKeySet() {
    ConcurrentNavigableMap map = map5();
    Set s = map.keySet();
    assertEquals(5, s.size());
    assertTrue(s.contains(one));
    assertTrue(s.contains(two));
    assertTrue(s.contains(three));
    assertTrue(s.contains(four));
    assertTrue(s.contains(five));
}
 
Example 2
Source File: ConcurrentSkipListSubMapJUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * keySet returns a Set containing all the keys
 */
public void testDescendingKeySet() {
    ConcurrentNavigableMap map = dmap5();
    Set s = map.keySet();
    assertEquals(5, s.size());
    assertTrue(s.contains(m1));
    assertTrue(s.contains(m2));
    assertTrue(s.contains(m3));
    assertTrue(s.contains(m4));
    assertTrue(s.contains(m5));
}
 
Example 3
Source File: ConcurrentSkipListSubMapJUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * keySet.toArray returns contains all keys
 */
public void testKeySetToArray() {
    ConcurrentNavigableMap map = map5();
    Set s = map.keySet();
    Object[] ar = s.toArray();
    assertTrue(s.containsAll(Arrays.asList(ar)));
    assertEquals(5, ar.length);
    ar[0] = m10;
    assertFalse(s.containsAll(Arrays.asList(ar)));
}
 
Example 4
Source File: ConcurrentSkipListSubMapJUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * keySet is ordered
 */
public void testDescendingKeySetOrder() {
    ConcurrentNavigableMap map = dmap5();
    Set s = map.keySet();
    Iterator i = s.iterator();
    Integer last = (Integer)i.next();
    assertEquals(last, m1);
    while (i.hasNext()) {
        Integer k = (Integer)i.next();
        assertTrue(last.compareTo(k) > 0);
        last = k;
    }
}
 
Example 5
Source File: ConcurrentSkipListSubMapJUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * keySet returns a Set containing all the keys
 */
public void testKeySet() {
    ConcurrentNavigableMap map = map5();
    Set s = map.keySet();
    assertEquals(5, s.size());
    assertTrue(s.contains(one));
    assertTrue(s.contains(two));
    assertTrue(s.contains(three));
    assertTrue(s.contains(four));
    assertTrue(s.contains(five));
}
 
Example 6
Source File: ConcurrentSkipListSubMapJUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * keySet.toArray returns contains all keys
 */
public void testDescendingAscendingKeySetToArray() {
    ConcurrentNavigableMap map = dmap5();
    Set s = map.keySet();
    Object[] ar = s.toArray();
    assertTrue(s.containsAll(Arrays.asList(ar)));
    assertEquals(5, ar.length);
    ar[0] = m10;
    assertFalse(s.containsAll(Arrays.asList(ar)));
}
 
Example 7
Source File: ConcurrentSkipListSubMapTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * keySet is ordered
 */
public void testDescendingKeySetOrder() {
    ConcurrentNavigableMap map = dmap5();
    Set s = map.keySet();
    Iterator i = s.iterator();
    Integer last = (Integer)i.next();
    assertEquals(last, m1);
    while (i.hasNext()) {
        Integer k = (Integer)i.next();
        assertTrue(last.compareTo(k) > 0);
        last = k;
    }
}
 
Example 8
Source File: ConcurrentSkipListSubMapTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * keySet.toArray returns contains all keys
 */
public void testKeySetToArray() {
    ConcurrentNavigableMap map = map5();
    Set s = map.keySet();
    Object[] ar = s.toArray();
    assertTrue(s.containsAll(Arrays.asList(ar)));
    assertEquals(5, ar.length);
    ar[0] = m10;
    assertFalse(s.containsAll(Arrays.asList(ar)));
}
 
Example 9
Source File: ConcurrentSkipListSubMapJUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * keySet.toArray returns contains all keys
 */
public void testKeySetToArray() {
    ConcurrentNavigableMap map = map5();
    Set s = map.keySet();
    Object[] ar = s.toArray();
    assertTrue(s.containsAll(Arrays.asList(ar)));
    assertEquals(5, ar.length);
    ar[0] = m10;
    assertFalse(s.containsAll(Arrays.asList(ar)));
}
 
Example 10
Source File: ConcurrentSkipListSubMapTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * keySet is ordered
 */
public void testKeySetOrder() {
    ConcurrentNavigableMap map = map5();
    Set s = map.keySet();
    Iterator i = s.iterator();
    Integer last = (Integer)i.next();
    assertEquals(last, one);
    while (i.hasNext()) {
        Integer k = (Integer)i.next();
        assertTrue(last.compareTo(k) < 0);
        last = k;
    }
}
 
Example 11
Source File: MemoryRawKVStore.java    From sofa-jraft with Apache License 2.0 5 votes vote down vote up
@Override
public byte[] jumpOver(final byte[] startKey, final long distance) {
    final Timer.Context timeCtx = getTimeContext("JUMP_OVER");
    try {
        final byte[] realStartKey = BytesUtil.nullToEmpty(startKey);
        final ConcurrentNavigableMap<byte[], byte[]> tailMap = this.defaultDB.tailMap(realStartKey);
        if (tailMap.isEmpty()) {
            return null;
        }
        long approximateKeys = 0;
        byte[] lastKey = null;
        for (final byte[] key : tailMap.keySet()) {
            lastKey = key;
            if (++approximateKeys >= distance) {
                break;
            }
        }
        if (lastKey == null) {
            return null;
        }
        final byte[] endKey = new byte[lastKey.length];
        System.arraycopy(lastKey, 0, endKey, 0, lastKey.length);
        return endKey;
    } finally {
        timeCtx.stop();
    }
}
 
Example 12
Source File: BTreeMapTest5.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * keySet.toArray returns contains all keys
 */
public void testKeySetToArray() {
    ConcurrentNavigableMap map = map5();
    Set s = map.keySet();
    Object[] ar = s.toArray();
    assertTrue(s.containsAll(Arrays.asList(ar)));
    assertEquals(5, ar.length);
    ar[0] = m10;
    assertFalse(s.containsAll(Arrays.asList(ar)));
}
 
Example 13
Source File: BTreeMapTest5.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * keySet is ordered
 */
public void testKeySetOrder() {
    ConcurrentNavigableMap map = map5();
    Set s = map.keySet();
    Iterator i = s.iterator();
    Integer last = (Integer)i.next();
    assertEquals(last, one);
    while (i.hasNext()) {
        Integer k = (Integer)i.next();
        assertTrue(last.compareTo(k) < 0);
        last = k;
    }
}
 
Example 14
Source File: BTreeMapTest5.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * keySet returns a Set containing all the keys
 */
public void testKeySet() {
    ConcurrentNavigableMap map = map5();
    Set s = map.keySet();
    assertEquals(5, s.size());
    assertTrue(s.contains(one));
    assertTrue(s.contains(two));
    assertTrue(s.contains(three));
    assertTrue(s.contains(four));
    assertTrue(s.contains(five));
}
 
Example 15
Source File: ConcurrentSkipListSubMapTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * keySet returns a Set containing all the keys
 */
public void testKeySet() {
    ConcurrentNavigableMap map = map5();
    Set s = map.keySet();
    assertEquals(5, s.size());
    assertTrue(s.contains(one));
    assertTrue(s.contains(two));
    assertTrue(s.contains(three));
    assertTrue(s.contains(four));
    assertTrue(s.contains(five));
}
 
Example 16
Source File: ConcurrentSkipListSubMapTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * keySet is ordered
 */
public void testDescendingKeySetOrder() {
    ConcurrentNavigableMap map = dmap5();
    Set s = map.keySet();
    Iterator i = s.iterator();
    Integer last = (Integer)i.next();
    assertEquals(last, m1);
    while (i.hasNext()) {
        Integer k = (Integer)i.next();
        assertTrue(last.compareTo(k) > 0);
        last = k;
    }
}
 
Example 17
Source File: ConcurrentSkipListSubMapTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * keySet returns a Set containing all the keys
 */
public void testDescendingKeySet() {
    ConcurrentNavigableMap map = dmap5();
    Set s = map.keySet();
    assertEquals(5, s.size());
    assertTrue(s.contains(m1));
    assertTrue(s.contains(m2));
    assertTrue(s.contains(m3));
    assertTrue(s.contains(m4));
    assertTrue(s.contains(m5));
}
 
Example 18
Source File: ConcurrentSkipListSubMapTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * keySet.toArray returns contains all keys
 */
public void testKeySetToArray() {
    ConcurrentNavigableMap map = map5();
    Set s = map.keySet();
    Object[] ar = s.toArray();
    assertTrue(s.containsAll(Arrays.asList(ar)));
    assertEquals(5, ar.length);
    ar[0] = m10;
    assertFalse(s.containsAll(Arrays.asList(ar)));
}
 
Example 19
Source File: ConcurrentSkipListSubMapTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * keySet is ordered
 */
public void testKeySetOrder() {
    ConcurrentNavigableMap map = map5();
    Set s = map.keySet();
    Iterator i = s.iterator();
    Integer last = (Integer)i.next();
    assertEquals(last, one);
    while (i.hasNext()) {
        Integer k = (Integer)i.next();
        assertTrue(last.compareTo(k) < 0);
        last = k;
    }
}
 
Example 20
Source File: ConcurrentSkipListSubMapTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * keySet.toArray returns contains all keys
 */
public void testDescendingAscendingKeySetToArray() {
    ConcurrentNavigableMap map = dmap5();
    Set s = map.keySet();
    Object[] ar = s.toArray();
    assertTrue(s.containsAll(Arrays.asList(ar)));
    assertEquals(5, ar.length);
    ar[0] = m10;
    assertFalse(s.containsAll(Arrays.asList(ar)));
}