//Constructor public NodeExecutor(NodeVisitor <T> visitor, NodeDiffHandler <T> handler) : base() { _comparer = new NodeComparer <T>(visitor); //Default comparer - override for specifics _verifier = new NodeVerifier <T>(_comparer); //Default verifier - override for specifics _handler = handler; }
//Overrides public virtual bool Compare(T a, T b, NodeDiffHandler <T> handler) { //State _handler = handler; _a = a; _b = b; _same = true; //Simple Algortyhm: // We have a simple rountine that compares(a -> b). // It does this through a brain-dead find routine ie: find(a in b). // // That would give you edits + removals, but unfortunatly doesn't give you additions in b. // So we simply do it twice (ie: find(a, b), then find(b, a), which equates to: // Compare(a, b) = covers: // #1 b's removals (ie: deletions) // #2 b's edits (ie: changes) // Compare(b, a) = coers: // #3 a's removals (ie: insertions) // #4 a's edits from b (ie: changes we don't care about) //First pass: Compare(a -> b) _visitor.Process(a, new NodeHandler <T>(OnLeft)); //Second pass: Compare(b -> a) _visitor.Process(b, new NodeHandler <T>(OnRight)); return(_same); }