select

Partitions buf with num - 1 as a pivot such that the first num elements will be less than or equal to the remaining elements in the array. Comparisons will be performed using the supplied predicate or '<' if none is supplied. The algorithm is not required to be stable.

  1. size_t select(Elem[] buf, Num num, Pred2E pred)
    version(TangoDoc)
    select
  2. template select(Buf, Num)
  3. template select(Buf, Num, Pred)

Parameters

buf Elem[]

The array to partition. This parameter is not marked 'ref' to allow temporary slices to be sorted. As buf is not resized in any way, omitting the 'ref' qualifier has no effect on the result of this operation, even though it may be viewed as a side-effect.

num Num

The number of elements which are considered significant in this array, where num - 1 is the pivot around which partial sorting will occur. For example, if num is buf.length / 2 then select will effectively partition the array around its median value, with the elements in the first half of the array evaluating as less than or equal to the elements in the second half.

pred Pred2E

The evaluation predicate, which should return true if e1 is less than e2 and false if not. This predicate may be any callable type.

Return Value

Type: size_t

The index of the pivot point, which will be the lesser of num - 1 and buf.length.

Meta