/** * Create a new sorted list accumulator. * @param n The number of results desired; negative for unlimited. * @return An accumulator accumulator. */ public static <T extends Comparable<? super T>> SortedListAccumulator<T> decreasing(int n) { if (n < 0) { return new Unlimited<T>(Ordering.<T>natural()); } else { return new TopN<T>(n, Ordering.<T>natural()); } }
/** * Create a new sorted list accumulator that sorts in decreasing order. * @param n The number of results desired; negative for unlimited. * @param comp The comparator; items will be picked in *decreasing* order by this comparator. * @return An accumulator accumulator. */ public static <T> SortedListAccumulator<T> decreasing(int n, Comparator<? super T> comp) { if (n < 0) { return new Unlimited<T>(Ordering.from(comp)); } else { return new TopN<T>(n, Ordering.from(comp)); } }
/** * Create a new sorted list accumulator. * @param n The number of results desired; negative for unlimited. * @return An accumulator accumulator. */ public static <T extends Comparable<? super T>> SortedListAccumulator<T> decreasing(int n) { if (n < 0) { return new Unlimited<T>(Ordering.<T>natural()); } else { return new TopN<T>(n, Ordering.<T>natural()); } }
/** * Create a new sorted list accumulator that sorts in decreasing order. * @param n The number of results desired; negative for unlimited. * @param comp The comparator; items will be picked in *decreasing* order by this comparator. * @return An accumulator accumulator. */ public static <T> SortedListAccumulator<T> decreasing(int n, Comparator<? super T> comp) { if (n < 0) { return new Unlimited<T>(Ordering.from(comp)); } else { return new TopN<T>(n, Ordering.from(comp)); } }