detect all cycles in roughly linear time and constant space (#2102)

This commit is contained in:
Mark
2023-10-12 23:16:35 -06:00
parent 8aadc99f1d
commit e4a677ceea
3 changed files with 77 additions and 33 deletions

View File

@@ -1,4 +1,6 @@
pub(crate) use crate::machine::gc::{CycleDetectorUMP, IteratorUMP, StacklessPreOrderHeapIter};
#[cfg(test)]
pub(crate) use crate::machine::gc::{IteratorUMP};
pub(crate) use crate::machine::gc::{CycleDetectorUMP, StacklessPreOrderHeapIter};
use crate::atom_table::*;
use crate::machine::heap::*;
@@ -503,6 +505,7 @@ impl<'a, ElideLists: ListElisionPolicy> Iterator for StackfulPreOrderHeapIter<'a
}
}
#[cfg(test)]
#[inline(always)]
pub(crate) fn stackless_preorder_iter(
heap: &mut Vec<HeapCellValue>,
@@ -1265,7 +1268,6 @@ mod tests {
list_loc_as_cell!(1)
);
assert_eq!(iter.next().unwrap(), list_loc_as_cell!(1));
assert_eq!(iter.next(), None);
}