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

The following examples show how to use java.util.concurrent.ConcurrentSkipListMap#entrySet() . 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
/**
 * entrySet contains all pairs
 */
public void testEntrySet() {
    ConcurrentSkipListMap map = map5();
    Set s = map.entrySet();
    assertEquals(5, s.size());
    Iterator it = s.iterator();
    while (it.hasNext()) {
        Map.Entry e = (Map.Entry) it.next();
        assertTrue(
                   (e.getKey().equals(one) && e.getValue().equals("A")) ||
                   (e.getKey().equals(two) && e.getValue().equals("B")) ||
                   (e.getKey().equals(three) && e.getValue().equals("C")) ||
                   (e.getKey().equals(four) && e.getValue().equals("D")) ||
                   (e.getKey().equals(five) && e.getValue().equals("E")));
    }
}
 
Example 2
Source File: ConcurrentSkipListMapTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * entrySet contains all pairs
 */
public void testEntrySet() {
    ConcurrentSkipListMap map = map5();
    Set s = map.entrySet();
    assertEquals(5, s.size());
    Iterator it = s.iterator();
    while (it.hasNext()) {
        Map.Entry e = (Map.Entry) it.next();
        assertTrue(
                   (e.getKey().equals(one) && e.getValue().equals("A")) ||
                   (e.getKey().equals(two) && e.getValue().equals("B")) ||
                   (e.getKey().equals(three) && e.getValue().equals("C")) ||
                   (e.getKey().equals(four) && e.getValue().equals("D")) ||
                   (e.getKey().equals(five) && e.getValue().equals("E")));
    }
}
 
Example 3
Source File: ConcurrentSkipListMapTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * entrySet.toArray contains all entries
 */
public void testEntrySetToArray() {
    ConcurrentSkipListMap map = map5();
    Set s = map.entrySet();
    Object[] ar = s.toArray();
    assertEquals(5, ar.length);
    for (int i = 0; i < 5; ++i) {
        assertTrue(map.containsKey(((Map.Entry)(ar[i])).getKey()));
        assertTrue(map.containsValue(((Map.Entry)(ar[i])).getValue()));
    }
}
 
Example 4
Source File: ConcurrentSkipListMapTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * entrySet.toArray contains all entries
 */
public void testEntrySetToArray() {
    ConcurrentSkipListMap map = map5();
    Set s = map.entrySet();
    Object[] ar = s.toArray();
    assertEquals(5, ar.length);
    for (int i = 0; i < 5; ++i) {
        assertTrue(map.containsKey(((Map.Entry)(ar[i])).getKey()));
        assertTrue(map.containsValue(((Map.Entry)(ar[i])).getValue()));
    }
}
 
Example 5
Source File: PersistentIndex.java    From ambry with Apache License 2.0 5 votes vote down vote up
/**
 * @param indexSegments the map of index segment start {@link Offset} to {@link IndexSegment} instances
 * @return mapping from log segment names to {@link IndexSegment} instances that refer to them.
 */
private TreeMap<String, List<IndexSegment>> getLogSegmentToIndexSegmentMapping(
    ConcurrentSkipListMap<Offset, IndexSegment> indexSegments) {
  TreeMap<String, List<IndexSegment>> mapping = new TreeMap<>(LogSegmentNameHelper.COMPARATOR);
  for (Map.Entry<Offset, IndexSegment> indexSegmentEntry : indexSegments.entrySet()) {
    IndexSegment indexSegment = indexSegmentEntry.getValue();
    String logSegmentName = indexSegment.getLogSegmentName();
    if (!mapping.containsKey(logSegmentName)) {
      mapping.put(logSegmentName, new ArrayList<IndexSegment>());
    }
    mapping.get(logSegmentName).add(indexSegment);
  }
  return mapping;
}