1
0
mirror of https://github.com/gilbertchen/duplicacy synced 2025-12-12 14:23:30 +00:00

Added string array helper functions Contains and Find.

This commit is contained in:
a-s-z-home
2018-11-03 20:20:00 +01:00
parent 86c89f43a0
commit 166f6e6266

View File

@@ -474,3 +474,24 @@ func MinInt(x, y int) int {
}
return y
}
// Contains tells whether a contains x.
func Contains(a []string, x string) bool {
for _, n := range a {
if x == n {
return true
}
}
return false
}
// Find returns the smallest index i at which x == a[i],
// or len(a) if there is no such index.
func Find(a []string, x string) int {
for i, n := range a {
if x == n {
return i
}
}
return len(a)
}