Instance Method

removeFirst()

Removes the first element of the set.

Declaration

@discardableResult mutating func removeFirst() -> Element

Return Value

A member of the set.

Discussion

Because a set is not an ordered collection, the “first” element may not be the first element that was added to the set. The set must not be empty.

Complexity: Amortized O(1) if the set does not wrap a bridged NSSet. If the set wraps a bridged NSSet, the performance is unspecified.

See Also

Removing Elements

func filter((Element) -> Bool) -> Set<Element>

Returns a new set containing the elements of the set that satisfy the given predicate.

func remove(Element) -> Element?

Removes the specified element from the set.

func remove(at: Set<Element>.Index) -> Element

Removes the element at the given index of the set.

func removeAll(keepingCapacity: Bool)

Removes all members from the set.