differs

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data interface {
	// ACount is the length of the A data.
	ACount() int

	// BCount is the length of the B data.
	BCount() int

	// Equals determines if the data in A at the index `aIndex`
	// is equal to B at the index `bIndex`.
	Equals(aIndex, bIndex int) bool
}

Data is the interface used to determine a diff for a variety of data types.

type Diff

type Diff interface {
	// Diff performs a diff on the given data and
	// returns the resulting diff path.
	Diff(data Data) Result

	// PlusMinus gets the labelled difference between the two slices.
	// It formats the results by prepending a "+" to new strings in [b],
	// a "-" for any to removed strings from [a], and " " if the strings are the same.
	PlusMinus(a, b []string) []string

	// Merge gets the labelled difference between the two slices
	// using a similar output to the git merge differences output.
	Merge(a, b []string) []string
}

Diff is an instance of a Levenshtein difference algorithm.

type Result

type Result interface {
	// Count get the number of step groups.
	collections.Countable

	// ACount is the length of the A data.
	ACount() int

	// BCount is the length of the B data.
	BCount() int

	// Total gets the sum of all the steps in each group.
	Total() int

	// AddedCount gets the sum of all the added steps.
	AddedCount() int

	// RemovedCount gets the sum of all the removed steps.
	RemovedCount() int

	// HasDiff indicates if there were any differences found.
	HasDiff() bool

	// Enumerates the step groups where each group is the step type
	// and the number of steps to take of that type.
	collections.Enumerable[collections.Tuple2[step.Step, int]]
}

Result contains the steps to take to walk through the diff.

The result is kept as step groups. A step group is a continuous run of the same type of step represented by the step type and the number of steps of that type.

Jump to

Keyboard shortcuts

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