Compare commits

...

2 Commits

Author SHA1 Message Date
cf9c73aa4a v0.0.120 2023-05-24 21:42:10 +02:00
0652bf22dc v0.0.119 2023-05-24 21:32:00 +02:00
2 changed files with 47 additions and 0 deletions

View File

@@ -433,3 +433,10 @@ func ArrConcat[T any](arr ...[]T) []T {
}
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
}

View File

@@ -61,3 +61,43 @@ func CompareArr[T OrderedConstraint](arr1 []T, arr2 []T) bool {
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
}