RangeReplaceableCollection

protocol RangeReplaceableCollection : Collection where Self.SubSequence : _RangeReplaceableIndexable
  • Mechanica

    Appends a new element.

    Declaration

    Swift

    public func appending(_ element: Element) -> Self
  • Mechanica

    Removes the first element that matches the given condition.

    Declaration

    Swift

    public mutating func removeFirst(where condition: (Element) -> Bool) -> Element?
  • Mechanica

    Removes the first element that matches the given condition and returns a tuple with a new collection and the removed element.

    Declaration

    Swift

    public func removingFirst(where condition: (Element) -> Bool) -> (Self, Element?)

    Return Value

    Returns a tuple with a new collection and the removed element.

  • Mechanica

    Removes the last element that matches the given condition.

    Declaration

    Swift

    public mutating func removeLast(where condition: (Element) -> Bool) -> Element?
  • Mechanica

    Removes the last element that matches the given condition and returns a tuple with a new collection and the removed element.

    Declaration

    Swift

    public func removingLast(where condition: (Element) -> Bool) -> (Self, Element?)

    Return Value

    Returns a tuple with a new collection and the removed element.

  • Mechanica

    Removes all the elements that matches the given condition and returns all the removed element (if any).

    Note

    use filter if you don’t need the removed element.

    Declaration

    Swift

    public mutating func removeAll(where condition: (Element) -> Bool) -> [Element]
  • Mechanica

    Removes all the elements that matches the given condition and returns a tuple with a new collection and the removed elements.

    Note

    use filter if you don’t need the removed element.

    Declaration

    Swift

    public func removingAll(where condition: (Element) -> Bool) -> (Self, [Element])

    Return Value

    Returns a tuple with a new collection and the removed elements.

  • Mechanica Removes the first specified element from the collection (if exists).

    Declaration

    Swift

    public mutating func removeFirstOccurrence(of element: Element) -> Element?

    Return Value

    The element removed (if any).

  • Mechanica

    Removes the last specified element from the array (if exists).

    Declaration

    Swift

    public mutating func removeLastOccurrence(of element: Element) -> Element?

    Return Value

    The element removed (if any).