Add adds the given element "i" to the ordered set, unless the element is already present. It returns whether or not the element was added.
(i string)
| 38 | // Add adds the given element "i" to the ordered set, unless the element is |
| 39 | // already present. It returns whether or not the element was added. |
| 40 | func (s *OrderedSet) Add(i string) bool { |
| 41 | if _, ok := s.m[i]; ok { |
| 42 | return false |
| 43 | } |
| 44 | |
| 45 | s.s = append(s.s, i) |
| 46 | s.m[i] = len(s.s) - 1 |
| 47 | |
| 48 | return true |
| 49 | } |
| 50 | |
| 51 | // Contains returns whether or not the given "i" is contained in this ordered |
| 52 | // set. It is a constant-time operation. |
no outgoing calls
no test coverage detected