Diff
public struct Diff : DiffProtocol
A sequence of deletions and insertions where deletions point to locations in the source and insertions point to locations in the output. Examples:
"12" -> "": D(0)D(1)
"" -> "12": I(0)I(1)
See also
Diff-
Declaration
Swift
public enum Element
-
Returns the position immediately after the given index.
Declaration
Swift
public func index(after i: Int) -> Int
Parameters
i
A valid index of the collection.
i
must be less thanendIndex
.Return Value
The index value immediately after
i
. -
An array of particular diff operations
Declaration
Swift
public var elements: [Diff.Element]
-
Initializes a new
Diff
from a given array of diff operations.Declaration
Swift
public init(elements: [Diff.Element])
Parameters
elements
an array of particular diff operations
-
Undocumented
Declaration
Swift
public init(traces: [Trace])
-
Declaration
Swift
public init(arrayLiteral elements: Diff.Element...)
-
Generates arbitrarly sorted patch sequence based on the callee. It is a list of steps to be applied to obtain the
to
collection from thefrom
one. The sorting function lets you sort the output e.g. you might want the output patch to have insertions first.Complexity
O(D^2)
Declaration
Swift
public func patch<T: Collection>( from: T, to: T, sort: OrderedBefore ) -> [Patch<T.Element>]
Parameters
from
The source collection (usually the source collecetion of the callee)
to
The target collection (usually the target collecetion of the callee)
sort
A sorting function
Return Value
Arbitrarly sorted sequence of steps to obtain
to
collection from thefrom
one.
-
Generates a patch sequence based on a diff. It is a list of steps to be applied to obtain the
to
collection from thefrom
one.Complexity
O(N)
Parameters
from
The source collection (usually the source collecetion of the callee)
to
The target collection (usually the target collecetion of the callee)
Return Value
A sequence of steps to obtain
to
collection from thefrom
one.