diff options
Diffstat (limited to 'apt-pkg/solver3.h')
| -rw-r--r-- | apt-pkg/solver3.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/apt-pkg/solver3.h b/apt-pkg/solver3.h index a3ec859bb..af1d749eb 100644 --- a/apt-pkg/solver3.h +++ b/apt-pkg/solver3.h @@ -200,6 +200,7 @@ struct Lit int32_t value; public: + constexpr Lit() : value{0} {} // SAFETY: value must be 31 bit, one bit is needed for the sign. constexpr Lit(Var var) : value{static_cast<int32_t>(var.value)} {} @@ -328,6 +329,8 @@ class Solver inline State &operator[](Var r); inline const State &operator[](Var r) const; + inline std::vector<const Clause *> &watches(Lit lit); + // \brief Heap of the remaining work. // // In contrast to MiniSAT which picks undecided literals and decides them, @@ -364,6 +367,8 @@ class Solver virtual void Discover(Var var) = 0; // \brief Propagate all pending propagations [[nodiscard]] bool Propagate(); + // \brief Propagate all pending propagations + [[nodiscard]] bool Propagate(const Clause *clause, Lit lit); // \brief Return the current level (.size() with casting) level_type decisionLevel() @@ -553,8 +558,8 @@ struct APT::Solver::Solver::State // \brief Clauses owned by this package/version std::vector<std::unique_ptr<Clause>> clauses; - // \brief Reverse clauses, that is dependencies (or conflicts) from other packages on this one - std::vector<const Clause *> rclauses; + // \brief Watches watching a clause by sign + std::vector<const Clause *> watches[2]; }; /** @@ -606,3 +611,8 @@ struct std::hash<APT::Solver::Lit> std::hash<decltype(APT::Solver::Lit::value)> hash_value; std::size_t operator()(const APT::Solver::Lit &v) const noexcept { return hash_value(v.value); } }; + +inline std::vector<const APT::Solver::Clause *> &APT::Solver::Solver::watches(Lit lit) +{ + return (*this)[lit.var()].watches[lit.sign()]; +} |
