3 Star 2 Fork 2

Gitee 极速下载/codis

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/CodisLabs/codis
克隆/下载
math.go 874 Bytes
一键复制 编辑 原始数据 按行查看 历史
spinlock 提交于 2016-08-02 11:35 +08:00 . utils: testcases for package math2
// Copyright 2016 CodisLabs. All Rights Reserved.
// Licensed under the MIT (MIT-LICENSE.txt) license.
package math2
import (
"fmt"
"time"
)
func MaxInt(a, b int) int {
if a > b {
return a
} else {
return b
}
}
func MinInt(a, b int) int {
if a < b {
return a
} else {
return b
}
}
func MinMaxInt(v, min, max int) int {
if min <= max {
v = MaxInt(v, min)
v = MinInt(v, max)
return v
}
panic(fmt.Sprintf("min = %d, max = %d", min, max))
}
func MaxDuration(a, b time.Duration) time.Duration {
if a > b {
return a
} else {
return b
}
}
func MinDuration(a, b time.Duration) time.Duration {
if a < b {
return a
} else {
return b
}
}
func MinMaxDuration(v, min, max time.Duration) time.Duration {
if min <= max {
v = MaxDuration(v, min)
v = MinDuration(v, max)
return v
}
panic(fmt.Sprintf("min = %s, max = %s", min, max))
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors/codis.git
git@gitee.com:mirrors/codis.git
mirrors
codis
codis
de1ad026e329

搜索帮助