MCPcopy Index your code
hub / github.com/git-lfs/git-lfs / Intersect

Method Intersect

tools/ordered_set.go:111–130  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
111func (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.

Callers

nothing calls this directly

Calls 5

CardinalityMethod · 0.95
ContainsMethod · 0.95
ContainsMethod · 0.65
AddMethod · 0.65

Tested by

no test coverage detected