[Aptitude-devel] r2996 - in branches/aptitude-0.3/aptitude: . src/generic/problemresolver

Daniel Burrows dburrows@costa.debian.org
Sun, 10 Apr 2005 02:46:59 +0000


Author: dburrows
Date: Sun Apr 10 02:46:55 2005
New Revision: 2996

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/generic/problemresolver/problemresolver.h
Log:
Fix operator< on solutions; solutions get dropped properly now.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Sun Apr 10 02:46:55 2005
@@ -1,5 +1,12 @@
 2005-04-09  Daniel Burrows  <dburrows@debian.org>
 
+	* src/generic/problemresolver/problemresolver.h:
+
+	  Use map's operator< to order solutions rather than hacking my
+	  own.  Has the benefit of fixing one known and at least one
+	  unknown bug in the ordering of solutions.  Closed solutions
+	  actually get dropped now.
+
 	* src/cmdline/cmdline_do_action.cc:
 
 	  Summarize the proposed solutions as debug output.

Modified: branches/aptitude-0.3/aptitude/src/generic/problemresolver/problemresolver.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/problemresolver/problemresolver.h	(original)
+++ branches/aptitude-0.3/aptitude/src/generic/problemresolver/problemresolver.h	Sun Apr 10 02:46:55 2005
@@ -161,7 +161,7 @@
 
     action(const version &_ver):ver(_ver) {}
 
-    bool operator<(const action &other) {return ver<other.ver;}
+    bool operator<(const action &other) const {return ver<other.ver;}
   };
 
   /** Represents a partial or complete solution to a dependency
@@ -436,7 +436,7 @@
   {
     bool operator()(const solution &s1, const solution &s2) const
     {
-      // Variation on orthographic sort.
+      // Variation on lexicographical comparison.
       //
       // S1 < S2 if
       //   - S1(p)=S2(p) for all p<p' and S1(p')<S2(p'), where
@@ -445,26 +445,7 @@
       const std::map<package,action>
 	&a1=s1.get_actions(), &a2=s2.get_actions();
 
-      if(a1.size()<a2.size())
-	return true;
-      else if(a2.size()<a1.size())
-	return true;
-
-      i1=a1.begin();
-      i2=a2.begin();
-
-      while(i1!=a1.end() && i2!=a2.end())
-	{
-	  if(i1->second.ver < i2->second.ver)
-	    return true;
-	  else if(i2->second.ver < i1->second.ver)
-	    return false;
-
-	  ++i1;
-	  ++i2;
-	}
-
-      return false;
+      return a1 < a2;
     }
   };
 
@@ -730,6 +711,8 @@
     // should enqueue a new root node.
     if(open.empty())
       {
+	closed.clear();
+
 	std::set<dep> broken;
 
 	// Find all the broken deps.
@@ -763,7 +746,12 @@
 
 	// If all dependencies are satisfied, we found a solution.
 	if(s.get_broken().empty())
-	  return s;
+	  {
+	    std::cout << " --- Found solution ";
+	    s.dump(std::cout);
+	    std::cout << std::endl;
+	    return s;
+	  }
 	// Nope, let's go enqueue successor nodes.
 	else
 	  process_solution(s);