diffseq

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Edit

type Edit struct {
	A0, A1 int // range A[A0:A1]
	B0, B1 int // range B[B0:B1]
}

An Edit represents a single item in an edit script, either insert, replace, or delete. It contains only changed items, no surrounding equal context.

func Diff

func Diff[S Seq](a, b S, eq Equal[S]) []Edit

Diff finds an edit script to transform a into b. Function eq is used to determine equality of items.

func DiffSlice

func DiffSlice[T comparable](a, b []T) []Edit

DiffSlice finds an edit script to transform a into b, using Go's built-in == operator.

type Equal

type Equal[S Seq] func(a, b S, ai, bi int) bool

Equal is a comparison function. It returns whether item ai in sequence a is equal to item bi in sequence b. It is okay for a and b to be the same sequence.

type Seq

type Seq interface {
	Len() int
}

A Seq represents a sequence of items to be compared against another sequence.

Jump to

Keyboard shortcuts

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