Java 类org.apache.commons.collections15.comparators.ComparableComparator 实例源码

项目:VarJ    文件:TestCollatingIterator.java   
public void setUp() throws Exception {
    super.setUp();
    comparator = new ComparableComparator();
    evens = new ArrayList();
    odds = new ArrayList();
    for (int i = 0; i < 20; i++) {
        if (0 == i % 2) {
            evens.add(new Integer(i));
        } else {
            odds.add(new Integer(i));
        }
    }
    fib = new ArrayList();
    fib.add(new Integer(1));
    fib.add(new Integer(1));
    fib.add(new Integer(2));
    fib.add(new Integer(3));
    fib.add(new Integer(5));
    fib.add(new Integer(8));
    fib.add(new Integer(13));
    fib.add(new Integer(21));
}
项目:VarJ    文件:TestDualTreeBidiMap2.java   
public void testSortOrder() throws Exception {
    SortedBidiMap sm = (SortedBidiMap) makeFullMap();

    // Sort by the comparator used in the makeEmptyBidiMap() method
    List newSortedKeys = Arrays.asList(getSampleKeys());
    Collections.sort(newSortedKeys, new ReverseComparator(ComparableComparator.getInstance()));
    newSortedKeys = Collections.unmodifiableList(newSortedKeys);

    Iterator mapIter = sm.keySet().iterator();
    Iterator expectedIter = newSortedKeys.iterator();
    while (expectedIter.hasNext()) {
        Object expectedKey = expectedIter.next();
        Object 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);
    }
}
项目:VarJ    文件:AbstractTestOrderedMap.java   
/**
 * The only confirmed collection we have that is ordered is the sorted one.
 * Thus, sort the keys.
 */
public Object[] getSampleKeys() {
    List list = new ArrayList(Arrays.asList(super.getSampleKeys()));
    Collections.sort(list, new NullComparator(ComparableComparator.getInstance()));
    return list.toArray();
}
项目:VarJ    文件:TestDualTreeBidiMap2.java   
public BidiMap makeEmptyBidiMap() {
    return DualTreeBidiMap.createTwoWayBidiMap(new ReverseComparator(ComparableComparator.getInstance()));
}
项目:VarJ    文件:TestDualTreeBidiMap2.java   
public Map makeConfirmedMap() {
    return new TreeMap(new ReverseComparator(ComparableComparator.getInstance()));
}
项目:BfROpenLab    文件:SortedSparseMultigraph.java   
/**
 * Creates a new instance which sorts its vertices and edges according to 
 * their natural ordering.
 */
@SuppressWarnings("unchecked")
public SortedSparseMultigraph()
{
    this(new ComparableComparator(), new ComparableComparator());
}
项目:VarJ    文件:AbstractTestOrderedMap.java   
/**
 * OrderedMap uses TreeMap as its known comparison.
 *
 * @return a map that is known to be valid
 */
public Map makeConfirmedMap() {
    return new TreeMap(new NullComparator(ComparableComparator.getInstance()));
}