diff options
author | 2023-01-27 21:04:29 +0000 | |
---|---|---|
committer | 2023-01-27 21:04:29 +0000 | |
commit | 78aca807103640c1abb92d047cc052973254281b (patch) | |
tree | c0c9eee47b4e7583b843d63b1693b92b249ce82a /android/util.go | |
parent | ec41b5c2e2ac19ecf3455549e93e78415282e84b (diff) | |
parent | 4e115cc90de936fd68ce162c847370df5fb5021c (diff) |
Merge "add androidmk cc-related variables to androidmk"
Diffstat (limited to 'android/util.go')
-rw-r--r-- | android/util.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/android/util.go b/android/util.go index a0f716047..234bda365 100644 --- a/android/util.go +++ b/android/util.go @@ -136,6 +136,32 @@ func InList(s string, list []string) bool { return IndexList(s, list) != -1 } +func setFromList[T comparable](l []T) map[T]bool { + m := make(map[T]bool, len(l)) + for _, t := range l { + m[t] = true + } + return m +} + +// ListDifference checks if the two lists contain the same elements +func ListDifference[T comparable](l1, l2 []T) []T { + diff := []T{} + m1 := setFromList(l1) + m2 := setFromList(l2) + for _, t := range l1 { + if _, ok := m2[t]; !ok { + diff = append(diff, t) + } + } + for _, t := range l2 { + if _, ok := m1[t]; !ok { + diff = append(diff, t) + } + } + return diff +} + // Returns true if the given string s is prefixed with any string in the given prefix list. func HasAnyPrefix(s string, prefixList []string) bool { for _, prefix := range prefixList { |