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§
Sourcefn next_candidate(&mut self, solution: &S) -> Option<CandidateId>
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.
fn candidate(&self, id: CandidateId) -> Option<MoveCandidateRef<'_, S, M>>
fn take_candidate(&mut self, id: CandidateId) -> M
Provided Methods§
Sourcefn next_candidate_with_director<D: Director<S>>(
&mut self,
director: &mut D,
) -> Option<CandidateId>
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.
Sourcefn next_candidate_with_control<ShouldStop>(
&mut self,
solution: &S,
should_stop: &mut ShouldStop,
) -> Option<CandidateId>
fn next_candidate_with_control<ShouldStop>( &mut self, solution: &S, should_stop: &mut ShouldStop, ) -> Option<CandidateId>
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.
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)>
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>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".