Changeset 1421:4fd76139b69e in lemon
 Timestamp:
 02/17/18 23:44:32 (6 years ago)
 Branch:
 default
 Phase:
 public
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

lemon/path.h
r1420 r1421 183 183 } 184 184 185 /// \brief The nth arc. 186 /// 187 /// Gives back the nth arc. This operator is just an alias for \ref nth(), 188 /// it runs in O(1) time. 189 /// \pre \c n is in the range <tt>[0..length()  1]</tt>. 190 const Arc& operator[](int n) const { 191 return nth(n); 192 } 193 185 194 /// \brief The first arc of the path 186 195 const Arc& front() const { … … 403 412 } 404 413 414 /// \brief The nth arc. 415 /// 416 /// Gives back the nth arc. This operator is just an alias for \ref nth(), 417 /// it runs in O(1) time. 418 /// \pre \c n is in the range <tt>[0..length()  1]</tt>. 419 const Arc& operator[](int n) const { 420 return data[n]; 421 } 422 405 423 /// \brief The first arc of the path. 406 424 const Arc& front() const { … … 617 635 } 618 636 return ArcIt(*this, node); 637 } 638 639 /// \brief The nth arc. 640 /// 641 /// Looks for the nth arc in O(n) time. This operator is just an alias 642 /// for \ref nth(). 643 /// \pre \c n is in the range <tt>[0..length()  1]</tt>. 644 const Arc& operator[](int n) const { 645 return nth(n); 619 646 } 620 647 … … 967 994 } 968 995 996 /// \brief The nth arc. 997 /// 998 /// Gives back the nth arc. This operator is just an alias for \ref nth(), 999 /// it runs in O(1) time. 1000 /// \pre \c n is in the range <tt>[0..length()  1]</tt>. 1001 const Arc& operator[](int n) const { 1002 return _arcs[n]; 1003 } 1004 969 1005 /// \brief The length of the path. 970 1006 int length() const { return len; } 
test/path_test.cc
r1270 r1421 108 108 checkBackAndFrontInsertablePath<ListPath<GR> >(); 109 109 checkBackInsertablePath<SimplePath<GR> >(); 110 111 checkSubscriptOperator<Path<GR> >(); 112 checkSubscriptOperator<SimplePath<GR> >(); 113 checkSubscriptOperator<StaticPath<GR> >(); 114 checkSubscriptOperator<ListPath<GR> >(); 110 115 111 116 checkListPathSplitAndSplice(); … … 274 279 } 275 280 281 template <typename P> 282 void checkSubscriptOperator() { 283 SimplePath<GR> p0; 284 p0.addBack(a1); 285 p0.addBack(a3); 286 p0.addBack(a2); 287 P p = p0; 288 check(!p.empty(), "Wrong empty()"); 289 check(p.length() == 3, "Wrong length"); 290 check(p.front() == a1, "Wrong front()"); 291 check(p.back() == a2, "Wrong back()"); 292 check(p.nth(0) == a1, "Wrong nth()"); 293 check(p.nth(1) == a3, "Wrong nth()"); 294 check(p.nth(2) == a2, "Wrong nth()"); 295 check(p[0] == a1, "Wrong operator[]"); 296 check(p[1] == a3, "Wrong operator[]"); 297 check(p[2] == a2, "Wrong operator[]"); 298 } 299 276 300 void checkListPathSplitAndSplice() { 277 301
Note: See TracChangeset
for help on using the changeset viewer.