aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-16 11:31:43 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-16 11:31:43 +0100
commit9f77de78486d14c7f7aa9716e5d8d9d23bfcabd8 (patch)
tree0692361f5256aabd1d1626cd485aca9d6ca1db38
parentd76f838b1a492c9bd973c5917309391c23bf2ef8 (diff)
downloadpaludis-9f77de78486d14c7f7aa9716e5d8d9d23bfcabd8.tar.gz
paludis-9f77de78486d14c7f7aa9716e5d8d9d23bfcabd8.tar.xz
Make NAG nodes iterable
-rw-r--r--paludis/resolver/nag.cc19
-rw-r--r--paludis/resolver/nag.hh6
2 files changed, 25 insertions, 0 deletions
diff --git a/paludis/resolver/nag.cc b/paludis/resolver/nag.cc
index 04a48a5..0f887c8 100644
--- a/paludis/resolver/nag.cc
+++ b/paludis/resolver/nag.cc
@@ -66,6 +66,12 @@ namespace paludis
{
typedef NodesWithProperties::const_iterator UnderlyingIterator;
};
+
+ template <>
+ struct WrappedForwardIteratorTraits<NAG::NodesConstIteratorTag>
+ {
+ typedef Nodes::const_iterator UnderlyingIterator;
+ };
}
NAG::NAG() :
@@ -269,6 +275,18 @@ NAG::end_edges_from(const Resolvent & r) const
return EdgesFromConstIterator(e->second.end());
}
+NAG::NodesConstIterator
+NAG::begin_nodes() const
+{
+ return NodesConstIterator(_imp->nodes.begin());
+}
+
+NAG::NodesConstIterator
+NAG::end_nodes() const
+{
+ return NodesConstIterator(_imp->nodes.end());
+}
+
void
NAG::serialise(Serialiser & s) const
{
@@ -348,4 +366,5 @@ NAGEdgeProperties::deserialise(Deserialisation & d)
}
template class WrappedForwardIterator<NAG::EdgesFromConstIteratorTag, const std::pair<const Resolvent, NAGEdgeProperties> >;
+template class WrappedForwardIterator<NAG::NodesConstIteratorTag, const Resolvent>;
diff --git a/paludis/resolver/nag.hh b/paludis/resolver/nag.hh
index f9f0ea8..4f400bb 100644
--- a/paludis/resolver/nag.hh
+++ b/paludis/resolver/nag.hh
@@ -74,6 +74,11 @@ namespace paludis
EdgesFromConstIterator begin_edges_from(const Resolvent &) const PALUDIS_ATTRIBUTE((warn_unused_result));
EdgesFromConstIterator end_edges_from(const Resolvent &) const PALUDIS_ATTRIBUTE((warn_unused_result));
+ struct NodesConstIteratorTag;
+ typedef WrappedForwardIterator<NodesConstIteratorTag, const Resolvent> NodesConstIterator;
+ NodesConstIterator begin_nodes() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ NodesConstIterator end_nodes() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
void serialise(Serialiser &) const;
static const std::tr1::shared_ptr<NAG> deserialise(Deserialisation & d) PALUDIS_ATTRIBUTE((warn_unused_result));
};
@@ -82,6 +87,7 @@ namespace paludis
#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
extern template class WrappedForwardIterator<resolver::NAG::EdgesFromConstIteratorTag,
const std::pair<const resolver::Resolvent, resolver::NAGEdgeProperties> >;
+ extern template class WrappedForwardIterator<resolver::NAG::NodesConstIteratorTag, const resolver::Resolvent>;
#endif
}