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

Method Intersect

tools/stringset.go:85–102  ·  view source on GitHub ↗

Returns a new set with items that exist only in both sets.

(other StringSet)

Source from the content-addressed store, hash-verified

83
84// Returns a new set with items that exist only in both sets.
85func (set StringSet) Intersect(other StringSet) StringSet {
86 intersection := NewStringSet()
87 // loop over smaller set
88 if set.Cardinality() < other.Cardinality() {
89 for elem := range set {
90 if other.Contains(elem) {
91 intersection.Add(elem)
92 }
93 }
94 } else {
95 for elem := range other {
96 if set.Contains(elem) {
97 intersection.Add(elem)
98 }
99 }
100 }
101 return intersection
102}
103
104// Returns a new set with items in the current set but not in the other set
105func (set StringSet) Difference(other StringSet) StringSet {

Callers 1

TestOrderedSetIntersectFunction · 0.45

Calls 5

CardinalityMethod · 0.95
AddMethod · 0.95
ContainsMethod · 0.95
NewStringSetFunction · 0.85
ContainsMethod · 0.65

Tested by 1

TestOrderedSetIntersectFunction · 0.36