Skip to main content

MoveCursor

Trait MoveCursor 

Source
pub trait MoveCursor<S: PlanningSolution, M: Move<S>> {
    // Required methods
    fn next_candidate(&mut self, solution: &S) -> Option<CandidateId>;
    fn candidate(&self, id: CandidateId) -> Option<MoveCandidateRef<'_, S, M>>;
    fn take_candidate(&mut self, id: CandidateId) -> M;

    // Provided methods
    fn next_candidate_with_director<D: Director<S>>(
        &mut self,
        director: &mut D,
    ) -> Option<CandidateId> { ... }
    fn next_candidate_with_control<ShouldStop>(
        &mut self,
        solution: &S,
        should_stop: &mut ShouldStop,
    ) -> Option<CandidateId>
       where ShouldStop: FnMut() -> bool { ... }
    fn next_owned_candidate(&mut self, solution: &S) -> Option<M> { ... }
    fn next_owned_candidate_matching(
        &mut self,
        solution: &S,
        predicate: for<'a> fn(MoveCandidateRef<'a, S, M>) -> bool,
    ) -> Option<M> { ... }
    fn next_owned_candidate_inspected<T, F>(
        &mut self,
        solution: &S,
        inspect: F,
    ) -> Option<(M, T)>
       where F: for<'a> FnMut(MoveCandidateRef<'a, S, M>) -> Option<T> { ... }
    fn apply_owned_candidate<D: Director<S>>(
        &mut self,
        id: CandidateId,
        score_director: &mut D,
    ) { ... }
    fn release_candidate(&mut self, id: CandidateId) -> bool { ... }
    fn selector_index(&self, _id: CandidateId) -> Option<usize> { ... }
}
Expand description

Incremental, cursor-owned candidate storage for a single neighborhood.

next_candidate() constructs or discovers at most the next candidate and returns a stable ID. A consumer may stop at any time: dropping the cursor must release all retained candidates and any unconsumed source state without requiring the remaining neighborhood to be enumerated. Implementations must not rely on full exhaustion for correctness, callback delivery, or cleanup.

Candidates remain borrowable until they are released or transferred. The selected candidate is consumed exactly once through take_candidate() or apply_owned_candidate(); unselected live candidates remain cursor-owned.

Required Methods§

Source

fn next_candidate(&mut self, solution: &S) -> Option<CandidateId>

Pulls the next candidate against the caller’s live working solution.

The solution is lent for the duration of the pull only. Cursors own no solution state: everything derived at open is plain data (indexes, coordinates, seeds), so a commit between pulls invalidates nothing the cursor retains and the next pull always sees current state.

Source

fn candidate(&self, id: CandidateId) -> Option<MoveCandidateRef<'_, S, M>>

Source

fn take_candidate(&mut self, id: CandidateId) -> M

Provided Methods§

Source

fn next_candidate_with_director<D: Director<S>>( &mut self, director: &mut D, ) -> Option<CandidateId>

Pulls the next candidate while lending the live director.

Composite cursors that must preview a child (apply, shadow, check, undo) do so on the caller’s director instead of a cloned preview solution. The default simply forwards to MoveCursor::next_candidate with director.working_solution(); cursors that never mutate keep paying nothing.

Source

fn next_candidate_with_control<ShouldStop>( &mut self, solution: &S, should_stop: &mut ShouldStop, ) -> Option<CandidateId>
where ShouldStop: FnMut() -> bool,

Pulls the next candidate while allowing expensive cursor implementations to observe solve control between units of generation work. A None result may mean either exhaustion or requested interruption, so callers must recheck the same control signal before resolving an exhausted scan.

Source

fn next_owned_candidate(&mut self, solution: &S) -> Option<M>

Source

fn next_owned_candidate_matching( &mut self, solution: &S, predicate: for<'a> fn(MoveCandidateRef<'a, S, M>) -> bool, ) -> Option<M>

Source

fn next_owned_candidate_inspected<T, F>( &mut self, solution: &S, inspect: F, ) -> Option<(M, T)>
where F: for<'a> FnMut(MoveCandidateRef<'a, S, M>) -> Option<T>,

Source

fn apply_owned_candidate<D: Director<S>>( &mut self, id: CandidateId, score_director: &mut D, )

Source

fn release_candidate(&mut self, id: CandidateId) -> bool

Source

fn selector_index(&self, _id: CandidateId) -> Option<usize>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<S, M> MoveCursor<S, M> for ArenaMoveCursor<S, M>
where S: PlanningSolution, M: Move<S>,

Source§

impl<S, V, D> MoveCursor<S, ListChangeMove<S, V>> for NearbyListChangeMoveCursor<'_, S, V, D>
where S: PlanningSolution, V: Clone + PartialEq + Send + Sync + Debug + 'static, D: CrossEntityDistanceMeter<S>,

Source§

impl<S, V, D> MoveCursor<S, ListSwapMove<S, V>> for NearbyListSwapMoveCursor<'_, S, V, D>
where S: PlanningSolution, V: Clone + PartialEq + Send + Sync + Debug + 'static, D: CrossEntityDistanceMeter<S>,

Source§

impl<S, V> MoveCursor<S, ChangeMove<S, V>> for ChangeMoveCursor<S, V>
where S: PlanningSolution, V: Clone + PartialEq + Send + Sync + Debug + 'static,

Source§

impl<S, V> MoveCursor<S, ListChangeMove<S, V>> for ListChangeMoveCursor<S, V>
where S: PlanningSolution, V: Clone + PartialEq + Send + Sync + Debug + 'static,

Source§

impl<S, V> MoveCursor<S, ListMoveUnion<S, V>> for ListPrecedenceMoveCursor<S, V>
where S: PlanningSolution, V: Clone + PartialEq + Send + Sync + Debug + 'static,

Source§

impl<S, V> MoveCursor<S, ListPermuteMove<S, V>> for ListPermuteMoveCursor<S, V>
where S: PlanningSolution, V: Clone + Send + Sync + Debug + 'static,

Source§

impl<S, V> MoveCursor<S, ListReverseMove<S, V>> for ListReverseMoveCursor<S, V>
where S: PlanningSolution, V: Clone + Send + Sync + Debug + 'static,

Source§

impl<S, V> MoveCursor<S, ListRuinMove<S, V>> for ListRuinMoveCursor<S, V>
where S: PlanningSolution, V: Clone + PartialEq + Send + Sync + Debug + 'static,

Source§

impl<S, V> MoveCursor<S, ListSwapMove<S, V>> for ListSwapMoveCursor<S, V>
where S: PlanningSolution, V: Clone + PartialEq + Send + Sync + Debug + 'static,

Source§

impl<S, V> MoveCursor<S, RuinMove<S, V>> for RuinMoveCursor<S, V>
where S: PlanningSolution, V: Clone + Send + Sync + Debug + 'static,

Source§

impl<S, V> MoveCursor<S, SublistChangeMove<S, V>> for SublistChangeMoveCursor<S, V>
where S: PlanningSolution, V: Clone + PartialEq + Send + Sync + Debug + 'static,

Source§

impl<S, V> MoveCursor<S, SublistSwapMove<S, V>> for SublistSwapMoveCursor<S, V>
where S: PlanningSolution, V: Clone + PartialEq + Send + Sync + Debug + 'static,

Source§

impl<S, V> MoveCursor<S, SwapMove<S, V>> for SwapMoveCursor<S, V>
where S: PlanningSolution, V: Clone + PartialEq + Send + Sync + Debug + 'static,

Source§

impl<S> MoveCursor<S, DynamicListChangeMove<S>> for DynamicListChangeMoveCursor<S>