Documentation ¶
Index ¶
- Constants
- func Default() differs.Diff
- func EnumerateValues[T comparable, S ~[]T](result differs.Result, a, b S) collections.Enumerator[collections.Tuple2[step.Step, S]]
- func Hirschberg(length int, useReduce bool) differs.Diff
- func Hybrid(length int, useReduce bool, size int) differs.Diff
- func Inline[T comparable, S ~[]T](path differs.Result, a, b S, separator string) []string
- func Merge(path differs.Result, a, b []string) []string
- func PlusMinus(path differs.Result, a, b []string) []string
- func Wagner(size int) differs.Diff
Constants ¶
const DefaultWagnerThreshold = 500
DefaultWagnerThreshold is the point at which the algorithms switch from Hirschberg to Wagner-Fischer. When both length of the comparable are smaller than this value Wagner-Fischer is used. The Wagner matrix will never be larger than this value of entries. If this is less than 4 the Wagner algorithm will not be used.
Variables ¶
This section is empty.
Functions ¶
func Default ¶
Default creates the default diff algorithm with default configuration.
The default is a hybrid Hirschberg with Wagner-Fischer using a reduction at each step and the default Wagner threshold.
func EnumerateValues ¶
func EnumerateValues[T comparable, S ~[]T](result differs.Result, a, b S) collections.Enumerator[collections.Tuple2[step.Step, S]]
EnumerateValues will iterate the given result from a diff of the two given slices where the enumeration contains the correct values for each step.
Typically this is used for lines of a document. The number of A and B values must be the same as used when creating the given results.
func Hirschberg ¶
Hirschberg creates a new Hirschberg algorithm instance for performing a diff.
The given length is the initial score vector size. If the vector is too small it will be reallocated to the larger size. Use -1 to not preallocate the vectors. The useReduce flag indicates if the equal padding edges should be checked at each step of the algorithm or not.
func Hybrid ¶
Hybrid creates a new hybrid Hirschberg with Wagner-Fischer cutoff for performing a diff.
The given length is the initial score vector size of the Hirschberg algorithm. If the vector is too small it will be reallocated to the larger size. Use -1 to not preallocate the vectors. The useReduce flag indicates if the equal padding edges should be checked at each step of the algorithm or not.
The given size is the amount of matrix space, width * height, to use for the Wagner-Fischer. This must be greater than 4 fo use the cutoff. The larger the size, the more memory is used creating the matrix but the earlier the Wagner-Fischer algorithm can take over.
func Inline ¶
func Inline[T comparable, S ~[]T](path differs.Result, a, b S, separator string) []string
Inline gets the difference with all values that are of the same step type joined into one string prefixed with a symbol indicating the step type.
func Merge ¶
Merge gets the labelled difference between the two slices using a similar output to the git merge differences output.
Types ¶
This section is empty.