pub struct VisitedSet { /* private fields */ }Expand description
Generation-based visited-node tracker for greedy search.
Avoids clearing a Vec<bool> on every query by incrementing a generation counter.
Implementations§
Source§impl VisitedSet
impl VisitedSet
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Create a new VisitedSet with pre-allocated capacity for capacity nodes.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Reset the visited state for all nodes in O(1) by advancing the generation.
Sourcepub fn ensure_capacity(&mut self, node: usize)
pub fn ensure_capacity(&mut self, node: usize)
Grow the internal buffer if node would be out of range.
Resizing uses node + 1; the maximum ID must permit that addition and allocation.
Sourcepub fn mark_if_new(&mut self, node: usize) -> bool
pub fn mark_if_new(&mut self, node: usize) -> bool
Mark node as visited if it has not been visited in this generation.
Returns true on first visit, false on subsequent calls for the same node.
Resizing uses node + 1, with the same capacity requirements as ensure_capacity.
Sourcepub fn visit(&mut self, node: usize) -> bool
pub fn visit(&mut self, node: usize) -> bool
Mark a node as visited; returns true on its first visit in this generation.
Trait Implementations§
Source§impl Clone for VisitedSet
impl Clone for VisitedSet
Auto Trait Implementations§
impl Freeze for VisitedSet
impl RefUnwindSafe for VisitedSet
impl Send for VisitedSet
impl Sync for VisitedSet
impl Unpin for VisitedSet
impl UnsafeUnpin for VisitedSet
impl UnwindSafe for VisitedSet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more