<!--
{
  "documentType" : "article",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/Set/SetAlgebra-Implementations",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "SetAlgebra Implementations"
}
-->

# SetAlgebra Implementations

## Topics

### Initializers

[`init()`](/documentation/Swift/Set/init())

Creates an empty set.

[`init<Source>(Source)`](/documentation/Swift/Set/init(_:))

Creates a new set from a finite sequence of items.

[`init<S>(S)`](/documentation/Swift/Set/init(_:)-9cgks)

Creates a new set from a finite sequence of items.

[`init(arrayLiteral: Self.Element...)`](/documentation/Swift/Set/init(arrayLiteral:)-85a3x)

Creates a set containing the elements of the given array literal.

### Instance Methods

[`func contains(Element) -> Bool`](/documentation/Swift/Set/contains(_:))

Returns a Boolean value that indicates whether the given element exists
in the set.

[`func formIntersection<S>(S)`](/documentation/Swift/Set/formIntersection(_:))

Removes the elements of the set that aren’t also in the given sequence.

[`func formSymmetricDifference(Set<Element>)`](/documentation/Swift/Set/formSymmetricDifference(_:)-22p0m)

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.

[`func formUnion<S>(S)`](/documentation/Swift/Set/formUnion(_:))

Inserts the elements of the given sequence into the set.

[`func insert(Element) -> (inserted: Bool, memberAfterInsert: Element)`](/documentation/Swift/Set/insert(_:)-nads)

Inserts the given element in the set if it is not already present.

[`func intersection(Set<Element>) -> Set<Element>`](/documentation/Swift/Set/intersection(_:)-1zh8f)

Returns a new set with the elements that are common to both this set and
the given sequence.

[`func isDisjoint(with: Set<Element>) -> Bool`](/documentation/Swift/Set/isDisjoint(with:)-8ngmk)

Returns a Boolean value that indicates whether this set has no members in
common with the given set.

[`func isSubset(of: Set<Element>) -> Bool`](/documentation/Swift/Set/isSubset(of:)-1d7pp)

Returns a Boolean value that indicates whether this set is a subset of
the given set.

[`func isSuperset(of: Set<Element>) -> Bool`](/documentation/Swift/Set/isSuperset(of:)-9iz62)

Returns a Boolean value that indicates whether this set is a superset of
the given set.

[`func remove(Element) -> Element?`](/documentation/Swift/Set/remove(_:)-8p2tv)

Removes the specified element from the set.

[`func subtract(Self)`](/documentation/Swift/Set/subtract(_:)-7uaak)

Removes the elements of the given set from this set.

[`func subtract(Set<Element>)`](/documentation/Swift/Set/subtract(_:)-8gc48)

Removes the elements of the given set from this set.

[`func subtracting(Set<Element>) -> Set<Element>`](/documentation/Swift/Set/subtracting(_:)-3n4lc)

Returns a new set containing the elements of this set that do not occur
in the given set.

[`func symmetricDifference<S>(S) -> Set<Element>`](/documentation/Swift/Set/symmetricDifference(_:))

Returns a new set with the elements that are either in this set or in the
given sequence, but not in both.

[`func union<S>(S) -> Set<Element>`](/documentation/Swift/Set/union(_:))

Returns a new set with the elements of both this set and the given
sequence.

[`func update(with: Element) -> Element?`](/documentation/Swift/Set/update(with:)-2n6tk)

Inserts the given element into the set unconditionally.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)