mirror of
https://github.com/dlang/phobos.git
synced 2025-05-01 23:50:31 +03:00
Minor tweaks
This commit is contained in:
parent
6c7d0e2ef1
commit
762b0b4881
1 changed files with 10 additions and 3 deletions
|
@ -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]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue