在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
A := strset.NewWithSize(0) A.Add("a","b","c","d") B := strset.NewWithSize(0) B.Add("a","d","e","c") unionSet :=strset.NewWithSize(0) //交集 intersectionSet :=strset.NewWithSize(0) //并集 intersectionSet = A.Copy() intersectionSet.Add(B.List()...) if A.HasAny(B.List()...) || B.HasAny(A.List()...){ unionSet = A.Copy() A.Remove(B.List()...) unionSet .Remove(A.List()...) } fmt.Println("交集:",unionSet ) fmt.Println("并集:",intersectionSet)
|
请发表评论