Longest common subsequence: Difference between revisions

m
Clarified preferNextIndex2 optimization to the Hunt and Szymanski algorithm.
m (syntax highlighting fixup automation)
m (Clarified preferNextIndex2 optimization to the Hunt and Szymanski algorithm.)
Line 573:
 
//
// Look ahead to the next index2 value to optimize spacePairs used inby the Hunt
// and Szymanski algorithm. If the next index2 is also an improvement on
// the value currently held in threshold[index3], a new Pair will only be
// superseded on the next index2 iteration.
//
// DependingVerify onthe matchnext redundancy,value theof numberindex2 ofwill Pairbe constructionsgreater maythan bethe final element
// dividedof bythe factorsnext rangingshorter fromLCS 2at up to 10 or more.prev(limit):
//
auto skipIndex2preferNextIndex2 = next(it2) != dq2.rend() &&
(limit == threshold.begin() || *prev(limit) < *next(it2));
 
//
// Depending on match redundancy, this optimization may reduce the number
// of Pair allocations by factors ranging from 2 up to 10 or more.
//
if (skipIndex2) continue;
 
159

edits