diff

This module implements an algorithm to compute the diff between two sequences of lines.

Types

Item = object
  startA*: int                 ## Start Line number in Data A.
  startB*: int                 ## Start Line number in Data B.
  deletedA*: int               ## Number of changes in Data A.
  insertedB*: int              ## Number of changes in Data B.
  
An Item in the list of differences.   Source Edit

Procs

proc diffInt(arrayA, arrayB: openArray[int]): seq[Item] {...}{.raises: [], tags: [].}

Find the difference in 2 arrays of integers.

arrayA A-version of the numbers (usualy the old one)

arrayB B-version of the numbers (usualy the new one)

Returns a array of Items that describe the differences.

  Source Edit
proc diffText(textA, textB: string): seq[Item] {...}{.raises: [KeyError], tags: [].}

Find the difference in 2 text documents, comparing by textlines.

The algorithm itself is comparing 2 arrays of numbers so when comparing 2 text documents each line is converted into a (hash) number. This hash-value is computed by storing all textlines into a common hashtable so i can find dublicates in there, and generating a new number each time a new textline is inserted.

textA A-version of the text (usually the old one)

textB B-version of the text (usually the new one)

Returns a seq of Items that describe the differences.

  Source Edit