Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
cf9c73aa4a
|
|||
0652bf22dc
|
@@ -433,3 +433,10 @@ func ArrConcat[T any](arr ...[]T) []T {
|
|||||||
}
|
}
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ArrCopy does a shallow copy of the 'in' array
|
||||||
|
func ArrCopy[T any](in []T) []T {
|
||||||
|
out := make([]T, len(in))
|
||||||
|
copy(out, in)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
@@ -61,3 +61,43 @@ func CompareArr[T OrderedConstraint](arr1 []T, arr2 []T) bool {
|
|||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CompareString(a, b string) int {
|
||||||
|
if a == b {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
if a < b {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return +1
|
||||||
|
}
|
||||||
|
|
||||||
|
func CompareInt(a, b int) int {
|
||||||
|
if a == b {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
if a < b {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return +1
|
||||||
|
}
|
||||||
|
|
||||||
|
func CompareInt64(a, b int64) int {
|
||||||
|
if a == b {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
if a < b {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return +1
|
||||||
|
}
|
||||||
|
|
||||||
|
func Compare[T OrderedConstraint](a, b T) int {
|
||||||
|
if a == b {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
if a < b {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return +1
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user