summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Burrows <dburrows@debian.org>2009-06-06 10:37:55 -0700
committerDaniel Burrows <dburrows@debian.org>2009-06-06 10:37:55 -0700
commit33dafb0b2a65bdfa59c363ffcc5e4dcbc13fcb5e (patch)
tree8944920e9cfdc564d5e7442b7e50d41d62f0e4c3
parent485717cdd41ee7808bbac5bd4128c313f6693ade (diff)
downloadaptitude-33dafb0b2a65bdfa59c363ffcc5e4dcbc13fcb5e.tar.gz
Add a convenience routine in choice_indexed_map that checks whether a map contains a key.
-rw-r--r--src/generic/problemresolver/choice_indexed_map.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/generic/problemresolver/choice_indexed_map.h b/src/generic/problemresolver/choice_indexed_map.h
index def37622..e9e48068 100644
--- a/src/generic/problemresolver/choice_indexed_map.h
+++ b/src/generic/problemresolver/choice_indexed_map.h
@@ -391,6 +391,27 @@ public:
return true;
}
+
+private:
+ // Whenever something is visited, aborts the for_each and returns
+ // false.
+ class not_visited
+ {
+ public:
+ bool operator()(const choice &c, const ValueType &v) const
+ {
+ return false;
+ }
+ };
+
+public:
+ /** \brief Test whether this set contains a key that is contained in
+ * the given choice.
+ */
+ bool contains_key(const choice &c) const
+ {
+ return !for_each_key_contained_in(c, not_visited());
+ }
};
/** \brief A set of objects, indexed for retrieval by an associated