lemon/bits/vector_map.h
changeset 2031 080d51024ac5
parent 1999 2ff283124dfc
child 2202 09cbc87cb4ab
     1.1 --- a/lemon/bits/vector_map.h	Mon Apr 03 09:24:38 2006 +0000
     1.2 +++ b/lemon/bits/vector_map.h	Mon Apr 03 09:45:23 2006 +0000
     1.3 @@ -27,6 +27,9 @@
     1.4  
     1.5  #include <lemon/bits/alteration_notifier.h>
     1.6  
     1.7 +#include <lemon/concept_check.h>
     1.8 +#include <lemon/concept/maps.h>
     1.9 +
    1.10  ///\ingroup graphbits
    1.11  ///
    1.12  ///\file
    1.13 @@ -112,10 +115,35 @@
    1.14        }
    1.15      }
    1.16  
    1.17 -  private:
    1.18 +    /// \brief Assign operator.
    1.19 +    ///
    1.20 +    /// This operator assigns for each item in the map the
    1.21 +    /// value mapped to the same item in the copied map.  
    1.22 +    /// The parameter map should be indiced with the same
    1.23 +    /// itemset because this assign operator does not change
    1.24 +    /// the container of the map. 
    1.25 +    VectorMap& operator=(const VectorMap& cmap) {
    1.26 +      return operator=<VectorMap>(cmap);
    1.27 +    }
    1.28  
    1.29 -    VectorMap& operator=(const VectorMap&);
    1.30  
    1.31 +    /// \brief Template assign operator.
    1.32 +    ///
    1.33 +    /// The given parameter should be conform to the ReadMap
    1.34 +    /// concecpt and could be indiced by the current item set of
    1.35 +    /// the NodeMap. In this case the value for each item
    1.36 +    /// is assigned by the value of the given ReadMap. 
    1.37 +    template <typename CMap>
    1.38 +    VectorMap& operator=(const CMap& cmap) {
    1.39 +      checkConcept<concept::ReadMap<Key, _Value>, CMap>();
    1.40 +      const typename Parent::Notifier* notifier = Parent::getNotifier();
    1.41 +      Item it;
    1.42 +      for (notifier->first(it); it != INVALID; notifier->next(it)) {
    1.43 +        set(it, cmap[it]);
    1.44 +      }
    1.45 +      return *this;
    1.46 +    }
    1.47 +    
    1.48    public:
    1.49  
    1.50      /// \brief The subcript operator.