diff --git a/src/internal/partial_solution.rs b/src/internal/partial_solution.rs index 4edf243f..83389b6f 100644 --- a/src/internal/partial_solution.rs +++ b/src/internal/partial_solution.rs @@ -254,6 +254,24 @@ impl PartialSolution { } } + pub fn prioritized_packages(&self) -> impl Iterator { + let check_all = self.changed_this_decision_level + == self.current_decision_level.0.saturating_sub(1) as usize; + let current_decision_level = self.current_decision_level; + self.package_assignments + .get_range(self.changed_this_decision_level..) + .unwrap() + .iter() + .filter(move |(_, pa)| { + // We only actually need to update the package if its Been changed + // since the last time we called prioritize. + // Which means it's highest decision level is the current decision level, + // or if we backtracked in the mean time. + check_all || pa.highest_decision_level == current_decision_level + }) + .filter_map(|(p, pa)| pa.assignments_intersection.potential_package_filter(p)) + } + pub fn pick_highest_priority_pkg( &mut self, prioritizer: impl Fn(&DP::P, &DP::VS) -> DP::Priority,