myers

package
v0.0.0-...-20ebb0f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2021 License: BSD-3-Clause Imports: 3 Imported by: 1

Documentation

Overview

Package myers implements the Myers diff algorithm.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Diff

func Diff(ctx context.Context, ab Pair) edit.Script

Diff calculates an edit.Script for ab using the Myers diff algorithm. This implementation uses the algorithm described in the first half of Myers' paper, which requires quadratric space. (An implementation of the linear space version is forthcoming.)

Because diff calculation can be expensive, Myers supports cancellation via ctx.

Types

type Pair

type Pair interface {
	// LenA returns the number of initial elements.
	LenA() int
	// LenB returns the number of final elements.
	LenB() int
	// Equal reports whether the aᵢ'th element of A is equal to the bᵢ'th element of B.
	Equal(ai, bi int) bool
}

A Pair is two things that can be diffed using the Myers diff algorithm. A is the initial state; B is the final state.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL