Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DiffSolution ¶
type DiffSolution struct {
Lines [][3]string
}
DiffSolution contains a set of lines, where each element of lines comprises the left and right line, and whether the change was from A or B.
func HistogramDiff ¶
func HistogramDiff(a, b string) *DiffSolution
HistogramDiff uses the histogram diff algorithm to generate a line-based diff between two strings
func SequenceDiff ¶
func SequenceDiff(a, b string) *DiffSolution
SequenceDiff two strings using dynamic programming and return a DiffSolution.
func (*DiffSolution) PostProcess ¶
func (d *DiffSolution) PostProcess()
PostProcess loops over the solution. For each changed region, see if we can move it forward. i.e. if we have the following changeset:
a [b c d] b c
then we move the modified region forward so we have instead:
a b c [d b c]
this heuristic only moves additions or deletions (but never both in a move).
type HistogramDiffer ¶
type HistogramDiffer struct {
// contains filtered or unexported fields
}
HistogramDiffer implements the histogram diff algorithm.
func NewHistogramDiffer ¶
func NewHistogramDiffer(a, b []string) *HistogramDiffer
NewHistogramDiffer returns a HistogramDiffer which diffs the given sequence of words.
func (*HistogramDiffer) Solve ¶
func (h *HistogramDiffer) Solve() *DiffSolution
Solve returns a DiffSolution. Internally it uses solveRange to find all matching regions, then it uses the standard differ to create diffs on the intra-region area.
type LineSource ¶
type LineSource string
LineSource indicates the origin of the solution line.
const ( Unknown LineSource = "" LineFromA LineSource = "<" LineFromB LineSource = ">" LineFromBoth LineSource = "=" LineFromBothEdit LineSource = "~" )
These are valid values for LineSource.
type SequenceDiffer ¶
type SequenceDiffer struct {
// contains filtered or unexported fields
}
SequenceDiffer computes a diff using a dynamic programming algorithm.
func NewSequenceDiffer ¶
func NewSequenceDiffer(a, b []string) *SequenceDiffer
NewSequenceDiffer returns a new SequenceDiffer to compare two lists of strings.
func (*SequenceDiffer) Solve ¶
func (d *SequenceDiffer) Solve() *DiffSolution
Solve the diff using dyanmic programming.
type Solver ¶
type Solver interface {
Solve() *DiffSolution
}
Solver is an interface implemented by the diff algorithms.