Documentation ¶
Overview ¶
package match matches two sorted arrays of int values together: matchTo and matchFrom. The values in matchTo and matchFrom are paired such that the value in matchFrom is as close as possible to the value in matchTo but is never greater than the value in matchTo. Optionally, a maxDiff value can be specified such that the difference between paired values is always less than maxDiff. Values are paired so that the number of matches is maximized.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Match ¶
match returns an []int that is the same size of matchTo. Each element in returned []int is either -1 if the corresponding element in matchTo does not match any in matchFrom or is the matching index in matchFrom. Each element in matchFrom may be associated with at most one element from matchTo. That is the returned array will not contain any duplicate indexes. Both matchTo and matchFrom must be sorted in ascending order. For index j in matchFrom to match index i in matchTo matchTo[i] >= matchFrom[j]. Moreover if maxDiff is positive, then matchTo[i] - matchFrom[i] < maxDiff. Caller should pass a pointer to a slice that is initally nil for buffer. Returned array will always be a slice of buffer (buffer grows as necessary). Returned array is only valid until the next call to this method.
Types ¶
This section is empty.