Minor tweaks

This commit is contained in:
Nick Treleaven 2023-03-25 16:00:07 +00:00 committed by Elias Batek
parent 6c7d0e2ef1
commit 762b0b4881

View file

@ -4037,7 +4037,9 @@ if (isInputRange!Range && !isInfinite!Range &&
}
/** Returns an array of the minimum and maximum element in `r`.
* Makes `< 3n/2` comparisons.
* Performs `< 3n/2` comparisons, unlike the naive `< 2n`.
* Params:
* r = The range to traverse.
*/
// TODO alias map = a => a
ElementType!Range[2] extrema(Range)(Range r)
@ -4082,9 +4084,14 @@ in (!r.empty)
return result;
}
unittest
///
@safe unittest
{
assert(extrema([5,2,9,4,1]) == [1, 9]);
}
@safe unittest
{
assert(extrema([8,3,7,4,9]) == [3, 9]);
assert(extrema([1,5,3,2]) == [1, 5]);
assert(extrema([2,3,3,2]) == [2, 3]);