The OpenD Programming Language

topN

Stores the smallest elements of the two ranges in the left-hand range.

  1. auto topN(Range r, size_t nth)
  2. auto topN(Range1 r1, Range2 r2)
    topN
    (
    alias less = "a < b"
    Range1
    Range2
    )
    (
    Range1 r1
    ,
    Range2 r2
    )
    if (
    isRandomAccessRange!(Range1) &&
    hasLength!Range1
    &&
    &&
    is(ElementType!Range1 == ElementType!Range2)
    &&
    &&
    )

Parameters

less

The predicate to sort by.

ss

The swapping strategy to use.

r1 Range1

The first range.

r2 Range2

The second range.

Examples

int[] a = [ 5, 7, 2, 6, 7 ];
int[] b = [ 2, 1, 5, 6, 7, 3, 0 ];
topN(a, b);
sort(a);
assert(a == [0, 1, 2, 2, 3]);

Meta