Array
public extension Array
public extension Array where Element: Equatable
public extension Array where Element == String
-
Return array containing elements of self that are also in other, plus elements from other that are not in self
Declaration
Swift
func updatedPreservingOrder(from other: Array, predicate: (Element, Element) -> Bool) -> [Element]
Parameters
other
the array to update from
predicate
returns true if a pair of elements, one from each array, satisfies it
Return Value
updated array
-
Update array in-place to contain elements of self that are also in other, plus elements from other that are not in self
Declaration
Swift
mutating func updatePreservingOrder(from other: Array, predicate: (Element, Element) -> Bool)
Parameters
other
the array to update from
predicate
returns true if a pair of elements, one from each array, satisfies it
-
Move the element at old index to new index, modifying self in-place
Declaration
Swift
mutating func move(atIndex old: Index, toIndex new: Index)
Parameters
old
index of the element to move
new
new index of the element
-
Move the element at old index to new index
Declaration
Swift
func moved(atIndex old: Index, toIndex new: Index) -> [Element]
Parameters
old
index of the element to move
new
new index of the element
Return Value
modified copy of self
-
Move the element matching the predicate to index, modifying self in-place
Declaration
Swift
mutating func move(where predicate: (Element) -> Bool, to index: Index)
Parameters
predicate
allows the move if true
index
new position of the element
-
Move the element matching the predicate to index
Declaration
Swift
func moved(where predicate: (Element) -> Bool, to index: Index) -> [Element]
Parameters
predicate
allows the move if true
index
new position of the element
Return Value
modified copy of self
-
Return array containing elements of self that are also in other, plus elements from other that are not in self
Declaration
Swift
func updatedPreservingOrder(from other: Array) -> [Element]
Parameters
other
the array to update from
Return Value
updated array
-
Update array in-place to contain elements of self that are also in other, plus elements from other that are not in self
Declaration
Swift
mutating func updatePreservingOrder(from other: Array)
Parameters
other
the array to update from
-
Move the element to index, modifying self in-place
Declaration
Swift
mutating func move(element: Element, to index: Index)
Parameters
element
to be moved
index
new position of the element
-
Move the element matching the predicate to index
Declaration
Swift
func moved(element: Element, to index: Index) -> [Element]
Parameters
element
to be moved
index
new position of the element
Return Value
modified copy of self
-
Given an array of strings, each optionally sepatated into prefix and suffix by the separator, sort strings aplhabeticall, but grouped by suffix
Declaration
Swift
func sortedBySuffixAndPrefix(separator: String = "_") -> [Element]
Parameters
separator
defaults to “_”
Return Value
sorted array