Returns the k greatest elements of the given iterable according to this ordering, in order from greatest to least. If there are fewer than k elements present, all will be included. The implementation does not necessarily use a stable sorting algorithm; when multiple elemen
(Iterable<E> iterable, int k)
| 831 | |
| 832 | |
| 833 | public <E extends T> List<E> greatestOf(Iterable<E> iterable, int k) { |
| 834 | // TODO(kevinb): see if delegation is hurting performance noticeably |
| 835 | // TODO(kevinb): if we change this implementation, add full unit tests. |
| 836 | return reverse().leastOf(iterable, k); |
| 837 | } |
| 838 | |
| 839 | /** |
| 840 | * Returns the {@code k} greatest elements from the given iterator according to |