Another set. もう一方の集合。
Instance Method
インスタンスメソッド
form
formSymmetricDifference(_:)
Removes the elements of the set that are also in the given sequence and adds the members of the sequence that are not already in the set.
この集合の要素で与えられたシーケンスの中にもあるものを削除します、そしてシーケンスのメンバで集合の中にはまだないものを加えます。
Availability
- iOS 8.0+
- iPadOS 8.0+
- macOS 10.10+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
- Xcode 10.2+
Technology
- Swift Standard Library Swift標準ライブラリ
Declaration 宣言
mutating func formSymmetricDifference(_ other: Set
<Element>)
Parameters パラメータ
other
Discussion 解説
In the following example, the elements of the employees
set that are also members of neighbors
are removed from employees
, while the elements of neighbors
that are not members of employees
are added to employees
. In particular, the names "Alicia"
, "Chris"
, and "Diana"
are removed from employees
while the names "Forlani"
and "Greta"
are added.
以下の例において、employees
集合の要素でまたneighbors
のメンバであるものはemployees
から削除されます、一方でneighbors
の要素でemployees
の要素でないものはemployees
に加えられます。個別的には、名前"Alicia"
、"Chris"
、そして"Diana"
は、employees
から削除される一方で名前"Forlani"
と"Greta"
は加えられます。
var employees: Set = ["Alicia", "Bethany", "Chris", "Diana", "Eric"]
let neighbors: Set = ["Bethany", "Eric", "Forlani", "Greta"]
employees.formSymmetricDifference(neighbors)
print(employees)
// Prints "["Diana", "Chris", "Forlani", "Alicia", "Greta"]"
Relationships 関係
From Protocol 由来プロトコル
See Also 参照
Combining Sets 集合を結合する
func union<S>(S) -> Set<Element>
Returns a new set with the elements of both this set and the given sequence.
この集合と与えられたシーケンスの両方の要素を持つ新しい集合を返します。
func formUnion <S>(S)
Inserts the elements of the given sequence into the set.
与えられたシーケンスの要素を集合に挿入します。
func intersection(Set<Element>) -> Set<Element>
Returns a new set with the elements that are common to both this set and the given sequence.
この集合と与えられたシーケンスの両方に共通である要素を持つ新しい集合を返します。
func intersection<S>(S) -> Set<Element>
Returns a new set with the elements that are common to both this set and the given sequence.
この集合と与えられたシーケンスの両方に共通である要素を持つ新しい集合を返します。
func formIntersection <S>(S)
Removes the elements of the set that aren’t also in the given sequence.
与えられたシーケンスの中にはない、この集合の要素を削除します。
func symmetricDifference <S>(S) -> Set<Element>
Returns a new set with the elements that are either in this set or in the given sequence, but not in both.
この集合の中か与えられたシーケンスの中かどちらかの、しかし両方の中にではない要素を持つ新しい集合を返します。
func formSymmetricDifference <S>(S)
Replace this set with the elements contained in this set or the given set, but not both.
この集合を、この集合または与えられた集合の中に含まれる、しかし両方にではない要素で置き換えます。
func subtract(Set<Element>)
Removes the elements of the given set from this set.
与えられた集合の要素をこの集合から削除します。
func subtract<S>(S)
Removes the elements of the given sequence from the set.
与えられたシーケンスの要素を集合から削除します。
func subtracting(Set<Element>) -> Set<Element>
Returns a new set containing the elements of this set that do not occur in the given set.
与えられた集合の中の現れないこの集合の要素を含んでいる新しい集合を返します。
func subtracting<S>(S) -> Set<Element>
Returns a new set containing the elements of this set that do not occur in the given sequence.
与えられたシーケンスの中の現れないこの集合の要素を含んでいる新しい集合を返します。