diff options
Diffstat (limited to 'android/util.go')
-rw-r--r-- | android/util.go | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/android/util.go b/android/util.go index 30d8ec6b3..7b305b575 100644 --- a/android/util.go +++ b/android/util.go @@ -102,13 +102,6 @@ func JoinWithPrefixSuffixAndSeparator(strs []string, prefix, suffix, sep string) return buf.String() } -// SortedStringKeys returns the keys of the given map in the ascending order. -// -// Deprecated: Use SortedKeys instead. -func SortedStringKeys[V any](m map[string]V) []string { - return SortedKeys(m) -} - // SortedKeys returns the keys of the given map in the ascending order. func SortedKeys[T cmp.Ordered, V any](m map[T]V) []T { if len(m) == 0 { @@ -213,21 +206,23 @@ func PrettyConcat(list []string, quote bool, lastSep string) string { } // ListSetDifference checks if the two lists contain the same elements. It returns -// a boolean which is true if there is a difference, and then returns lists of elements +// a boolean which is true if there is a difference, and then returns lists of unique elements // that are in l1 but not l2, and l2 but not l1. func ListSetDifference[T comparable](l1, l2 []T) (bool, []T, []T) { listsDiffer := false + l1 = firstUnique(l1) + l2 = firstUnique(l2) diff1 := []T{} diff2 := []T{} m1 := setFromList(l1) m2 := setFromList(l2) - for t := range m1 { + for _, t := range l1 { if _, ok := m2[t]; !ok { diff1 = append(diff1, t) listsDiffer = true } } - for t := range m2 { + for _, t := range l2 { if _, ok := m1[t]; !ok { diff2 = append(diff2, t) listsDiffer = true @@ -238,8 +233,13 @@ func ListSetDifference[T comparable](l1, l2 []T) (bool, []T, []T) { // Returns true if the two lists have common elements. func HasIntersection[T comparable](l1, l2 []T) bool { - _, a, b := ListSetDifference(l1, l2) - return len(a)+len(b) < len(setFromList(l1))+len(setFromList(l2)) + m1 := setFromList(l1) + for _, x := range l2 { + if _, ok := m1[x]; ok { + return true + } + } + return false } // Returns true if the given string s is prefixed with any string in the given prefix list. |