mirror of
https://github.com/dlang/phobos.git
synced 2025-05-04 17:11:26 +03:00
13 lines
401 B
Text
13 lines
401 B
Text
Added `std.algorithm.searching.maxIndex` to get the index of the maximum element of a range.
|
|
|
|
`std.algorithm.searching.maxIndex` gets the index of the maximum element of a range,
|
|
according to a specified predicate. The default predicate is "a > b".
|
|
|
|
-------
|
|
import std.algorithm.searching : maxIndex;
|
|
int[] a = [5, 4, 2, 1, 9, 10];
|
|
assert(a.minIndex == 5);
|
|
|
|
int[] a;
|
|
assert(a.minIndex == -1);
|
|
-------
|