Corrections on StoreBoolMap
authordeba
Thu, 19 Apr 2007 15:09:08 +0000
changeset 242302fedd6652c6
parent 2422 77ed2b97abbd
child 2424 95cd24940d00
Corrections on StoreBoolMap
- *insert_iterator has void value_type
- use const setting
lemon/maps.h
     1.1 --- a/lemon/maps.h	Thu Apr 19 15:07:03 2007 +0000
     1.2 +++ b/lemon/maps.h	Thu Apr 19 15:09:08 2007 +0000
     1.3 @@ -1044,21 +1044,35 @@
     1.4    inline NotMap<M> notMap(const M &m) {
     1.5      return NotMap<M>(m);
     1.6    }
     1.7 -
     1.8 +  
     1.9    template <typename M> 
    1.10    inline NotWriteMap<M> notMap(M &m) {
    1.11      return NotWriteMap<M>(m);
    1.12    }
    1.13  
    1.14    namespace _maps_bits {
    1.15 +
    1.16      template <typename Value>
    1.17      struct Identity {
    1.18        typedef Value argument_type;
    1.19        typedef Value result_type;
    1.20 -      Value operator()(const Value& val) {
    1.21 +      Value operator()(const Value& val) const {
    1.22  	return val;
    1.23        }
    1.24      };
    1.25 +
    1.26 +    template <typename _Iterator, typename Enable = void>
    1.27 +    struct IteratorTraits {
    1.28 +      typedef typename std::iterator_traits<_Iterator>::value_type Value;
    1.29 +    };
    1.30 +
    1.31 +    template <typename _Iterator>
    1.32 +    struct IteratorTraits<_Iterator,
    1.33 +      typename exists<typename _Iterator::container_type>::type> 
    1.34 +    {
    1.35 +      typedef typename _Iterator::container_type::value_type Value;
    1.36 +    };
    1.37 +
    1.38    }
    1.39    
    1.40  
    1.41 @@ -1085,8 +1099,9 @@
    1.42    /// prim(ugraph, cost, writerMap);
    1.43    ///\endcode
    1.44    template <typename _Iterator, 
    1.45 -            typename _Functor = 
    1.46 -            _maps_bits::Identity<typename std::iterator_traits<_Iterator>::value_type> >
    1.47 +            typename _Functor =
    1.48 +            _maps_bits::Identity<typename _maps_bits::
    1.49 +                                 IteratorTraits<_Iterator>::Value> >
    1.50    class StoreBoolMap {
    1.51    public:
    1.52      typedef _Iterator Iterator;
    1.53 @@ -1111,14 +1126,15 @@
    1.54      }
    1.55  
    1.56      /// Setter function of the map
    1.57 -    void set(const Key& key, Value value) {
    1.58 +    void set(const Key& key, Value value) const {
    1.59        if (value) {
    1.60  	*_end++ = _functor(key);
    1.61        }
    1.62      }
    1.63      
    1.64    private:
    1.65 -    Iterator _begin, _end;
    1.66 +    Iterator _begin;
    1.67 +    mutable Iterator _end;
    1.68      Functor _functor;
    1.69    };
    1.70