From 286a7748a9c7c189492b4d9b9e0de89df2a27fda Mon Sep 17 00:00:00 2001 From: Daniel Burrows Date: Thu, 4 Mar 2010 09:10:04 -0800 Subject: Implement a structural comparison operation on tier operations. --- src/generic/problemresolver/tier_operation.cc | 9 +++++++++ src/generic/problemresolver/tier_operation.h | 4 ++++ 2 files changed, 13 insertions(+) (limited to 'src/generic/problemresolver') diff --git a/src/generic/problemresolver/tier_operation.cc b/src/generic/problemresolver/tier_operation.cc index 8d8ac5fc..1b6e83ba 100644 --- a/src/generic/problemresolver/tier_operation.cc +++ b/src/generic/problemresolver/tier_operation.cc @@ -92,6 +92,15 @@ tier tier_operation::op_impl::apply(const tier &t) const out_user_levels.end()); } +int tier_operation::op_impl::compare(const op_impl &other) const +{ + const int structural_level_cmp = aptitude::util::compare3(structural_level, other.structural_level); + if(structural_level_cmp != 0) + return structural_level_cmp; + else + return aptitude::util::compare3(actions, other.actions); +} + void tier_operation::op_impl::dump(std::ostream &out) const { out << "("; diff --git a/src/generic/problemresolver/tier_operation.h b/src/generic/problemresolver/tier_operation.h index e3ae3759..47ca0029 100644 --- a/src/generic/problemresolver/tier_operation.h +++ b/src/generic/problemresolver/tier_operation.h @@ -144,6 +144,10 @@ class tier_operation */ tier apply(const tier &t) const; + /** \brief Compare two operations by their identity. + */ + int compare(const op_impl &other) const; + /** \brief Dump this operation to a stream. */ void dump(std::ostream &out) const; }; -- cgit v1.2.3