MCPcopy
hub / github.com/git-lfs/git-lfs / Union

Method Union

tools/ordered_set.go:96–107  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

94//
95// It is an O(n+m) operation.
96func (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.

Callers 1

SymmetricDifferenceMethod · 0.45

Calls 3

CardinalityMethod · 0.95
AddMethod · 0.65

Tested by

no test coverage detected