var skillsOfA: Set<String> = ["swift", "OC"]
var emptySet1: Set<Int> = []
var emptySet2: Set<Double>;()
var vowels = Set(["A","S","W","E"])
var skillsOfB: Set = ["aaa","sss","ddd"]
skillsOfB.count
let set:Set<Int> = [2,2,2,2]
set.count
skillsOfB.isEmpty
emptySet1.isEmpty
let e = skillsOfA.first
skillsOfA.contains("OC")
for skill in skillsOfB{
print(skill)
}
let setA: Set = [1,2,3]
let setB: Set = [1,2,3]
setA == setB//无序,没有重复的元素
var skillsOfA: Set<String> = ["swift", "OC"]
var skillsOfB: Set<String> = ["HTML","CSS","Javascript"]
var skillsOfC: Set<String> = []
skillsOfC.insert("swift")
skillsOfC.insert("HTML")
skillsOfC.insert("CSS")
skillsOfC.insert("CSS")
skillsOfC.remove("CSS")
skillsOfC
skillsOfC.remove("Javascript")
skillsOfC
if let skill = skillsOfC.remove("HTML"){
print("HTML is remove")
}
skillsOfC.removeAll()
集合的运算,交集,并集,。。。。。
var skillsOfA: Set<String> = ["swift", "OC"]
var skillsOfB: Set<String> = ["HTML","CSS","Javascript"]
var skillsOfC: Set<String> = ["swift","HTML","CSS"]
skillsOfA.union(skillsOfC)
skillsOfA
//skillsOfA.unionInPlace(skillsOfC)
//skillsOfA
skillsOfA.intersect(skillsOfC)
skillsOfA
//skillsOfA.intersectInPlace(skillsOfC)
//skillsOfA
skillsOfA.subtract(skillsOfC)
skillsOfC.subtract(skillsOfA)
skillsOfA.exclusiveOr(skillsOfC)
var skillsOfD: Set = ["swift"]
skillsOfD.isSubsetOf(skillsOfA)
skillsOfD.isStrictSubsetOf(skillsOfA)
skillsOfA.isSupersetOf(skillsOfD)
skillsOfA.isStrictSupersetOf(skillsOfD)
skillsOfA.isDisjointWith(skillsOfB)
skillsOfA.isDisjointWith(skillsOfC)
网友评论