Skip to content

Commit e282bec

Browse files
committed
Minor tweaks
1 parent a11485e commit e282bec

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

std/algorithm/searching.d

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3862,7 +3862,9 @@ if (isInputRange!Range && !isInfinite!Range &&
38623862
}
38633863

38643864
/** Returns an array of the minimum and maximum element in `r`.
3865-
* Makes `< 3n/2` comparisons.
3865+
* Performs `< 3n/2` comparisons, unlike the naive `< 2n`.
3866+
* Params:
3867+
* r = The range to traverse.
38663868
*/
38673869
// TODO alias map = a => a
38683870
ElementType!Range[2] extrema(Range)(Range r)
@@ -3907,15 +3909,20 @@ in (!r.empty)
39073909
return result;
39083910
}
39093911

3910-
unittest
3912+
///
3913+
@safe unittest
39113914
{
39123915
assert(extrema([5,2,9,4,1]) == [1, 9]);
3916+
}
3917+
3918+
@safe unittest
3919+
{
39133920
assert(extrema([8,3,7,4,9]) == [3, 9]);
39143921
assert(extrema([1,5,3,2]) == [1, 5]);
39153922
assert(extrema([2,3,3,2]) == [2, 3]);
39163923

39173924
version (StdRandomTests)
3918-
foreach (i; 0..1000)
3925+
foreach (i; 0 .. 1000)
39193926
{
39203927
import std.random, std.range;
39213928
auto arr = generate!(() => uniform(0, 100)).takeExactly(uniform(1, 10)).array;

0 commit comments

Comments
 (0)