Changeset 1130:0759d974de81 in lemonmain for lemon/path.h
 Timestamp:
 01/05/14 22:24:56 (6 years ago)
 Branch:
 default
 Phase:
 public
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

lemon/path.h
r1092 r1130 31 31 #include <lemon/core.h> 32 32 #include <lemon/concepts/path.h> 33 #include <lemon/bits/stl_iterators.h> 33 34 34 35 namespace lemon { … … 140 141 int idx; 141 142 }; 143 144 /// \brief Gets the collection of the arcs of the path. 145 /// 146 /// This function can be used for iterating on the 147 /// arcs of the path. It returns a wrapped 148 /// ArcIt, which looks like an STL container 149 /// (by having begin() and end()) which you can use in rangebased 150 /// for loops, STL algorithms, etc. 151 /// For example you can write: 152 ///\code 153 /// for(auto a: p.arcs()) 154 /// doSomething(a); 155 ///\endcode 156 LemonRangeWrapper1<ArcIt, Path> arcs() const { 157 return LemonRangeWrapper1<ArcIt, Path>(*this); 158 } 159 142 160 143 161 /// \brief Length of the path. … … 346 364 }; 347 365 366 /// \brief Gets the collection of the arcs of the path. 367 /// 368 /// This function can be used for iterating on the 369 /// arcs of the path. It returns a wrapped 370 /// ArcIt, which looks like an STL container 371 /// (by having begin() and end()) which you can use in rangebased 372 /// for loops, STL algorithms, etc. 373 /// For example you can write: 374 ///\code 375 /// for(auto a: p.arcs()) 376 /// doSomething(a); 377 ///\endcode 378 LemonRangeWrapper1<ArcIt, SimplePath> arcs() const { 379 return LemonRangeWrapper1<ArcIt, SimplePath>(*this); 380 } 381 382 348 383 /// \brief Length of the path. 349 384 int length() const { return data.size(); } … … 543 578 Node *node; 544 579 }; 580 581 /// \brief Gets the collection of the arcs of the path. 582 /// 583 /// This function can be used for iterating on the 584 /// arcs of the path. It returns a wrapped 585 /// ArcIt, which looks like an STL container 586 /// (by having begin() and end()) which you can use in rangebased 587 /// for loops, STL algorithms, etc. 588 /// For example you can write: 589 ///\code 590 /// for(auto a: p.arcs()) 591 /// doSomething(a); 592 ///\endcode 593 LemonRangeWrapper1<ArcIt, ListPath> arcs() const { 594 return LemonRangeWrapper1<ArcIt, ListPath>(*this); 595 } 596 545 597 546 598 /// \brief The nth arc. … … 796 848 /// 797 849 /// Default constructor 798 StaticPath() : len(0), arcs(0) {}850 StaticPath() : len(0), _arcs(0) {} 799 851 800 852 /// \brief Copy constructor 801 853 /// 802 StaticPath(const StaticPath& cpath) : arcs(0) {854 StaticPath(const StaticPath& cpath) : _arcs(0) { 803 855 pathCopy(cpath, *this); 804 856 } … … 808 860 /// This path can be initialized from any other path type. 809 861 template <typename CPath> 810 StaticPath(const CPath& cpath) : arcs(0) {862 StaticPath(const CPath& cpath) : _arcs(0) { 811 863 pathCopy(cpath, *this); 812 864 } … … 816 868 /// Destructor of the path 817 869 ~StaticPath() { 818 if ( arcs) delete[]arcs;870 if (_arcs) delete[] _arcs; 819 871 } 820 872 … … 883 935 int idx; 884 936 }; 937 938 /// \brief Gets the collection of the arcs of the path. 939 /// 940 /// This function can be used for iterating on the 941 /// arcs of the path. It returns a wrapped 942 /// ArcIt, which looks like an STL container 943 /// (by having begin() and end()) which you can use in rangebased 944 /// for loops, STL algorithms, etc. 945 /// For example you can write: 946 ///\code 947 /// for(auto a: p.arcs()) 948 /// doSomething(a); 949 ///\endcode 950 LemonRangeWrapper1<ArcIt, StaticPath> arcs() const { 951 return LemonRangeWrapper1<ArcIt, StaticPath>(*this); 952 } 953 885 954 886 955 /// \brief The nth arc. … … 888 957 /// \pre \c n is in the <tt>[0..length()  1]</tt> range. 889 958 const Arc& nth(int n) const { 890 return arcs[n];959 return _arcs[n]; 891 960 } 892 961 … … 905 974 void clear() { 906 975 len = 0; 907 if ( arcs) delete[]arcs;908 arcs = 0;976 if (_arcs) delete[] _arcs; 977 _arcs = 0; 909 978 } 910 979 911 980 /// \brief The first arc of the path. 912 981 const Arc& front() const { 913 return arcs[0];982 return _arcs[0]; 914 983 } 915 984 916 985 /// \brief The last arc of the path. 917 986 const Arc& back() const { 918 return arcs[len  1];987 return _arcs[len  1]; 919 988 } 920 989 … … 925 994 void build(const CPath& path) { 926 995 len = path.length(); 927 arcs = new Arc[len];996 _arcs = new Arc[len]; 928 997 int index = 0; 929 998 for (typename CPath::ArcIt it(path); it != INVALID; ++it) { 930 arcs[index] = it;999 _arcs[index] = it; 931 1000 ++index; 932 1001 } … … 936 1005 void buildRev(const CPath& path) { 937 1006 len = path.length(); 938 arcs = new Arc[len];1007 _arcs = new Arc[len]; 939 1008 int index = len; 940 1009 for (typename CPath::RevArcIt it(path); it != INVALID; ++it) { 941 1010 index; 942 arcs[index] = it;1011 _arcs[index] = it; 943 1012 } 944 1013 } … … 946 1015 private: 947 1016 int len; 948 Arc* arcs;1017 Arc* _arcs; 949 1018 }; 950 1019 … … 1158 1227 }; 1159 1228 1229 /// \brief Gets the collection of the nodes of the path. 1230 /// 1231 /// This function can be used for iterating on the 1232 /// nodes of the path. It returns a wrapped 1233 /// PathNodeIt, which looks like an STL container 1234 /// (by having begin() and end()) which you can use in rangebased 1235 /// for loops, STL algorithms, etc. 1236 /// For example you can write: 1237 ///\code 1238 /// for(auto u: pathNodes(g,p)) 1239 /// doSomething(u); 1240 ///\endcode 1241 template<typename Path> 1242 LemonRangeWrapper2<PathNodeIt<Path>, typename Path::Digraph, Path> 1243 pathNodes(const typename Path::Digraph &g, const Path &p) { 1244 return 1245 LemonRangeWrapper2<PathNodeIt<Path>, typename Path::Digraph, Path>(g,p); 1246 } 1247 1160 1248 ///@} 1161 1249
Note: See TracChangeset
for help on using the changeset viewer.