Similar::Algorithms::IdentifyDistinct(Int)
A utility struct to convert distinct items to unique integers.
This can be helpful on larger inputs to speed up the comparisons performed by doing a first pass where the data set gets reduced to (small) integers.
The idea is that instead of passing two sequences to a diffling algorithm
you first pass it via IdentifyDistinct:
old = ["foo", "bar", "baz"]
new = ["foo", "blah", "baz"]
h = IdentifyDistinct(Int32).new(old, 0...old.size, new, 0...new.size)
ops = Similar.capture_diff(
Algorithm::Myers,
h.old_lookup,
h.old_range,
h.new_lookup,
h.new_range
)
The indexes are the same as with the passed source ranges.