diff -r 81563e019fa4 -r cdbba181b786 lemon/maps.h --- a/lemon/maps.h Thu Mar 20 17:15:35 2008 +0100 +++ b/lemon/maps.h Thu Mar 20 21:59:35 2008 +0000 @@ -1667,6 +1667,80 @@ return LessMap(m1,m2); } + namespace _maps_bits { + + template + struct Identity { + typedef Value argument_type; + typedef Value result_type; + Value operator()(const Value& val) const { + return val; + } + }; + + template + struct IteratorTraits { + typedef typename std::iterator_traits<_Iterator>::value_type Value; + }; + + template + struct IteratorTraits<_Iterator, + typename exists::type> + { + typedef typename _Iterator::container_type::value_type Value; + }; + + } + + /// \brief Writable bool map for logging each \c true assigned element + /// + /// A \ref concepts::ReadWriteMap "read-write" bool map for logging + /// each \c true assigned element, i.e it copies subsequently each + /// keys set to \c true to the given iterator. + /// + /// \tparam It the type of the Iterator. + /// \tparam Ke the type of the map's Key. The default value should + /// work in most cases. + /// + /// \note The container of the iterator must contain enough space + /// for the elements. (Or it should be an inserter iterator). + /// + /// \todo Revise the name of this class and give an example code. + template ::Value> + class StoreBoolMap { + public: + typedef It Iterator; + + typedef Ke Key; + typedef bool Value; + + /// Constructor + StoreBoolMap(Iterator it) + : _begin(it), _end(it) {} + + /// Gives back the given iterator set for the first key + Iterator begin() const { + return _begin; + } + + /// Gives back the the 'after the last' iterator + Iterator end() const { + return _end; + } + + /// The set function of the map + void set(const Key& key, Value value) const { + if (value) { + *_end++ = key; + } + } + + private: + Iterator _begin; + mutable Iterator _end; + }; + /// @} }