MCPcopy Index your code
hub / github.com/aptly-dev/aptly / StrSliceDeduplicate

Function StrSliceDeduplicate

utils/list.go:80–103  ·  view source on GitHub ↗

StrSliceDeduplicate removes dups in slice

(s []string)

Source from the content-addressed store, hash-verified

78
79// StrSliceDeduplicate removes dups in slice
80func StrSliceDeduplicate(s []string) []string {
81 l := len(s)
82 if l < 2 {
83 return s
84 }
85 if l == 2 {
86 if s[0] == s[1] {
87 return s[0:1]
88 }
89 return s
90 }
91
92 found := make(map[string]bool, l)
93 j := 0
94 for i, x := range s {
95 if !found[x] {
96 found[x] = true
97 s[j] = s[i]
98 j++
99 }
100 }
101
102 return s[:j]
103}
104
105// StrSlicesSubstract finds all the strings which are in l but not in r, both slices shoult be sorted
106func StrSlicesSubstract(l, r []string) []string {

Callers 6

ExpandGroupsMethod · 0.92
ImportChangesFilesFunction · 0.92
PublishMethod · 0.92
aptlyRepoAddFunction · 0.92
apiReposPackageFromDirFunction · 0.92

Calls

no outgoing calls

Tested by 1