當前位置: 首頁>>代碼示例>>Java>>正文


Java ComparableComparator類代碼示例

本文整理匯總了Java中org.apache.commons.collections15.comparators.ComparableComparator的典型用法代碼示例。如果您正苦於以下問題:Java ComparableComparator類的具體用法?Java ComparableComparator怎麽用?Java ComparableComparator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ComparableComparator類屬於org.apache.commons.collections15.comparators包,在下文中一共展示了ComparableComparator類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setUp

import org.apache.commons.collections15.comparators.ComparableComparator; //導入依賴的package包/類
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));
}
 
開發者ID:jgaltidor,項目名稱:VarJ,代碼行數:23,代碼來源:TestCollatingIterator.java

示例2: testSortOrder

import org.apache.commons.collections15.comparators.ComparableComparator; //導入依賴的package包/類
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);
    }
}
 
開發者ID:jgaltidor,項目名稱:VarJ,代碼行數:19,代碼來源:TestDualTreeBidiMap2.java

示例3: getSampleKeys

import org.apache.commons.collections15.comparators.ComparableComparator; //導入依賴的package包/類
/**
 * 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();
}
 
開發者ID:jgaltidor,項目名稱:VarJ,代碼行數:10,代碼來源:AbstractTestOrderedMap.java

示例4: makeEmptyBidiMap

import org.apache.commons.collections15.comparators.ComparableComparator; //導入依賴的package包/類
public BidiMap makeEmptyBidiMap() {
    return DualTreeBidiMap.createTwoWayBidiMap(new ReverseComparator(ComparableComparator.getInstance()));
}
 
開發者ID:jgaltidor,項目名稱:VarJ,代碼行數:4,代碼來源:TestDualTreeBidiMap2.java

示例5: makeConfirmedMap

import org.apache.commons.collections15.comparators.ComparableComparator; //導入依賴的package包/類
public Map makeConfirmedMap() {
    return new TreeMap(new ReverseComparator(ComparableComparator.getInstance()));
}
 
開發者ID:jgaltidor,項目名稱:VarJ,代碼行數:4,代碼來源:TestDualTreeBidiMap2.java

示例6: SortedSparseMultigraph

import org.apache.commons.collections15.comparators.ComparableComparator; //導入依賴的package包/類
/**
 * Creates a new instance which sorts its vertices and edges according to 
 * their natural ordering.
 */
@SuppressWarnings("unchecked")
public SortedSparseMultigraph()
{
    this(new ComparableComparator(), new ComparableComparator());
}
 
開發者ID:SiLeBAT,項目名稱:BfROpenLab,代碼行數:10,代碼來源:SortedSparseMultigraph.java

示例7: makeConfirmedMap

import org.apache.commons.collections15.comparators.ComparableComparator; //導入依賴的package包/類
/**
 * 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()));
}
 
開發者ID:jgaltidor,項目名稱:VarJ,代碼行數:9,代碼來源:AbstractTestOrderedMap.java


注:本文中的org.apache.commons.collections15.comparators.ComparableComparator類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。