The predicate to sort by.
The source range.
The target range.
Whether to sort the elements copied into target.
The slice of target containing the copied elements.
import std.typecons : Yes; int[] a = [ 10, 16, 2, 3, 1, 5, 0 ]; int[] b = new int[3]; topNCopy(a, b, Yes.sortOutput); assert(b == [ 0, 1, 2 ]);
Copies the top n elements of the input range source into the random-access range target, where n = target.length.
Elements of source are not touched. If sorted is true, the target is sorted. Otherwise, the target respects the heap property.