本文整理匯總了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));
}
示例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);
}
}
示例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();
}
示例4: makeEmptyBidiMap
import org.apache.commons.collections15.comparators.ComparableComparator; //導入依賴的package包/類
public BidiMap makeEmptyBidiMap() {
return DualTreeBidiMap.createTwoWayBidiMap(new ReverseComparator(ComparableComparator.getInstance()));
}
示例5: makeConfirmedMap
import org.apache.commons.collections15.comparators.ComparableComparator; //導入依賴的package包/類
public Map makeConfirmedMap() {
return new TreeMap(new ReverseComparator(ComparableComparator.getInstance()));
}
示例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());
}
示例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()));
}