MCPcopy Create free account
hub / github.com/weaveworks/scope / Add

Method Add

report/string_set.go:68–81  ·  view source on GitHub ↗

Add adds the strings to the StringSet. Add is the only valid way to grow a StringSet. Add returns the StringSet to enable chaining.

(strs ...string)

Source from the content-addressed store, hash-verified

66// Add adds the strings to the StringSet. Add is the only valid way to grow a
67// StringSet. Add returns the StringSet to enable chaining.
68func (s StringSet) Add(strs ...string) StringSet {
69 for _, str := range strs {
70 i := sort.Search(len(s), func(i int) bool { return s[i] >= str })
71 if i < len(s) && s[i] == str {
72 // The list already has the element.
73 continue
74 }
75 // It a new element, insert it in order.
76 s = append(s, "")
77 copy(s[i+1:], s[i:])
78 s[i] = str
79 }
80 return s
81}
82
83// Merge combines the two StringSets and returns a new result.
84// Second return value is true if the return value is s

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected