Instance Methodswift 6.0.1Swift
difference(from:by:)
Returns the difference needed to produce this collection’s ordered elements from the given collection, using the given predicate as an equivalence test.
- iOS
- 13.0+
- macOS
- 10.15+
- tvOS
- 13.0+
- watchOS
- 6.0+
func difference<C>(from other: C, by areEquivalent: (C.Element, Self.Element) -> Bool) -> CollectionDifference<Self.Element> where C : BidirectionalCollection, Self.Element == C.Element
Parameters
- other
The base state.
- areEquivalent
A closure that returns a Boolean value indicating whether two elements are equivalent.
Returns
The difference needed to produce the receiver’s state from the parameter’s state.
This function does not infer element moves. If you need to infer moves, call the inferringMoves()
method on the resulting difference.
Other members in extension
Instance members
var last: Self.Element?
The last element of the collection.
func distance(from: Self.Index, to: Self.Index
) -> Int func dropLast(Int
) -> Self.SubSequence Returns a subsequence containing all but the specified number of final elements.
func formIndex(before: inout Self.Index
) func index(Self.Index, offsetBy: Int
) -> Self.Index func index(Self.Index, offsetBy: Int, limitedBy: Self.Index
) -> Self.Index? func last(where: (Self.Element) throws -> Bool
) rethrows -> Self.Element? Returns the last element of the sequence that satisfies the given predicate.
func lastIndex(where: (Self.Element) throws -> Bool
) rethrows -> Self.Index? Returns the index of the last element in the collection that matches the given predicate.
func reversed(
) -> ReversedCollection<Self> Returns a view presenting the elements of the collection in reverse order.
func suffix(Int
) -> Self.SubSequence Returns a subsequence, up to the given maximum length, containing the final elements of the collection.