support comparison and unification of cyclic partial strings
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user