Class: ONPDiff
- Inherits:
-
Object
- Object
- ONPDiff
- Defined in:
- lib/discourse/onpdiff.rb
Overview
Use “An O(NP) Sequence Comparison Algorithm” as described by Sun Wu, Udi Manber and Gene Myers in www.itu.dk/stud/speciale/bepjea/xwebtex/litt/an-onp-sequence-comparison-algorithm.pdf
Instance Method Summary collapse
- #diff ⇒ Object
-
#initialize(a, b) ⇒ ONPDiff
constructor
A new instance of ONPDiff.
- #short_diff ⇒ Object
Constructor Details
#initialize(a, b) ⇒ ONPDiff
Returns a new instance of ONPDiff.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/discourse/onpdiff.rb', line 5 def initialize(a, b) @a, @b = a, b @m, @n = a.length, b.length @backtrack = [] if @reverse = @m > @n @a, @b = @b, @a @m, @n = @n, @m end @offset = @m + 1 @delta = @n - @m end |
Instance Method Details
#diff ⇒ Object
17 18 19 |
# File 'lib/discourse/onpdiff.rb', line 17 def diff @diff ||= build_edit_script(compose) end |
#short_diff ⇒ Object
21 22 23 |
# File 'lib/discourse/onpdiff.rb', line 21 def short_diff @short_diff ||= build_short_edit_script(compose) end |