[Lemon-commits] [lemon_svn] alpar: r2448 - hugo/trunk/lemon
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:52:43 CET 2006
Author: alpar
Date: Wed Jan 4 14:19:12 2006
New Revision: 2448
Modified:
hugo/trunk/lemon/iterable_maps.h
Log:
IterableBool{Upper/Lower}NodeMaps
Modified: hugo/trunk/lemon/iterable_maps.h
==============================================================================
--- hugo/trunk/lemon/iterable_maps.h (original)
+++ hugo/trunk/lemon/iterable_maps.h Wed Jan 4 14:19:12 2006
@@ -227,6 +227,150 @@
};
};
+ /// Iterable bool UpperNodeMap
+
+ /// This map can be used in the same way
+ /// as the standard UpperNodeMap<bool> of the
+ /// given graph \c Graph.
+ /// In addition, this class provides two iterators called \ref TrueIt
+ /// and \ref FalseIt to iterate through the "true" and "false" nodes.
+ template <class Graph>
+ class IterableBoolUpperNodeMap
+ {
+ typename Graph::template UpperNodeMap<int> cmap;
+
+ public:
+
+ typedef IterableBoolMap<typename Graph::template UpperNodeMap<int> > BimType;
+ BimType imap;
+
+
+ typedef typename BimType::RefType RefType;
+ typedef typename Graph::Node Key;
+ typedef bool Value;
+
+ friend class FalseIt;
+ friend class TrueIt;
+
+ ///\e
+ IterableBoolUpperNodeMap(const Graph &g,bool b=false) : cmap(g), imap(cmap,b) {}
+
+ public:
+ ///\e
+ void set(Key k, bool v) { imap.set(k,v);}
+ ///Number of \c true items in the map
+
+ ///Returns the number of \c true values in the map.
+ ///This is a constant time operation.
+ int countTrue() { return imap.countTrue(); }
+ ///Number of \c false items in the map
+
+ ///Returns the number of \c false values in the map.
+ ///This is a constant time operation.
+ int countFalse() { return imap.countFalse(); }
+#ifdef DOXYGEN
+ ///\e
+ bool &operator[](Key k) { return imap[k];}
+ ///\e
+ const bool &operator[](Key k) const { return imap[k];}
+#else
+ Value operator[](Key k) const { return imap[k];}
+ RefType operator[](Key k) { return imap[k];}
+#endif
+ ///Iterator for the "false" nodes
+ class FalseIt : public BimType::FalseIt
+ {
+ public:
+ ///\e
+ explicit FalseIt(const IterableBoolUpperNodeMap &m)
+ : BimType::FalseIt(m.imap) { }
+ ///\e
+ FalseIt(Invalid i) : BimType::FalseIt(i) { }
+ };
+ ///Iterator for the "true" nodes
+ class TrueIt : public BimType::TrueIt
+ {
+ public:
+ ///\e
+ explicit TrueIt(const IterableBoolUpperNodeMap &m)
+ : BimType::TrueIt(m.imap) { }
+ ///\e
+ TrueIt(Invalid i) : BimType::TrueIt(i) { }
+ };
+ };
+
+ /// Iterable bool LowerNodeMap
+
+ /// This map can be used in the same way
+ /// as the standard LowerNodeMap<bool> of the
+ /// given graph \c Graph.
+ /// In addition, this class provides two iterators called \ref TrueIt
+ /// and \ref FalseIt to iterate through the "true" and "false" nodes.
+ template <class Graph>
+ class IterableBoolLowerNodeMap
+ {
+ typename Graph::template LowerNodeMap<int> cmap;
+
+ public:
+
+ typedef IterableBoolMap<typename Graph::template LowerNodeMap<int> > BimType;
+ BimType imap;
+
+
+ typedef typename BimType::RefType RefType;
+ typedef typename Graph::Node Key;
+ typedef bool Value;
+
+ friend class FalseIt;
+ friend class TrueIt;
+
+ ///\e
+ IterableBoolLowerNodeMap(const Graph &g,bool b=false) : cmap(g), imap(cmap,b) {}
+
+ public:
+ ///\e
+ void set(Key k, bool v) { imap.set(k,v);}
+ ///Number of \c true items in the map
+
+ ///Returns the number of \c true values in the map.
+ ///This is a constant time operation.
+ int countTrue() { return imap.countTrue(); }
+ ///Number of \c false items in the map
+
+ ///Returns the number of \c false values in the map.
+ ///This is a constant time operation.
+ int countFalse() { return imap.countFalse(); }
+#ifdef DOXYGEN
+ ///\e
+ bool &operator[](Key k) { return imap[k];}
+ ///\e
+ const bool &operator[](Key k) const { return imap[k];}
+#else
+ Value operator[](Key k) const { return imap[k];}
+ RefType operator[](Key k) { return imap[k];}
+#endif
+ ///Iterator for the "false" nodes
+ class FalseIt : public BimType::FalseIt
+ {
+ public:
+ ///\e
+ explicit FalseIt(const IterableBoolLowerNodeMap &m)
+ : BimType::FalseIt(m.imap) { }
+ ///\e
+ FalseIt(Invalid i) : BimType::FalseIt(i) { }
+ };
+ ///Iterator for the "true" nodes
+ class TrueIt : public BimType::TrueIt
+ {
+ public:
+ ///\e
+ explicit TrueIt(const IterableBoolLowerNodeMap &m)
+ : BimType::TrueIt(m.imap) { }
+ ///\e
+ TrueIt(Invalid i) : BimType::TrueIt(i) { }
+ };
+ };
+
/// Iterable bool EdgeMap
/// This map can be used in the same way
More information about the Lemon-commits
mailing list