[Aptitude-svn-commit] r4103 - in branches/aptitude-0.3/aptitude: .
src/generic/problemresolver
Daniel Burrows
dburrows at costa.debian.org
Sat Sep 17 04:09:03 UTC 2005
Author: dburrows
Date: Sat Sep 17 04:09:00 2005
New Revision: 4103
Modified:
branches/aptitude-0.3/aptitude/ChangeLog
branches/aptitude-0.3/aptitude/src/generic/problemresolver/conflictset.h
Log:
Handle the case of an empty right branch.
Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog (original)
+++ branches/aptitude-0.3/aptitude/ChangeLog Sat Sep 17 04:09:00 2005
@@ -1,5 +1,13 @@
2005-09-16 Daniel Burrows <dburrows at debian.org>
+ * src/generic/problemresolver/conflictset.h:
+
+ Properly handle the case of an empty right branch by just
+ setting right_offset to one past the left branch. This is
+ exactly correct, although it has the effect of causing the tree
+ to overlap itself (if you work it out, though, this is exactly
+ what's desired anyway).
+
* tests/test_resolver.cc, src/generic/problemresolver/conflictset.h, src/generic/problemresolver/problemresolver.h:
Add an experimental conflict set optimized under some
Modified: branches/aptitude-0.3/aptitude/src/generic/problemresolver/conflictset.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/problemresolver/conflictset.h (original)
+++ branches/aptitude-0.3/aptitude/src/generic/problemresolver/conflictset.h Sat Sep 17 04:09:00 2005
@@ -142,7 +142,9 @@
struct node
{
/** The number of elements to move forward in the array to reach
- * the right child of this node. If 0, there is no right child.
+ * the right child of this node. If there is no right child,
+ * this is the offset to the end of the left child (which is by
+ * definition where the search goes if there is no right child).
*/
unsigned int right_offset;
@@ -267,12 +269,10 @@
best_split->first,
best_split->second));
+ typename std::vector<node>::size_type right_elt = tree.size();
+ tree[curr_elt].right_offset = right_elt - curr_elt;
if(!right_children.empty())
- {
- typename std::vector<node>::size_type right_elt = tree.size();
- tree[curr_elt].right_offset = right_elt - curr_elt;
- build_tree(right_children, env);
- }
+ build_tree(right_children, env);
}
static void dump(std::ostream &out, const action &act)
@@ -320,8 +320,10 @@
out << ")" << std::endl;
dump(out, elt + 1, "L: ", indent+4);
- if(elt->right_offset > 0)
- dump(out, elt + elt->right_offset ,"R: ", indent+4);
+ // FIXME: whether this is entirely correct is a matter of
+ // opinion; it may do odd things when the tree overlaps
+ // itself.
+ dump(out, elt + elt->right_offset ,"R: ", indent+4);
}
}
}
@@ -379,10 +381,8 @@
if(matches)
++i;
- else if(i->right_offset > 0)
- i += i->right_offset;
else
- ++i;
+ i += i->right_offset;
}
return entries.end();
More information about the Aptitude-svn-commit
mailing list