Created
December 23, 2010 23:59
-
-
Save autumnharmony/753715 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (F1.Info == F2.Info){ | |
#region если вхождение в самом начале | |
Debug.WriteLine("предположительно есть совпадение в начале"); | |
p = F1; | |
pp = F2; | |
//Node t = p; | |
matched = false; | |
while (pp!=null && p!=null){ | |
matched = true; | |
if (p.Info != pp.Info) { | |
matched = false; | |
break; | |
} | |
//else{ | |
//matched = true; | |
p=p.Link; | |
pp=pp.Link; | |
//} | |
Debug.WriteLine("!!! p ="+p); | |
} | |
// bp | |
if (matched) { | |
// нашли вхождение | |
Debug.WriteLine("и правда, есть вхождение в начале, меняем"); | |
q = (Node)F3.Clone(); | |
F1 = q; | |
while (q.Link!=null){ | |
q=q.Link; | |
} | |
q.Link = p; | |
prep = q; | |
p = q.Link; | |
//Debug.WriteLine("prep ="+prep.Info+" p="+p.Info); | |
} | |
else { | |
Debug.WriteLine("встретилась "+p.Info+"ложная тревога, переходим в "+F1.Link.Info); | |
prep = F1; | |
p = F1.Link; | |
} | |
#endregion | |
} | |
/* | |
else { | |
prep = F1; | |
p = F1.Link; | |
} | |
*/ | |
#region середина и конец | |
while (p!=null){ | |
Debug.WriteLine(p.Info+""); | |
if (p.Info == F2.Info){ | |
Debug.WriteLine("преположительно вхождение"); | |
Debug.WriteLine(p+""); | |
// запомнили начало | |
Node s = p; | |
pp = F2; | |
matched = false; | |
while (pp!=null && p!=null){ | |
//if (){ | |
matched = true; | |
if (pp.Info!=p.Info) { | |
Debug.WriteLine(pp.Info + "!="+p.Info); | |
matched = false; | |
break; | |
} | |
matched = true; | |
//else { | |
// matched = true; | |
pp = pp.Link; | |
p = p.Link; | |
if (pp == null && matched){ | |
matched = true; | |
break; | |
} | |
if (p == null) { | |
matched = false; | |
break; | |
} | |
//} | |
//matched = true; | |
//} | |
/* | |
else { | |
matched = false; | |
break; | |
} | |
*/ | |
} | |
if (matched) { | |
Debug.WriteLine("и правда, меняем"); | |
q = (Node)F3.Clone(); | |
prep.Link = q; | |
while (q.Link!=null){ | |
q=q.Link; | |
} | |
q.Link = p; | |
//prep.Link = q; | |
prep = q; | |
//p = p.Link; | |
Debug.WriteLine("prep = "+prep + " p = "+p); | |
} | |
else { | |
prep = s; | |
p = s.Link; | |
} | |
} | |
else { | |
prep = p; | |
p = p.Link; | |
} | |
} | |
#endregion | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment