diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2022-07-01 21:49:11 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2022-07-01 21:49:11 -0600 |
commit | bc146f3c56e1582275b884932d560c1e99dfcd25 (patch) | |
tree | f913703c7c613d69ec9d835115e6f2a57f0fe168 | |
parent | 5fa1cbeedb79f5578a1ffe5a6e2af0872d491f20 (diff) |
implement btree lookup
-rw-r--r-- | pkg/util/generic.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/pkg/util/generic.go b/pkg/util/generic.go index 70fed5b..dbe077f 100644 --- a/pkg/util/generic.go +++ b/pkg/util/generic.go @@ -77,3 +77,14 @@ func SortedMapKeys[K constraints.Ordered, V any](m map[K]V) []K { SortSlice(ret) return ret } + +func CmpUint[T constraints.Unsigned](a, b T) int { + switch { + case a < b: + return -1 + case a == b: + return 0 + default: + return 1 + } +} |