NBest
Convenient collection to gather the N highest elements, and discard the others
This can be useful in the implementation of an algorithm like k-nearest-neighbour, where you can build an [NBest] using [Iterator::collect]
use NBest;
let numbers = vec!;
let n_best = with_cmp_fn_and_iter;
assert_eq!;
Future Work: This implementation uses [BinaryHeap], but an internal implementation would be more efficient because it currently needs to store a copy of the compare function for every retained element.
Future Work: Explore making the N value a constant parameter. It might be more efficient, and it would allow the [FromIterator] trait to be implemented. On the other hand type parameters are uglier to work with than arguments passed at runtime.