Array

extension Array
extension Array where Element: Equatable
  • Returns an Array adding the a new element at the end.

    Declaration

    Swift

    public func appending(_ newElement: Element) -> [Element]

    Parameters

    newElement

    The element to append to the Array.

    Return Value

    An Array with the added element at the end.

  • Returns the Array removing the element at the specified index.

    Declaration

    Swift

    public func removing(at index: Int) -> [Element]

    Parameters

    index

    The index of the element to remove from the Array.

    Return Value

    An Array with the element in the specified index removed.

  • Moves an element at the specified index to the designated index.

    Declaration

    Swift

    public mutating func move(at index: Index, to newIndex: Index)

    Parameters

    index

    The current position of the element to move. index must be a valid index of the array.

    newIndex

    The position at which to move the new element. index must be a valid index of the array or equal to its endIndex property.

Available where Element: Equatable

  • Moves an element to the designated index.

    Declaration

    Swift

    public mutating func move(_ item: Element, to newIndex: Index)

    Parameters

    item

    An element in the array.

    newIndex

    The position at which to move the new element. index must be a valid index of the array or equal to its endIndex property.

  • Moves an element to the start index.

    Declaration

    Swift

    public mutating func moveToStart(item: Element)

    Parameters

    item

    An element in the array.

  • Moves an element to the end index.

    Declaration

    Swift

    public mutating func moveToEnd(item: Element)

    Parameters

    item

    An element in the array.