Index
The position of an element in a set.
@frozen struct IndexThe position of an element in a set.
@frozen struct Indexwhere Element:Hashableimport Swift@frozen struct Set<Element> where Element : HashableAn unordered collection of unique elements.
protocol Hashable : EquatableA type that can be hashed into a Hasher to produce an integer hash value.
init() Creates an empty set.
init<Source>(_ sequence: Source) where Element == Source.Element, Source : Sequence Creates a new set from a finite sequence of items.
init(arrayLiteral elements: Element...) Creates a set containing the elements of the given array literal.
var capacity: Int { get }The total number of elements that the set can contain without allocating new storage.
var count: Int { get }The number of elements in the set.
var customMirror: Mirror { get }A mirror that reflects the set.
var debugDescription: String { get }A string that represents the contents of the set, suitable for debugging.
var description: String { get }A string that represents the contents of the set.
var endIndex: Set<Element>.Index { get }The “past the end” position for the set—that is, the position one greater than the last valid subscript argument.
var isEmpty: Bool { get }A Boolean value that indicates whether the set is empty.
var startIndex: Set<Element>.Index { get }The starting position for iterating members of the set.
subscript(position: Set<Element>.Index) -> Element { get } Accesses the member at the given position.
static func == (lhs: Set<Element>, rhs: Set<Element>) -> Bool Returns a Boolean value indicating whether two sets have equal elements.
func contains(_ member: Element) -> Bool Returns a Boolean value that indicates whether the given element exists in the set.
func filter(_ isIncluded: (Element) throws -> Bool) rethrows -> Set<Element> Returns a new set containing the elements of the set that satisfy the given predicate.
func firstIndex(of member: Element) -> Set<Element>.Index? Returns the index of the given element in the set, or nil if the element is not a member of the set.
func formIndex(after i: inout Set<Element>.Index) mutating func formIntersection<S>(_ other: S) where Element == S.Element, S : Sequence Removes the elements of the set that aren’t also in the given sequence.
mutating func formSymmetricDifference(_ other: Set<Element>) 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.
mutating func formSymmetricDifference<S>(_ other: S) where Element == S.Element, S : Sequence Replace this set with the elements contained in this set or the given set, but not both.
mutating func formUnion<S>(_ other: S) where Element == S.Element, S : Sequence Inserts the elements of the given sequence into the set.
func hash(into hasher: inout Hasher) Hashes the essential components of this value by feeding them into the given hasher.
func index(after i: Set<Element>.Index) -> Set<Element>.Index @discardableResult mutating func insert(_ newMember: Element) -> (inserted: Bool, memberAfterInsert: Element) Inserts the given element in the set if it is not already present.
func intersection(_ other: 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>(_ other: S) -> Set<Element> where Element == S.Element, S : Sequence Returns a new set with the elements that are common to both this set and the given sequence.
func isDisjoint(with other: Set<Element>) -> Bool Returns a Boolean value that indicates whether this set has no members in common with the given set.
func isDisjoint<S>(with other: S) -> Bool where Element == S.Element, S : Sequence Returns a Boolean value that indicates whether the set has no members in common with the given sequence.
func isStrictSubset(of other: Set<Element>) -> Bool Returns a Boolean value that indicates whether the set is a strict subset of the given sequence.
func isStrictSubset<S>(of possibleStrictSuperset: S) -> Bool where Element == S.Element, S : Sequence Returns a Boolean value that indicates whether the set is a strict subset of the given sequence.
func isStrictSuperset(of other: Set<Element>) -> Bool Returns a Boolean value that indicates whether the set is a strict superset of the given sequence.
func isStrictSuperset<S>(of possibleStrictSubset: S) -> Bool where Element == S.Element, S : Sequence Returns a Boolean value that indicates whether the set is a strict superset of the given sequence.
func isSubset(of other: Set<Element>) -> Bool Returns a Boolean value that indicates whether this set is a subset of the given set.
func isSubset<S>(of possibleSuperset: S) -> Bool where Element == S.Element, S : Sequence Returns a Boolean value that indicates whether the set is a subset of the given sequence.
func isSuperset(of other: Set<Element>) -> Bool Returns a Boolean value that indicates whether this set is a superset of the given set.
func isSuperset<S>(of possibleSubset: S) -> Bool where Element == S.Element, S : Sequence Returns a Boolean value that indicates whether the set is a superset of the given sequence.
func makeIterator() -> Set<Element>.Iterator Returns an iterator over the members of the set.
mutating func popFirst() -> Element? Removes and returns the first element of the set.
@discardableResult mutating func remove(_ member: Element) -> Element? Removes the specified element from the set.
@discardableResult mutating func remove(at position: Set<Element>.Index) -> Element Removes the element at the given index of the set.
mutating func removeAll(keepingCapacity keepCapacity: Bool = false) Removes all members from the set.
@discardableResult mutating func removeFirst() -> Element Removes the first element of the set.
mutating func reserveCapacity(_ minimumCapacity: Int) Reserves enough space to store the specified number of elements.
mutating func subtract(_ other: Set<Element>) Removes the elements of the given set from this set.
mutating func subtract<S>(_ other: S) where Element == S.Element, S : Sequence Removes the elements of the given sequence from the set.
func subtracting(_ other: 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>(_ other: S) -> Set<Element> where Element == S.Element, S : Sequence Returns a new set containing the elements of this set that do not occur in the given sequence.
func symmetricDifference<S>(_ other: S) -> Set<Element> where Element == S.Element, S : Sequence 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>(_ other: S) -> Set<Element> where Element == S.Element, S : Sequence Returns a new set with the elements of both this set and the given sequence.
@discardableResult mutating func update(with newMember: Element) -> Element? Inserts the given element into the set unconditionally.
@frozen struct IteratorAn iterator over the members of a Set<Element>.
protocol BitwiseCopyable : ~Escapableprotocol Comparable : EquatableA type that can be compared using the relational operators <, <=, >=, and >.
protocol CopyableA type whose values can be implicitly or explicitly copied.
protocol EquatableA type that can be compared for value equality.
protocol Escapablestatic func < (lhs: Set<Element>.Index, rhs: Set<Element>.Index) -> Bool static func == (lhs: Set<Element>.Index, rhs: Set<Element>.Index) -> Bool func hash(into hasher: inout Hasher) Hashes the essential components of this value by feeding them into the given hasher.
static func != (lhs: Self, rhs: Self) -> Bool Returns a Boolean value indicating whether two values are not equal.
static func ... (minimum: Self) -> PartialRangeFrom<Self> Returns a partial range extending upward from a lower bound.
static func ... (maximum: Self) -> PartialRangeThrough<Self> Returns a partial range up to, and including, its upper bound.
static func ... (minimum: Self, maximum: Self) -> ClosedRange<Self> Returns a closed range that contains both of its bounds.
static func ..< (maximum: Self) -> PartialRangeUpTo<Self> Returns a partial range up to, but not including, its upper bound.
static func ..< (minimum: Self, maximum: Self) -> Range<Self> Returns a half-open range that contains its lower bound but not its upper bound.
static func <= (lhs: Self, rhs: Self) -> Bool Returns a Boolean value indicating whether the value of the first argument is less than or equal to that of the second argument.
static func > (lhs: Self, rhs: Self) -> Bool Returns a Boolean value indicating whether the value of the first argument is greater than that of the second argument.
static func >= (lhs: Self, rhs: Self) -> Bool Returns a Boolean value indicating whether the value of the first argument is greater than or equal to that of the second argument.
protocol SendableA thread-safe type whose values can be shared across arbitrary concurrent contexts without introducing a risk of data races. Values of the type may have no shared mutable state, or they may protect that state with a lock or by forcing it to only be accessed from a specific actor.