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)
| 823 | * @since 8.0 |
| 824 | */ |
| 825 | public <E extends T> List<E> greatestOf(Iterable<E> iterable, int k) { |
| 826 | // TODO(kevinb): see if delegation is hurting performance noticeably |
| 827 | // TODO(kevinb): if we change this implementation, add full unit tests. |
| 828 | return reverse().leastOf(iterable, k); |
| 829 | } |
| 830 | |
| 831 | /** |
| 832 | * Returns the {@code k} greatest elements from the given iterator according to |