Use pathCopy(from,to) instead of copyPath(to,from) (#321)
authorPeter Kovacs <kpeter@inf.elte.hu>
Fri, 16 Oct 2009 10:21:37 +0200
changeset 404c6acc34f98dc
parent 402 41bdb4d6c8c3
child 405 bfe8377ba349
child 406 e9c203fb003d
Use pathCopy(from,to) instead of copyPath(to,from) (#321)
The old version is kept as a deprecated alternative.
lemon/path.h
     1.1 --- a/lemon/path.h	Mon Oct 12 13:41:15 2009 +0200
     1.2 +++ b/lemon/path.h	Fri Oct 16 10:21:37 2009 +0200
     1.3 @@ -70,7 +70,7 @@
     1.4      /// It simply makes a copy of the given path.
     1.5      template <typename CPath>
     1.6      Path(const CPath& cpath) {
     1.7 -      copyPath(*this, cpath);
     1.8 +      pathCopy(cpath, *this);
     1.9      }
    1.10  
    1.11      /// \brief Template copy assignment
    1.12 @@ -78,7 +78,7 @@
    1.13      /// This operator makes a copy of a path of any other type.
    1.14      template <typename CPath>
    1.15      Path& operator=(const CPath& cpath) {
    1.16 -      copyPath(*this, cpath);
    1.17 +      pathCopy(cpath, *this);
    1.18        return *this;
    1.19      }
    1.20  
    1.21 @@ -258,7 +258,7 @@
    1.22      /// makes a copy of the given path.
    1.23      template <typename CPath>
    1.24      SimplePath(const CPath& cpath) {
    1.25 -      copyPath(*this, cpath);
    1.26 +      pathCopy(cpath, *this);
    1.27      }
    1.28  
    1.29      /// \brief Template copy assignment
    1.30 @@ -267,7 +267,7 @@
    1.31      /// makes a copy of the given path.
    1.32      template <typename CPath>
    1.33      SimplePath& operator=(const CPath& cpath) {
    1.34 -      copyPath(*this, cpath);
    1.35 +      pathCopy(cpath, *this);
    1.36        return *this;
    1.37      }
    1.38  
    1.39 @@ -437,7 +437,7 @@
    1.40      /// makes a copy of the given path.
    1.41      template <typename CPath>
    1.42      ListPath(const CPath& cpath) : first(0), last(0) {
    1.43 -      copyPath(*this, cpath);
    1.44 +      pathCopy(cpath, *this);
    1.45      }
    1.46  
    1.47      /// \brief Destructor of the path
    1.48 @@ -453,7 +453,7 @@
    1.49      /// makes a copy of the given path.
    1.50      template <typename CPath>
    1.51      ListPath& operator=(const CPath& cpath) {
    1.52 -      copyPath(*this, cpath);
    1.53 +      pathCopy(cpath, *this);
    1.54        return *this;
    1.55      }
    1.56  
    1.57 @@ -763,7 +763,7 @@
    1.58      /// This path can be initialized from any other path type.
    1.59      template <typename CPath>
    1.60      StaticPath(const CPath& cpath) : arcs(0) {
    1.61 -      copyPath(*this, cpath);
    1.62 +      pathCopy(cpath, *this);
    1.63      }
    1.64  
    1.65      /// \brief Destructor of the path
    1.66 @@ -779,7 +779,7 @@
    1.67      /// makes a copy of the given path.
    1.68      template <typename CPath>
    1.69      StaticPath& operator=(const CPath& cpath) {
    1.70 -      copyPath(*this, cpath);
    1.71 +      pathCopy(cpath, *this);
    1.72        return *this;
    1.73      }
    1.74  
    1.75 @@ -928,57 +928,57 @@
    1.76        static const bool value = true;
    1.77      };
    1.78  
    1.79 -    template <typename Target, typename Source,
    1.80 -              bool buildEnable = BuildTagIndicator<Target>::value>
    1.81 +    template <typename From, typename To,
    1.82 +              bool buildEnable = BuildTagIndicator<To>::value>
    1.83      struct PathCopySelectorForward {
    1.84 -      static void copy(Target& target, const Source& source) {
    1.85 -        target.clear();
    1.86 -        for (typename Source::ArcIt it(source); it != INVALID; ++it) {
    1.87 -          target.addBack(it);
    1.88 +      static void copy(const From& from, To& to) {
    1.89 +        to.clear();
    1.90 +        for (typename From::ArcIt it(from); it != INVALID; ++it) {
    1.91 +          to.addBack(it);
    1.92          }
    1.93        }
    1.94      };
    1.95  
    1.96 -    template <typename Target, typename Source>
    1.97 -    struct PathCopySelectorForward<Target, Source, true> {
    1.98 -      static void copy(Target& target, const Source& source) {
    1.99 -        target.clear();
   1.100 -        target.build(source);
   1.101 +    template <typename From, typename To>
   1.102 +    struct PathCopySelectorForward<From, To, true> {
   1.103 +      static void copy(const From& from, To& to) {
   1.104 +        to.clear();
   1.105 +        to.build(from);
   1.106        }
   1.107      };
   1.108  
   1.109 -    template <typename Target, typename Source,
   1.110 -              bool buildEnable = BuildTagIndicator<Target>::value>
   1.111 +    template <typename From, typename To,
   1.112 +              bool buildEnable = BuildTagIndicator<To>::value>
   1.113      struct PathCopySelectorBackward {
   1.114 -      static void copy(Target& target, const Source& source) {
   1.115 -        target.clear();
   1.116 -        for (typename Source::RevArcIt it(source); it != INVALID; ++it) {
   1.117 -          target.addFront(it);
   1.118 +      static void copy(const From& from, To& to) {
   1.119 +        to.clear();
   1.120 +        for (typename From::RevArcIt it(from); it != INVALID; ++it) {
   1.121 +          to.addFront(it);
   1.122          }
   1.123        }
   1.124      };
   1.125  
   1.126 -    template <typename Target, typename Source>
   1.127 -    struct PathCopySelectorBackward<Target, Source, true> {
   1.128 -      static void copy(Target& target, const Source& source) {
   1.129 -        target.clear();
   1.130 -        target.buildRev(source);
   1.131 +    template <typename From, typename To>
   1.132 +    struct PathCopySelectorBackward<From, To, true> {
   1.133 +      static void copy(const From& from, To& to) {
   1.134 +        to.clear();
   1.135 +        to.buildRev(from);
   1.136        }
   1.137      };
   1.138  
   1.139      
   1.140 -    template <typename Target, typename Source,
   1.141 -              bool revEnable = RevPathTagIndicator<Source>::value>
   1.142 +    template <typename From, typename To,
   1.143 +              bool revEnable = RevPathTagIndicator<From>::value>
   1.144      struct PathCopySelector {
   1.145 -      static void copy(Target& target, const Source& source) {
   1.146 -        PathCopySelectorForward<Target, Source>::copy(target, source);
   1.147 +      static void copy(const From& from, To& to) {
   1.148 +        PathCopySelectorForward<From, To>::copy(from, to);
   1.149        }      
   1.150      };
   1.151  
   1.152 -    template <typename Target, typename Source>
   1.153 -    struct PathCopySelector<Target, Source, true> {
   1.154 -      static void copy(Target& target, const Source& source) {
   1.155 -        PathCopySelectorBackward<Target, Source>::copy(target, source);
   1.156 +    template <typename From, typename To>
   1.157 +    struct PathCopySelector<From, To, true> {
   1.158 +      static void copy(const From& from, To& to) {
   1.159 +        PathCopySelectorBackward<From, To>::copy(from, to);
   1.160        }      
   1.161      };
   1.162  
   1.163 @@ -987,11 +987,19 @@
   1.164  
   1.165    /// \brief Make a copy of a path.
   1.166    ///
   1.167 -  ///  This function makes a copy of a path.
   1.168 -  template <typename Target, typename Source>
   1.169 -  void copyPath(Target& target, const Source& source) {
   1.170 -    checkConcept<concepts::PathDumper<typename Source::Digraph>, Source>();
   1.171 -    _path_bits::PathCopySelector<Target, Source>::copy(target, source);
   1.172 +  /// This function makes a copy of a path.
   1.173 +  template <typename From, typename To>
   1.174 +  void pathCopy(const From& from, To& to) {
   1.175 +    checkConcept<concepts::PathDumper<typename From::Digraph>, From>();
   1.176 +    _path_bits::PathCopySelector<From, To>::copy(from, to);
   1.177 +  }
   1.178 +
   1.179 +  /// \brief Deprecated version of \ref pathCopy().
   1.180 +  ///
   1.181 +  /// Deprecated version of \ref pathCopy() (only for reverse compatibility).
   1.182 +  template <typename To, typename From>
   1.183 +  void copyPath(To& to, const From& from) {
   1.184 +    pathCopy(from, to);
   1.185    }
   1.186  
   1.187    /// \brief Check the consistency of a path.