Union returns a union of this set with the given set "other". It returns the items that are in either set while maintaining uniqueness constraints. It preserves ordered within each set, and orders the elements in this set before the elements in "other". It is an O(n+m) operation.
(other *OrderedSet)
| 94 | // |
| 95 | // It is an O(n+m) operation. |
| 96 | func (s *OrderedSet) Union(other *OrderedSet) *OrderedSet { |
| 97 | union := NewOrderedSetWithCapacity(other.Cardinality() + s.Cardinality()) |
| 98 | |
| 99 | for _, e := range s.s { |
| 100 | union.Add(e) |
| 101 | } |
| 102 | for _, e := range other.s { |
| 103 | union.Add(e) |
| 104 | } |
| 105 | |
| 106 | return union |
| 107 | } |
| 108 | |
| 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. |
no test coverage detected