コード例 #1
0
  public void testSortOrder() throws Exception {
    final SortedBidiMap<K, V> sm = makeFullMap();

    // Sort by the comparator used in the makeEmptyBidiMap() method
    List<K> newSortedKeys = getAsList(getSampleKeys());
    Collections.sort(
        newSortedKeys, new ReverseComparator<K>(ComparableComparator.<K>comparableComparator()));
    newSortedKeys = Collections.unmodifiableList(newSortedKeys);

    final Iterator<K> mapIter = sm.keySet().iterator();
    final Iterator<K> expectedIter = newSortedKeys.iterator();
    while (expectedIter.hasNext()) {
      final K expectedKey = expectedIter.next();
      final K mapKey = mapIter.next();
      assertNotNull("key in sorted list may not be null", expectedKey);
      assertNotNull("key in map may not be null", mapKey);
      assertEquals("key from sorted list and map must be equal", expectedKey, mapKey);
    }
  }
コード例 #2
0
 @Override
 public TreeMap<K, V> makeConfirmedMap() {
   return new TreeMap<K, V>(
       new ReverseComparator<K>(ComparableComparator.<K>comparableComparator()));
 }
コード例 #3
0
 @Override
 public DualTreeBidiMap<K, V> makeObject() {
   return new DualTreeBidiMap<K, V>(
       new ReverseComparator<K>(ComparableComparator.<K>comparableComparator()),
       new ReverseComparator<V>(ComparableComparator.<V>comparableComparator()));
 }