MCPcopy Index your code
hub / github.com/apache/casbin / ArrayRemoveDuplicates

Function ArrayRemoveDuplicates

util/util.go:129–140  ·  view source on GitHub ↗

ArrayRemoveDuplicates removes any duplicated elements in a string array.

(s *[]string)

Source from the content-addressed store, hash-verified

127
128// ArrayRemoveDuplicates removes any duplicated elements in a string array.
129func ArrayRemoveDuplicates(s *[]string) {
130 found := make(map[string]bool)
131 j := 0
132 for i, x := range *s {
133 if !found[x] {
134 found[x] = true
135 (*s)[j] = (*s)[i]
136 j++
137 }
138 }
139 *s = (*s)[:j]
140}
141
142// ArrayToString gets a printable string for a string array.
143func ArrayToString(s []string) string {

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…