diff options
Diffstat (limited to 'pkg/util/generic.go')
-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 + } +} |