Java Code Examples for java.util.concurrent.ConcurrentSkipListMap#descendingKeySet()

The following examples show how to use java.util.concurrent.ConcurrentSkipListMap#descendingKeySet() . 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 6 votes vote down vote up
/**
 * descendingKeySet is ordered
 */
public void testDescendingKeySetOrder() {
    ConcurrentSkipListMap map = map5();
    Set s = map.descendingKeySet();
    Iterator i = s.iterator();
    Integer last = (Integer)i.next();
    assertEquals(last, five);
    int count = 1;
    while (i.hasNext()) {
        Integer k = (Integer)i.next();
        assertTrue(last.compareTo(k) > 0);
        last = k;
        ++count;
    }
    assertEquals(5, count);
}
 
Example 2
Source File: ConcurrentSkipListMapTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * descending iterator of descendingKeySet is ordered
 */
public void testDescendingKeySetDescendingIteratorOrder() {
    ConcurrentSkipListMap map = map5();
    NavigableSet s = map.descendingKeySet();
    Iterator i = s.descendingIterator();
    Integer last = (Integer)i.next();
    assertEquals(last, one);
    int count = 1;
    while (i.hasNext()) {
        Integer k = (Integer)i.next();
        assertTrue(last.compareTo(k) < 0);
        last = k;
        ++count;
    }
    assertEquals(5, count);
}
 
Example 3
Source File: ConcurrentSkipListMapTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * descendingKeySet is ordered
 */
public void testDescendingKeySetOrder() {
    ConcurrentSkipListMap map = map5();
    Set s = map.descendingKeySet();
    Iterator i = s.iterator();
    Integer last = (Integer)i.next();
    assertEquals(last, five);
    int count = 1;
    while (i.hasNext()) {
        Integer k = (Integer)i.next();
        assertTrue(last.compareTo(k) > 0);
        last = k;
        ++count;
    }
    assertEquals(5, count);
}
 
Example 4
Source File: ConcurrentSkipListMapTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * descending iterator of descendingKeySet is ordered
 */
public void testDescendingKeySetDescendingIteratorOrder() {
    ConcurrentSkipListMap map = map5();
    NavigableSet s = map.descendingKeySet();
    Iterator i = s.descendingIterator();
    Integer last = (Integer)i.next();
    assertEquals(last, one);
    int count = 1;
    while (i.hasNext()) {
        Integer k = (Integer)i.next();
        assertTrue(last.compareTo(k) < 0);
        last = k;
        ++count;
    }
    assertEquals(5, count);
}
 
Example 5
Source File: ConcurrentSkipListMapTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * descendingkeySet.toArray returns contains all keys
 */
public void testDescendingKeySetToArray() {
    ConcurrentSkipListMap map = map5();
    Set s = map.descendingKeySet();
    Object[] ar = s.toArray();
    assertEquals(5, ar.length);
    assertTrue(s.containsAll(Arrays.asList(ar)));
    ar[0] = m10;
    assertFalse(s.containsAll(Arrays.asList(ar)));
}
 
Example 6
Source File: ConcurrentSkipListMapTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * descendingkeySet.toArray returns contains all keys
 */
public void testDescendingKeySetToArray() {
    ConcurrentSkipListMap map = map5();
    Set s = map.descendingKeySet();
    Object[] ar = s.toArray();
    assertEquals(5, ar.length);
    assertTrue(s.containsAll(Arrays.asList(ar)));
    ar[0] = m10;
    assertFalse(s.containsAll(Arrays.asList(ar)));
}