yavom
Yet Another Variation of Myers for generic containers (for example std::Vec)
This is an implementation of a quasi-Myers algorithm to determine the differences between two generic containers. Its usage is quite simple, for example:
let mut a: = vec!
.iter
.map
.collect;
let b: = vec!
.iter
.map
.collect;
// Create the diff (vector of moves)
let moves = cratemyers;
The return value moves is a vector of Move objects. You can apply moves to the array as follows:
moves.iter.for_each;
// now a's contents are the same as b's
You can serialize / deserialize Move objects as you deem necessary. To do so please consider the following definitions (found in diff.h):
;
;
The Vec field stores the values to be inserted. For example:
let ops = myers_unfilled;
let mut patch = vec!;
for o in ops
If you are interested in knowning how many moves will be necessary but do not want to generate complete moves (with complete insert data), you can use the myers_unfilled function:
let mut moves = cratemyers_unfilled;
eprintln!;
Subsequently you can fill the insertion data:
cratemyers_fill;
Credits & License
This code is Copyright (C) 2022 Amos Brocco (contact@amosbrocco.ch)
BSD 3-Clause License