Intersect returns the elements that are in both this set and then given "ordered" set. It is an O(min(n, m)) (in other words, O(n)) operation.
(other *OrderedSet)
| 109 | // Intersect returns the elements that are in both this set and then given |
| 110 | // "ordered" set. It is an O(min(n, m)) (in other words, O(n)) operation. |
| 111 | func (s *OrderedSet) Intersect(other *OrderedSet) *OrderedSet { |
| 112 | intersection := NewOrderedSetWithCapacity(min( |
| 113 | s.Cardinality(), other.Cardinality())) |
| 114 | |
| 115 | if s.Cardinality() < other.Cardinality() { |
| 116 | for _, elem := range s.s { |
| 117 | if other.Contains(elem) { |
| 118 | intersection.Add(elem) |
| 119 | } |
| 120 | } |
| 121 | } else { |
| 122 | for _, elem := range other.s { |
| 123 | if s.Contains(elem) { |
| 124 | intersection.Add(elem) |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | return intersection |
| 130 | } |
| 131 | |
| 132 | // Difference returns the elements that are in this set, but not included in |
| 133 | // other. |
nothing calls this directly
no test coverage detected