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)
| 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. |
| 68 | func (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 |
nothing calls this directly
no outgoing calls
no test coverage detected