Changeset 686:fc8a3393e0d9 in lemon-0.x for src/work/klao
- Timestamp:
- 06/16/04 11:44:30 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@934
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/work/klao/path.h
r683 r686 1 1 // -*- c++ -*- // 2 2 3 ///\ingroup datas 3 /** 4 @defgroup paths Path Structures 5 @ingroup datas 6 \brief Path structures implemented in Hugo. 7 8 Hugolib provides flexible data structures 9 to work with paths. 10 11 All of them have the same interface, especially they can be built or extended 12 using a standard Builder subclass. This make is easy to have e.g. the Dijkstra 13 algorithm to store its result in any kind of path structure. 14 15 */ 16 17 ///\ingroup paths 4 18 ///\file 5 19 ///\brief Classes for representing paths in graphs. … … 18 32 namespace hugo { 19 33 20 /// \addtogroup datas34 /// \addtogroup paths 21 35 /// @{ 22 36 … … 36 50 class DirPath { 37 51 public: 38 typedef typename Graph::Edge GraphEdge; 52 /// Edge type of the underlying graph. 53 typedef typename Graph::Edge GraphEdge; 54 /// Node type of the underlying graph. 39 55 typedef typename Graph::Node GraphNode; 40 56 class NodeIt; … … 153 169 154 170 155 /*** Iterator classes ***/ 171 /* Iterator classes */ 172 173 /** 174 * \brief Iterator class to iterate on the edges of the paths 175 * 176 * \ingroup paths 177 * This class is used to iterate on the edges of the paths 178 * 179 * Of course it converts to Graph::Edge 180 * 181 * \todo Its interface differs from the standard edge iterator. 182 * Yes, it shouldn't. 183 */ 156 184 class EdgeIt { 157 185 friend class DirPath; … … 160 188 const DirPath *p; 161 189 public: 190 /// Default constructor 162 191 EdgeIt() {} 192 /// Invalid constructor 163 193 EdgeIt(Invalid) : idx(-1), p(0) {} 194 /// Constructor with starting point 164 195 EdgeIt(const DirPath &_p, int _idx = 0) : 165 196 idx(_idx), p(&_p) { validate(); } 166 197 198 ///Validity check 167 199 bool valid() const { return idx!=-1; } 168 200 201 ///Conversion to Graph::Edge 169 202 operator GraphEdge () const { 170 203 return valid() ? p->edges[idx] : INVALID; 171 204 } 205 206 /// Next edge 172 207 EdgeIt& operator++() { ++idx; validate(); return *this; } 173 208 209 /// Comparison operator 174 210 bool operator==(const EdgeIt& e) const { return idx==e.idx; } 211 /// Comparison operator 175 212 bool operator!=(const EdgeIt& e) const { return idx!=e.idx; } 213 /// Comparison operator 176 214 bool operator<(const EdgeIt& e) const { return idx<e.idx; } 177 215 … … 182 220 }; 183 221 222 /** 223 * \brief Iterator class to iterate on the nodes of the paths 224 * 225 * \ingroup paths 226 * This class is used to iterate on the nodes of the paths 227 * 228 * Of course it converts to Graph::Node 229 * 230 * \todo Its interface differs from the standard node iterator. 231 * Yes, it shouldn't. 232 */ 184 233 class NodeIt { 185 234 friend class DirPath; … … 188 237 const DirPath *p; 189 238 public: 239 /// Default constructor 190 240 NodeIt() {} 241 /// Invalid constructor 191 242 NodeIt(Invalid) : idx(-1), p(0) {} 243 /// Constructor with starting point 192 244 NodeIt(const DirPath &_p, int _idx = 0) : 193 245 idx(_idx), p(&_p) { validate(); } 194 246 247 ///Validity check 195 248 bool valid() const { return idx!=-1; } 196 249 250 ///Conversion to Graph::Node 197 251 operator const GraphNode& () const { 198 252 if(idx >= p->length()) … … 203 257 return INVALID; 204 258 } 259 /// Next node 205 260 NodeIt& operator++() { ++idx; validate(); return *this; } 206 261 262 /// Comparison operator 207 263 bool operator==(const NodeIt& e) const { return idx==e.idx; } 264 /// Comparison operator 208 265 bool operator!=(const NodeIt& e) const { return idx!=e.idx; } 266 /// Comparison operator 209 267 bool operator<(const NodeIt& e) const { return idx<e.idx; } 210 268 … … 218 276 * \brief Class to build paths 219 277 * 220 * \ingroup datas278 * \ingroup paths 221 279 * This class is used to fill a path with edges. 222 280 * … … 286 344 // FIXME: Hmm, pontosan hogy is kene ezt csinalni? 287 345 // Hogy kenyelmes egy ilyet hasznalni? 346 347 ///Reserve storage in advance for the builder 348 349 ///If you know an reasonable upper bound of the number of the edges 350 ///to add, using this function you can speed up the building. 288 351 void reserve(size_t r) { 289 352 front.reserve(r); … … 350 413 class UndirPath { 351 414 public: 415 /// Edge type of the underlying graph. 352 416 typedef typename Graph::Edge GraphEdge; 353 typedef typename Graph::Node GraphNode; 417 /// Node type of the underlying graph. 418 typedef typename Graph::Node GraphNode; 354 419 class NodeIt; 355 420 class EdgeIt; … … 467 532 468 533 469 /*** Iterator classes ***/ 534 535 /** 536 * \brief Iterator class to iterate on the edges of the paths 537 * 538 * \ingroup paths 539 * This class is used to iterate on the edges of the paths 540 * 541 * Of course it converts to Graph::Edge 542 * 543 * \todo Its interface differs from the standard edge iterator. 544 * Yes, it shouldn't. 545 */ 470 546 class EdgeIt { 471 547 friend class UndirPath; … … 474 550 const UndirPath *p; 475 551 public: 552 /// Default constructor 476 553 EdgeIt() {} 554 /// Invalid constructor 477 555 EdgeIt(Invalid) : idx(-1), p(0) {} 556 /// Constructor with starting point 478 557 EdgeIt(const UndirPath &_p, int _idx = 0) : 479 558 idx(_idx), p(&_p) { validate(); } 480 559 560 ///Validity check 481 561 bool valid() const { return idx!=-1; } 482 562 563 ///Conversion to Graph::Edge 483 564 operator GraphEdge () const { 484 565 return valid() ? p->edges[idx] : INVALID; 485 566 } 486 EdgeIt& operator++() { ++idx; validate(); return *this; } 487 567 /// Next edge 568 EdgeIt& operator++() { ++idx; validate(); return *this; } 569 570 /// Comparison operator 488 571 bool operator==(const EdgeIt& e) const { return idx==e.idx; } 572 /// Comparison operator 489 573 bool operator!=(const EdgeIt& e) const { return idx!=e.idx; } 574 /// Comparison operator 490 575 bool operator<(const EdgeIt& e) const { return idx<e.idx; } 491 576 … … 496 581 }; 497 582 583 /** 584 * \brief Iterator class to iterate on the nodes of the paths 585 * 586 * \ingroup paths 587 * This class is used to iterate on the nodes of the paths 588 * 589 * Of course it converts to Graph::Node 590 * 591 * \todo Its interface differs from the standard node iterator. 592 * Yes, it shouldn't. 593 */ 498 594 class NodeIt { 499 595 friend class UndirPath; … … 502 598 const UndirPath *p; 503 599 public: 600 /// Default constructor 504 601 NodeIt() {} 602 /// Invalid constructor 505 603 NodeIt(Invalid) : idx(-1), p(0) {} 604 /// Constructor with starting point 506 605 NodeIt(const UndirPath &_p, int _idx = 0) : 507 606 idx(_idx), p(&_p) { validate(); } 508 607 608 ///Validity check 509 609 bool valid() const { return idx!=-1; } 510 610 611 ///Conversion to Graph::Node 511 612 operator const GraphNode& () const { 512 613 if(idx >= p->length()) … … 517 618 return INVALID; 518 619 } 620 /// Next node 519 621 NodeIt& operator++() { ++idx; validate(); return *this; } 520 622 623 /// Comparison operator 521 624 bool operator==(const NodeIt& e) const { return idx==e.idx; } 625 /// Comparison operator 522 626 bool operator!=(const NodeIt& e) const { return idx!=e.idx; } 523 bool operator<(const NodeIt& e) const { return idx<e.idx; } 627 /// Comparison operator 628 bool operator<(const NodeIt& e) const { return idx<e.idx; } 524 629 525 630 private: … … 532 637 * \brief Class to build paths 533 638 * 534 * \ingroup datas639 * \ingroup paths 535 640 * This class is used to fill a path with edges. 536 641 * … … 600 705 // FIXME: Hmm, pontosan hogy is kene ezt csinalni? 601 706 // Hogy kenyelmes egy ilyet hasznalni? 602 void reserve(size_t r) { 707 708 ///Reserve storage in advance for the builder 709 710 ///If you know an reasonable upper bound of the number of the edges 711 ///to add, using this function you can speed up the building. 712 void reserve(size_t r) { 603 713 front.reserve(r); 604 714 back.reserve(r);
Note: See TracChangeset
for help on using the changeset viewer.