internal

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RemoveCost gives the cost to remove A at the given index.
	RemoveCost = 1

	// AddCost gives the cost to add B at the given index.
	AddCost = 1

	// SubstitutionCost gives the substitution cost for replacing A with B at the given indices.
	SubstitutionCost = 2

	// EqualCost gives the cost for A and B being equal.
	EqualCost = 0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Algorithm

type Algorithm interface {
	// NoResizeNeeded determines if the diff algorithm can handle a container with
	// the amount of data inside of the given container. If this returns false a
	// larger matrix, cache, vector, or whatever would be created to perform the diff.
	NoResizeNeeded(cont Container) bool

	// Diff performs the algorithm on the given container
	// and writes the results to the collector.
	Diff(cont Container, col Collector)
}

Algorithm is the interface for a diff algorithm.

type Collector

type Collector interface {
	// InsertAdded inserts new Added parts into this collection.
	// This is expected to be inserted in reverse order from the expected result.
	InsertAdded(count int)

	// InsertRemoved inserts new Removed parts into this collection.
	// This is expected to be inserted in reverse order from the expected result.
	InsertRemoved(count int)

	// InsertEqual inserts new Equal parts into this collection.
	// This is expected to be inserted in reverse order from the expected result.
	InsertEqual(count int)

	// InsertSubstitute inserts new Added and Removed parts into this collection.
	// This is expected to be inserted in reverse order from the expected result.
	InsertSubstitute(count int)

	// Finish inserts any remaining parts which haven't been inserted yet.
	Finish() differs.Result
}

Collector is a tool for collecting the diff result.

type Container

type Container interface {
	differs.Data

	// SubstitutionCost determines the substitution cost for the given indices.
	SubstitutionCost(i, j int) int

	// Sub creates a new data container for a subset and
	// reverse relative to this container's settings.
	// The high values are exclusive, the low is inclusive.
	Sub(aLow, aHigh, bLow, bHigh int, reverse bool) Container

	// Reduce determines how much of the edges of this container are equal.
	// The amount before and after which are equal are returned and
	// the reduced sub-container is returned.
	Reduce() (Container, int, int)

	// EndCase determines if the given container is small enough to be simply added
	// into the collector without any diff algorithm. This will add into the given
	// collector and return true if done, otherwise it will return false.
	EndCase(col Collector) bool
}

Container is a wrapper for the data. It is used to determine subset and revered reading of the data.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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