Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var SplitKey = struct{}{}
SplitKey for context
Functions ¶
Types ¶
type Comparable ¶
type Comparable interface { // String for comparison, such as the hash String() string }
Comparable interface
type Indices ¶ added in v0.31.2
type Indices []int
Indices is the index list of items in xs that forms the LCS between xs and ys.
type Sequence ¶
type Sequence []Comparable
Sequence list
func StandardLCS ¶
StandardLCS implementation for testing purpose only, because it's very inefficient. https://en.wikipedia.org/wiki/Longest_common_subsequence_problem#LCS_function_defined.
func (Sequence) IsSubsequenceOf ¶
IsSubsequenceOf returns true if x is a subsequence of y
func (Sequence) Occurrence ¶ added in v0.31.1
Occurrence returns the position of each element of y in x.
func (Sequence) YadLCS ¶
YadLCS returns the x index of each Comparable that are in the YadLCS between x and y. The complexity is O(M * log(L)), M is the number of char matches between x and y, L is the length of LCS. The worst memory complexity is O(M), but usually it's much less.
The advantage of this algorithm is it's easy to understand and implement. It converts the LCS problem into problems that are familiar to us, such as LIS, binary-search, object-recycle, etc., which give us more room to do the optimization for each streamline.