maxIndex

fnptrdiff_t maxIndex(alias pred = "a < b", Range)(Range range) if (isInputRange!Range && !isInfinite!Range && is(typeof(binaryFun!pred(range.front, range.front))))

Computes the index of the first occurrence of range's maximum element.

Complexity: range Exactly range.length - 1 comparisons are needed.

Parameters

predThe ordering predicate to use to determine the maximum element.
rangeThe input range to search.

Returns

The index of the first encounter of the maximum in range. If the

range is empty, -1 is returned.

Limitations: If at least one of the arguments is NaN, the result is an unspecified value. See maxElement for examples on how to cope with NaNs.

See Also