[stdlib] add two-operand version of min.

This corresponds to the change on max at r18767.


Swift SVN r18769
This commit is contained in:
Manman Ren
2014-06-10 00:57:08 +00:00
parent fe3a7b0f5e
commit e3517e8792

View File

@@ -299,14 +299,25 @@ func swap<T>(inout a : T, inout b : T) {
}
func min<T : Comparable>(x: T, y: T, rest: T...) -> T {
func min<T : Comparable>(x: T, y: T) -> T {
var r = x
if y < x {
r = y
}
for z in rest {
if z < r {
r = z
return r
}
func min<T : Comparable>(x: T, y: T, z: T, rest: T...) -> T {
var r = x
if y < x {
r = y
}
if z < r {
r = z
}
for t in rest {
if t < r {
r = t
}
}
return r