Add adds x to the set if it is not already there.
(x uint32)
| 37 | |
| 38 | // Add adds x to the set if it is not already there. |
| 39 | func (s *Set) Add(x uint32) { |
| 40 | v := s.sparse[x] |
| 41 | if v < uint32(len(s.dense)) && s.dense[v] == x { |
| 42 | return |
| 43 | } |
| 44 | n := len(s.dense) |
| 45 | s.sparse[x] = uint32(n) |
| 46 | s.dense = append(s.dense, x) |
| 47 | } |
| 48 | |
| 49 | // Has reports whether x is in the set. |
| 50 | func (s *Set) Has(x uint32) bool { |
no outgoing calls