Diff

sealed abstract class Diff[T]

The result of running Myers' diff algorithm against two IndexedSeq instances. Provides the basic deletes and inserts operations required to transform base into target as well as higher-level logic that refines the basic result (like detecting "move" and "replace" ops).

The result of running Myers' diff algorithm against two IndexedSeq instances. Provides the basic deletes and inserts operations required to transform base into target as well as higher-level logic that refines the basic result (like detecting "move" and "replace" ops).

Instances are created with Diff(base, target).

Companion
object
class Object
trait Matchable
class Any

Value members

Abstract methods

def allOps: ArraySeq[Op]

Identifies all operation types (Diff.Op.Delete, Diff.Op.Insert, Diff.Op.Move and Diff.Op.Replace) and returns them sorted by baseIx.

Identifies all operation types (Diff.Op.Delete, Diff.Op.Insert, Diff.Op.Move and Diff.Op.Replace) and returns them sorted by baseIx.

The difference to delInsMovOpsSorted is that deletes and inserts targeting the same baseIx are combined into Diff.Op.Replace instances.

def base: IndexedSeq[T]

The base sequence this Diff was created against.

The base sequence this Diff was created against.

Creates a bidirectional index mapping between base and target, without taking moves into account. This means that elements that have been moved will not have their indices mapped. They simply appear as "not present" in the other sequence.

Creates a bidirectional index mapping between base and target, without taking moves into account. This means that elements that have been moved will not have their indices mapped. They simply appear as "not present" in the other sequence.

The benefit over bimap is the reduced overhead since the O(N^^2) move detection doesn't have to be performed.

def bimap: Bimap

Creates a bidirectional index mapping between base and target, taking moves into account.

Creates a bidirectional index mapping between base and target, taking moves into account.

def chunks: ArraySeq[Chunk[T]]

Segments the inputs into a sequence of chunks representing the diff in a alternative form, that is sometimes better suited to the task at hand than allOps and friends.

Segments the inputs into a sequence of chunks representing the diff in a alternative form, that is sometimes better suited to the task at hand than allOps and friends.

def delInsMovOps: ArraySeq[DelInsMov]

Returns an optimal number of the Diff.Op.DelInsMov operations required to transform base into target. Spends an additional O(N^^2) time on finding Diff.Op.Move operations.

Returns an optimal number of the Diff.Op.DelInsMov operations required to transform base into target. Spends an additional O(N^^2) time on finding Diff.Op.Move operations.

Note that a move is only identified as such if a Diff.Op.Delete has a directly corresponding Diff.Op.Insert. There is no further search for moves in subsets of individual deletes or inserts. Or said differently: Deletes and Inserts are never split to identify potential moves between parts of them.

Returns the delInsMovOps sorted by baseIx.

Returns the delInsMovOps sorted by baseIx.

def delInsOps: ArraySeq[DelIns]

Returns the basic deletes and inserts in one sequence, with the deletes preceding the inserts.

Returns the basic deletes and inserts in one sequence, with the deletes preceding the inserts.

def delInsOpsSorted: ArraySeq[DelIns]

Returns the delInsOps sorted by baseIx.

Returns the delInsOps sorted by baseIx.

def deletes: ArraySeq[Delete]

The Diff.Op.Delete operations that, together with inserts, are required to transform base into target.

The Diff.Op.Delete operations that, together with inserts, are required to transform base into target.

def inserts: ArraySeq[Insert]

The Diff.Op.Insert operations that, together with deletes, are required to transform base into target.

The Diff.Op.Insert operations that, together with deletes, are required to transform base into target.

def longestCommonSubsequence(ct: ClassTag[T]): ArraySeq[T]

Returns a longest common subsequence of the base and target sequences. or None, if the two sequences have no elements in common. Stacksafe and reasonably efficient.

Returns a longest common subsequence of the base and target sequences. or None, if the two sequences have no elements in common. Stacksafe and reasonably efficient.

NOTE: If you only need the longestCommonSubsequence then directly calling Diff.longestCommonSubsequence(base, target) is more efficient than Diff(base, target).longestCommonSubsequence!

def minEditDistance: Int

Returns the minimum number of edits required to transform base and target, whereby one "edit" corresponds to deleting or inserting one single element.

Returns the minimum number of edits required to transform base and target, whereby one "edit" corresponds to deleting or inserting one single element.

Same as delInsOps.map(_.count).sum but slightly more efficient.

NOTE: If you only need the minEditDistance then directly calling Diff.minEditDistance(base, target) is more efficient than Diff(base, target).minEditDistance!

def patch(ct: ClassTag[T]): Patch[T]

Identifies move operations and packages the diff data into a Diff.Patch instances, which contains all information required to produce the target sequence when only the base sequence is given.

Identifies move operations and packages the diff data into a Diff.Patch instances, which contains all information required to produce the target sequence when only the base sequence is given.

def target: IndexedSeq[T]

The target sequence this Diff was created against.

The target sequence this Diff was created against.