MCPcopy Create free account
hub / github.com/baidu/EasyFaaS / Intersection

Method Intersection

pkg/funclet/runtime/cgroup/string.go:126–142  ·  view source on GitHub ↗

Intersection returns a new set which includes the item in BOTH s1 and s2 For example: s1 = {a1, a2} s2 = {a2, a3} s1.Intersection(s2) = {a2}

(s2 String)

Source from the content-addressed store, hash-verified

124// s2 = {a2, a3}
125// s1.Intersection(s2) = {a2}
126func (s1 String) Intersection(s2 String) String {
127 var walk, other String
128 result := NewString()
129 if s1.Len() < s2.Len() {
130 walk = s1
131 other = s2
132 } else {
133 walk = s2
134 other = s1
135 }
136 for key := range walk {
137 if other.Has(key) {
138 result.Insert(key)
139 }
140 }
141 return result
142}
143
144// IsSuperset returns true if and only if s1 is a superset of s2.
145func (s1 String) IsSuperset(s2 String) bool {

Callers

nothing calls this directly

Calls 4

LenMethod · 0.95
HasMethod · 0.95
InsertMethod · 0.95
NewStringFunction · 0.85

Tested by

no test coverage detected