diff options
author | Keuin <[email protected]> | 2022-09-09 02:30:19 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2022-09-09 02:30:41 +0800 |
commit | f028bff042f471a68dff681af9c79ef96bc952e5 (patch) | |
tree | 40763feb1d0ec05260e56d6822622462b35b165a /common/minmax.go | |
parent | 719946a8211f3c8c68234a7c9e9c5af0226386aa (diff) |
Fix file buffer does not take effect. No idea why golang's io utility is so suck. Use ad-hoc buffered copy loop instead.
Diffstat (limited to 'common/minmax.go')
-rw-r--r-- | common/minmax.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/common/minmax.go b/common/minmax.go new file mode 100644 index 0000000..b670887 --- /dev/null +++ b/common/minmax.go @@ -0,0 +1,27 @@ +package common + +/* +Golang is a piece of shit. Its creators are paranoids. +*/ + +import ( + "golang.org/x/exp/constraints" +) + +type Number interface { + constraints.Integer | constraints.Float +} + +func Min[T Number](t1 T, t2 T) T { + if t1 < t2 { + return t1 + } + return t2 +} + +func Max[T Number](t1 T, t2 T) T { + if t1 > t2 { + return t1 + } + return t2 +} |