topNCopy

fnTRange topNCopy(alias less = "a < b", SRange, TRange)(SRange source, TRange target, SortOutput sorted = No.sortOutput) if (isInputRange!(SRange) && isRandomAccessRange!(TRange) && hasLength!(TRange) && hasSlicing!(TRange))

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.

Parameters

lessThe predicate to sort by.
sourceThe source range.
targetThe target range.
sortedWhether to sort the elements copied into target.

Returns

The slice of target containing the copied elements.