Generic Instance Method

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.

Declaration

func difference<C>(from other: C, by areEquivalent: (C.Element, UTF16.CodeUnit) -> Bool) -> CollectionDifference<UTF16.CodeUnit> 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.

Return Value

The difference needed to produce the reciever’s state from the parameter’s state.

Discussion

This function does not infer element moves. If you need to infer moves, call the inferringMoves() method on the resulting difference.

Complexity: Worst case performance is O(n * m), where n is the count of this collection and m is other.count. You can expect faster execution when the collections share many common elements.