lemon/path.h
changeset 145 95d905b6e33d
parent 100 4f754b4cf82b
child 157 2ccc1afc2c52
equal deleted inserted replaced
3:b34f6d369727 4:0484867c9f85
   901   ///////////////////////////////////////////////////////////////////////
   901   ///////////////////////////////////////////////////////////////////////
   902 
   902 
   903   namespace _path_bits {
   903   namespace _path_bits {
   904 
   904 
   905     template <typename Path, typename Enable = void>
   905     template <typename Path, typename Enable = void>
   906     struct RevTagIndicator {
   906     struct RevPathTagIndicator {
   907       static const bool value = false;
   907       static const bool value = false;
   908     };
   908     };
   909 
   909 
   910     template <typename Digraph>
   910     template <typename Path>
   911     struct RevTagIndicator<
   911     struct RevPathTagIndicator<
   912       Digraph, 
   912       Path, 
   913       typename enable_if<typename Digraph::RevTag, void>::type
   913       typename enable_if<typename Path::RevPathTag, void>::type
       
   914       > {
       
   915       static const bool value = true;
       
   916     };
       
   917 
       
   918     template <typename Path, typename Enable = void>
       
   919     struct BuildTagIndicator {
       
   920       static const bool value = false;
       
   921     };
       
   922 
       
   923     template <typename Path>
       
   924     struct BuildTagIndicator<
       
   925       Path, 
       
   926       typename enable_if<typename Path::BuildTag, void>::type
   914     > {
   927     > {
   915       static const bool value = true;
   928       static const bool value = true;
   916     };
   929     };
   917 
   930 
   918     template <typename Target, typename Source,
   931     template <typename Target, typename Source,
   919               typename BuildEnable = void, typename RevEnable = void>
   932 	      bool buildEnable = BuildTagIndicator<Target>::value, 
       
   933 	      bool revEnable = RevPathTagIndicator<Source>::value>
   920     struct PathCopySelector {
   934     struct PathCopySelector {
   921       static void copy(Target& target, const Source& source) {
   935       static void copy(Target& target, const Source& source) {
   922         target.clear();
   936         target.clear();
   923         for (typename Source::ArcIt it(source); it != INVALID; ++it) {
   937         for (typename Source::ArcIt it(source); it != INVALID; ++it) {
   924           target.addBack(it);
   938           target.addBack(it);
   925         }
   939         }
   926       }
   940       }
   927     };
   941     };
   928 
   942 
   929     template <typename Target, typename Source, typename BuildEnable>
   943     template <typename Target, typename Source>
   930     struct PathCopySelector<
   944     struct PathCopySelector<Target, Source, false, true> {
   931       Target, Source, BuildEnable, 
       
   932       typename enable_if<typename Source::RevPathTag, void>::type> {
       
   933       static void copy(Target& target, const Source& source) {
   945       static void copy(Target& target, const Source& source) {
   934         target.clear();
   946         target.clear();
   935         for (typename Source::RevArcIt it(source); it != INVALID; ++it) {
   947         for (typename Source::RevArcIt it(source); it != INVALID; ++it) {
   936           target.addFront(it);
   948           target.addFront(it);
   937         }
   949         }
   938       }
   950       }
   939     };
   951     };
   940 
   952 
   941     template <typename Target, typename Source, typename RevEnable>
   953     template <typename Target, typename Source>
   942     struct PathCopySelector<
   954     struct PathCopySelector<Target, Source, true, false> {
   943       Target, Source, 
       
   944       typename enable_if<typename Target::BuildTag, void>::type, RevEnable> {
       
   945       static void copy(Target& target, const Source& source) {
   955       static void copy(Target& target, const Source& source) {
   946         target.clear();
   956         target.clear();
   947         target.build(source);
   957         target.build(source);
   948       }
   958       }
   949     };
   959     };
   950 
   960 
   951     template <typename Target, typename Source>
   961     template <typename Target, typename Source>
   952     struct PathCopySelector<
   962     struct PathCopySelector<Target, Source, true, true> {
   953       Target, Source, 
       
   954       typename enable_if<typename Target::BuildTag, void>::type,
       
   955       typename enable_if<typename Source::RevPathTag, void>::type> {
       
   956       static void copy(Target& target, const Source& source) {
   963       static void copy(Target& target, const Source& source) {
   957         target.clear();
   964         target.clear();
   958         target.buildRev(source);
   965         target.buildRev(source);
   959       }
   966       }
   960     };
   967     };