本文整理匯總了Java中com.google.common.collect.Ordering.immutableSortedCopy方法的典型用法代碼示例。如果您正苦於以下問題:Java Ordering.immutableSortedCopy方法的具體用法?Java Ordering.immutableSortedCopy怎麽用?Java Ordering.immutableSortedCopy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.collect.Ordering
的用法示例。
在下文中一共展示了Ordering.immutableSortedCopy方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: writeAnnotations
import com.google.common.collect.Ordering; //導入方法依賴的package包/類
public void writeAnnotations(Writer out) throws IOException {
List<MapItem> mapItems = dexFile.getMapItems();
// sort the map items based on the order defined by sectionAnnotationOrder
Ordering<MapItem> ordering = Ordering.from(new Comparator<MapItem>() {
@Override public int compare(MapItem o1, MapItem o2) {
return Ints.compare(sectionAnnotationOrder.get(o1.getType()), sectionAnnotationOrder.get(o2.getType()));
}
});
mapItems = ordering.immutableSortedCopy(mapItems);
try {
for (MapItem mapItem: mapItems) {
SectionAnnotator annotator = annotators.get(mapItem.getType());
annotator.annotateSection(this);
}
} finally {
dexFile.writeAnnotations(out, this);
}
}
示例2: sortKeysByValue
import com.google.common.collect.Ordering; //導入方法依賴的package包/類
private static <K, V> ImmutableList<K> sortKeysByValue(
final Map<K, V> map, final Comparator<? super V> valueComparator) {
Ordering<K> keyOrdering =
new Ordering<K>() {
@Override
public int compare(K left, K right) {
return valueComparator.compare(map.get(left), map.get(right));
}
};
return keyOrdering.immutableSortedCopy(map.keySet());
}
示例3: sort
import com.google.common.collect.Ordering; //導入方法依賴的package包/類
public static ImmutableList<Blob> sort(ImmutableList<Blob> blobs, ImmutableList<String> currentOrdering) {
Ordering<Blob> comparator=comparatorOf(currentOrdering);
return comparator.immutableSortedCopy(blobs);
}