Array
public extension Array
public extension Array where Element: Equatable
-
Returns an Array adding the a new element at the end.
Declaration
Swift
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
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
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.
-
Returns the element at the specified index if it is within bounds, otherwise nil.
Declaration
Swift
subscript(safe index: Index) -> Element? { get }
-
Moves an element to the designated index.
Declaration
Swift
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
mutating func moveToStart(item: Element)
Parameters
item
An element in the array.
-
Moves an element to the end index.
Declaration
Swift
mutating func moveToEnd(item: Element)
Parameters
item
An element in the array.