support comparison and unification of cyclic partial strings

This commit is contained in:
Mark Thom
2021-11-17 23:29:23 -07:00
parent ffd1b7069f
commit b24e7cce38
3 changed files with 134 additions and 113 deletions

View File

@@ -113,6 +113,15 @@ impl BrentAlgState {
}
}
#[inline(always)]
pub fn teleport_tortoise(&mut self) {
if self.lam == self.power {
self.tortoise = self.hare;
self.power <<= 1;
self.lam = 0;
}
}
#[inline(always)]
pub fn step(&mut self, hare: usize) -> Option<CycleSearchResult> {
self.hare = hare;
@@ -120,10 +129,8 @@ impl BrentAlgState {
if self.tortoise == self.hare {
return Some(CycleSearchResult::NotList);
} else if self.lam == self.power {
self.tortoise = self.hare;
self.power <<= 1;
self.lam = 0;
} else {
self.teleport_tortoise();
}
None