lemon/path.h
changeset 764 b96574ff36ec
parent 697 41bdb4d6c8c3
child 702 2305167d2491
child 708 994c7df296c9
equal deleted inserted replaced
14:146c28d42b0a 16:34a812d4ec22
    68     ///
    68     ///
    69     /// This constuctor initializes the path from any other path type.
    69     /// This constuctor initializes the path from any other path type.
    70     /// It simply makes a copy of the given path.
    70     /// It simply makes a copy of the given path.
    71     template <typename CPath>
    71     template <typename CPath>
    72     Path(const CPath& cpath) {
    72     Path(const CPath& cpath) {
    73       copyPath(*this, cpath);
    73       pathCopy(cpath, *this);
    74     }
    74     }
    75 
    75 
    76     /// \brief Template copy assignment
    76     /// \brief Template copy assignment
    77     ///
    77     ///
    78     /// This operator makes a copy of a path of any other type.
    78     /// This operator makes a copy of a path of any other type.
    79     template <typename CPath>
    79     template <typename CPath>
    80     Path& operator=(const CPath& cpath) {
    80     Path& operator=(const CPath& cpath) {
    81       copyPath(*this, cpath);
    81       pathCopy(cpath, *this);
    82       return *this;
    82       return *this;
    83     }
    83     }
    84 
    84 
    85     /// \brief LEMON style iterator for path arcs
    85     /// \brief LEMON style iterator for path arcs
    86     ///
    86     ///
   256     ///
   256     ///
   257     /// This path can be initialized with any other path type. It just
   257     /// This path can be initialized with any other path type. It just
   258     /// makes a copy of the given path.
   258     /// makes a copy of the given path.
   259     template <typename CPath>
   259     template <typename CPath>
   260     SimplePath(const CPath& cpath) {
   260     SimplePath(const CPath& cpath) {
   261       copyPath(*this, cpath);
   261       pathCopy(cpath, *this);
   262     }
   262     }
   263 
   263 
   264     /// \brief Template copy assignment
   264     /// \brief Template copy assignment
   265     ///
   265     ///
   266     /// This path can be initialized with any other path type. It just
   266     /// This path can be initialized with any other path type. It just
   267     /// makes a copy of the given path.
   267     /// makes a copy of the given path.
   268     template <typename CPath>
   268     template <typename CPath>
   269     SimplePath& operator=(const CPath& cpath) {
   269     SimplePath& operator=(const CPath& cpath) {
   270       copyPath(*this, cpath);
   270       pathCopy(cpath, *this);
   271       return *this;
   271       return *this;
   272     }
   272     }
   273 
   273 
   274     /// \brief Iterator class to iterate on the arcs of the paths
   274     /// \brief Iterator class to iterate on the arcs of the paths
   275     ///
   275     ///
   435     ///
   435     ///
   436     /// This path can be initialized with any other path type. It just
   436     /// This path can be initialized with any other path type. It just
   437     /// makes a copy of the given path.
   437     /// makes a copy of the given path.
   438     template <typename CPath>
   438     template <typename CPath>
   439     ListPath(const CPath& cpath) : first(0), last(0) {
   439     ListPath(const CPath& cpath) : first(0), last(0) {
   440       copyPath(*this, cpath);
   440       pathCopy(cpath, *this);
   441     }
   441     }
   442 
   442 
   443     /// \brief Destructor of the path
   443     /// \brief Destructor of the path
   444     ///
   444     ///
   445     /// Destructor of the path
   445     /// Destructor of the path
   451     ///
   451     ///
   452     /// This path can be initialized with any other path type. It just
   452     /// This path can be initialized with any other path type. It just
   453     /// makes a copy of the given path.
   453     /// makes a copy of the given path.
   454     template <typename CPath>
   454     template <typename CPath>
   455     ListPath& operator=(const CPath& cpath) {
   455     ListPath& operator=(const CPath& cpath) {
   456       copyPath(*this, cpath);
   456       pathCopy(cpath, *this);
   457       return *this;
   457       return *this;
   458     }
   458     }
   459 
   459 
   460     /// \brief Iterator class to iterate on the arcs of the paths
   460     /// \brief Iterator class to iterate on the arcs of the paths
   461     ///
   461     ///
   761     /// \brief Template copy constructor
   761     /// \brief Template copy constructor
   762     ///
   762     ///
   763     /// This path can be initialized from any other path type.
   763     /// This path can be initialized from any other path type.
   764     template <typename CPath>
   764     template <typename CPath>
   765     StaticPath(const CPath& cpath) : arcs(0) {
   765     StaticPath(const CPath& cpath) : arcs(0) {
   766       copyPath(*this, cpath);
   766       pathCopy(cpath, *this);
   767     }
   767     }
   768 
   768 
   769     /// \brief Destructor of the path
   769     /// \brief Destructor of the path
   770     ///
   770     ///
   771     /// Destructor of the path
   771     /// Destructor of the path
   777     ///
   777     ///
   778     /// This path can be made equal to any other path type. It simply
   778     /// This path can be made equal to any other path type. It simply
   779     /// makes a copy of the given path.
   779     /// makes a copy of the given path.
   780     template <typename CPath>
   780     template <typename CPath>
   781     StaticPath& operator=(const CPath& cpath) {
   781     StaticPath& operator=(const CPath& cpath) {
   782       copyPath(*this, cpath);
   782       pathCopy(cpath, *this);
   783       return *this;
   783       return *this;
   784     }
   784     }
   785 
   785 
   786     /// \brief Iterator class to iterate on the arcs of the paths
   786     /// \brief Iterator class to iterate on the arcs of the paths
   787     ///
   787     ///
   926       typename enable_if<typename Path::BuildTag, void>::type
   926       typename enable_if<typename Path::BuildTag, void>::type
   927     > {
   927     > {
   928       static const bool value = true;
   928       static const bool value = true;
   929     };
   929     };
   930 
   930 
   931     template <typename Target, typename Source,
   931     template <typename From, typename To,
   932               bool buildEnable = BuildTagIndicator<Target>::value>
   932               bool buildEnable = BuildTagIndicator<To>::value>
   933     struct PathCopySelectorForward {
   933     struct PathCopySelectorForward {
   934       static void copy(Target& target, const Source& source) {
   934       static void copy(const From& from, To& to) {
   935         target.clear();
   935         to.clear();
   936         for (typename Source::ArcIt it(source); it != INVALID; ++it) {
   936         for (typename From::ArcIt it(from); it != INVALID; ++it) {
   937           target.addBack(it);
   937           to.addBack(it);
   938         }
   938         }
   939       }
   939       }
   940     };
   940     };
   941 
   941 
   942     template <typename Target, typename Source>
   942     template <typename From, typename To>
   943     struct PathCopySelectorForward<Target, Source, true> {
   943     struct PathCopySelectorForward<From, To, true> {
   944       static void copy(Target& target, const Source& source) {
   944       static void copy(const From& from, To& to) {
   945         target.clear();
   945         to.clear();
   946         target.build(source);
   946         to.build(from);
   947       }
   947       }
   948     };
   948     };
   949 
   949 
   950     template <typename Target, typename Source,
   950     template <typename From, typename To,
   951               bool buildEnable = BuildTagIndicator<Target>::value>
   951               bool buildEnable = BuildTagIndicator<To>::value>
   952     struct PathCopySelectorBackward {
   952     struct PathCopySelectorBackward {
   953       static void copy(Target& target, const Source& source) {
   953       static void copy(const From& from, To& to) {
   954         target.clear();
   954         to.clear();
   955         for (typename Source::RevArcIt it(source); it != INVALID; ++it) {
   955         for (typename From::RevArcIt it(from); it != INVALID; ++it) {
   956           target.addFront(it);
   956           to.addFront(it);
   957         }
   957         }
   958       }
   958       }
   959     };
   959     };
   960 
   960 
   961     template <typename Target, typename Source>
   961     template <typename From, typename To>
   962     struct PathCopySelectorBackward<Target, Source, true> {
   962     struct PathCopySelectorBackward<From, To, true> {
   963       static void copy(Target& target, const Source& source) {
   963       static void copy(const From& from, To& to) {
   964         target.clear();
   964         to.clear();
   965         target.buildRev(source);
   965         to.buildRev(from);
   966       }
   966       }
   967     };
   967     };
   968 
   968 
   969     
   969     
   970     template <typename Target, typename Source,
   970     template <typename From, typename To,
   971               bool revEnable = RevPathTagIndicator<Source>::value>
   971               bool revEnable = RevPathTagIndicator<From>::value>
   972     struct PathCopySelector {
   972     struct PathCopySelector {
   973       static void copy(Target& target, const Source& source) {
   973       static void copy(const From& from, To& to) {
   974         PathCopySelectorForward<Target, Source>::copy(target, source);
   974         PathCopySelectorForward<From, To>::copy(from, to);
   975       }      
   975       }      
   976     };
   976     };
   977 
   977 
   978     template <typename Target, typename Source>
   978     template <typename From, typename To>
   979     struct PathCopySelector<Target, Source, true> {
   979     struct PathCopySelector<From, To, true> {
   980       static void copy(Target& target, const Source& source) {
   980       static void copy(const From& from, To& to) {
   981         PathCopySelectorBackward<Target, Source>::copy(target, source);
   981         PathCopySelectorBackward<From, To>::copy(from, to);
   982       }      
   982       }      
   983     };
   983     };
   984 
   984 
   985   }
   985   }
   986 
   986 
   987 
   987 
   988   /// \brief Make a copy of a path.
   988   /// \brief Make a copy of a path.
   989   ///
   989   ///
   990   ///  This function makes a copy of a path.
   990   /// This function makes a copy of a path.
   991   template <typename Target, typename Source>
   991   template <typename From, typename To>
   992   void copyPath(Target& target, const Source& source) {
   992   void pathCopy(const From& from, To& to) {
   993     checkConcept<concepts::PathDumper<typename Source::Digraph>, Source>();
   993     checkConcept<concepts::PathDumper<typename From::Digraph>, From>();
   994     _path_bits::PathCopySelector<Target, Source>::copy(target, source);
   994     _path_bits::PathCopySelector<From, To>::copy(from, to);
       
   995   }
       
   996 
       
   997   /// \brief Deprecated version of \ref pathCopy().
       
   998   ///
       
   999   /// Deprecated version of \ref pathCopy() (only for reverse compatibility).
       
  1000   template <typename To, typename From>
       
  1001   void copyPath(To& to, const From& from) {
       
  1002     pathCopy(from, to);
   995   }
  1003   }
   996 
  1004 
   997   /// \brief Check the consistency of a path.
  1005   /// \brief Check the consistency of a path.
   998   ///
  1006   ///
   999   /// This function checks that the target of each arc is the same
  1007   /// This function checks that the target of each arc is the same