gitee.com/sy_183/go-common@v1.0.5-0.20231205030221-958cfe129b47/container/comparable.go (about) 1 package container 2 3 import "gitee.com/sy_183/go-common/generic" 4 5 type Comparable interface { 6 Compare(other Comparable) int 7 } 8 9 func OrderedCompare[Ordered generic.Ordered](n1, n2 Ordered) int { 10 switch { 11 case n1 < n2: 12 return -1 13 case n1 > n2: 14 return 1 15 default: 16 return 0 17 } 18 }