Changeset 209:765619b7cbb2 in lemon-1.2 for lemon/path.h
- Timestamp:
- 07/13/08 20:51:02 (17 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/path.h
r157 r209 1 /* -*- C++-*-1 /* -*- mode: C++; indent-tabs-mode: nil; -*- 2 2 * 3 * This file is a part of LEMON, a generic C++ optimization library 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 5 * Copyright (C) 2003-2008 … … 94 94 ArcIt(Invalid) : path(0), idx(-1) {} 95 95 /// \brief Initializate the iterator to the first arc of path 96 ArcIt(const Path &_path) 96 ArcIt(const Path &_path) 97 97 : path(&_path), idx(_path.empty() ? -1 : 0) {} 98 98 99 99 private: 100 100 101 ArcIt(const Path &_path, int _idx) 101 ArcIt(const Path &_path, int _idx) 102 102 : path(&_path), idx(_idx) {} 103 103 … … 110 110 111 111 /// \brief Next arc 112 ArcIt& operator++() { 112 ArcIt& operator++() { 113 113 ++idx; 114 if (idx >= path->length()) idx = -1; 115 return *this; 114 if (idx >= path->length()) idx = -1; 115 return *this; 116 116 } 117 117 … … 285 285 ArcIt(Invalid) : path(0), idx(-1) {} 286 286 /// \brief Initializate the constructor to the first arc of path 287 ArcIt(const SimplePath &_path) 287 ArcIt(const SimplePath &_path) 288 288 : path(&_path), idx(_path.empty() ? -1 : 0) {} 289 289 … … 291 291 292 292 /// Constructor with starting point 293 ArcIt(const SimplePath &_path, int _idx) 293 ArcIt(const SimplePath &_path, int _idx) 294 294 : idx(_idx), path(&_path) {} 295 295 … … 302 302 303 303 /// Next arc 304 ArcIt& operator++() { 304 ArcIt& operator++() { 305 305 ++idx; 306 if (idx >= path->length()) idx = -1; 307 return *this; 306 if (idx >= path->length()) idx = -1; 307 return *this; 308 308 } 309 309 … … 414 414 protected: 415 415 416 // the std::list<> is incompatible 416 // the std::list<> is incompatible 417 417 // hard to create invalid iterator 418 418 struct Node { … … 426 426 427 427 public: 428 428 429 429 /// \brief Default constructor 430 430 /// … … 471 471 ArcIt(Invalid) : path(0), node(0) {} 472 472 /// \brief Initializate the constructor to the first arc of path 473 ArcIt(const ListPath &_path) 473 ArcIt(const ListPath &_path) 474 474 : path(&_path), node(_path.first) {} 475 475 476 476 protected: 477 477 478 ArcIt(const ListPath &_path, Node *_node) 478 ArcIt(const ListPath &_path, Node *_node) 479 479 : path(&_path), node(_node) {} 480 480 … … 488 488 489 489 /// Next arc 490 ArcIt& operator++() { 490 ArcIt& operator++() { 491 491 node = node->next; 492 return *this; 492 return *this; 493 493 } 494 494 … … 758 758 /// Default constructor 759 759 StaticPath() : len(0), arcs(0) {} 760 760 761 761 /// \brief Template copy constructor 762 762 /// … … 797 797 ArcIt(Invalid) : path(0), idx(-1) {} 798 798 /// Initializate the constructor to the first arc of path 799 ArcIt(const StaticPath &_path) 799 ArcIt(const StaticPath &_path) 800 800 : path(&_path), idx(_path.empty() ? -1 : 0) {} 801 801 … … 803 803 804 804 /// Constructor with starting point 805 ArcIt(const StaticPath &_path, int _idx) 805 ArcIt(const StaticPath &_path, int _idx) 806 806 : idx(_idx), path(&_path) {} 807 807 … … 814 814 815 815 /// Next arc 816 ArcIt& operator++() { 816 ArcIt& operator++() { 817 817 ++idx; 818 if (idx >= path->length()) idx = -1; 819 return *this; 818 if (idx >= path->length()) idx = -1; 819 return *this; 820 820 } 821 821 … … 910 910 template <typename Path> 911 911 struct RevPathTagIndicator< 912 Path, 912 Path, 913 913 typename enable_if<typename Path::RevPathTag, void>::type 914 914 > { … … 923 923 template <typename Path> 924 924 struct BuildTagIndicator< 925 Path, 925 Path, 926 926 typename enable_if<typename Path::BuildTag, void>::type 927 927 > { … … 930 930 931 931 template <typename Target, typename Source, 932 bool buildEnable = BuildTagIndicator<Target>::value, 933 932 bool buildEnable = BuildTagIndicator<Target>::value, 933 bool revEnable = RevPathTagIndicator<Source>::value> 934 934 struct PathCopySelector { 935 935 static void copy(Target& target, const Source& source) { … … 982 982 /// 983 983 /// This function checks that the target of each arc is the same 984 /// as the source of the next one. 985 /// 984 /// as the source of the next one. 985 /// 986 986 template <typename Digraph, typename Path> 987 987 bool checkPath(const Digraph& digraph, const Path& path) { … … 1035 1035 typedef typename Path::Digraph Digraph; 1036 1036 typedef typename Digraph::Node Node; 1037 1037 1038 1038 /// Default constructor 1039 1039 PathNodeIt() {} 1040 1040 /// Invalid constructor 1041 PathNodeIt(Invalid) 1041 PathNodeIt(Invalid) 1042 1042 : _digraph(0), _it(INVALID), _nd(INVALID) {} 1043 1043 /// Constructor 1044 PathNodeIt(const Digraph& digraph, const Path& path) 1044 PathNodeIt(const Digraph& digraph, const Path& path) 1045 1045 : _digraph(&digraph), _it(path) { 1046 1046 _nd = (_it != INVALID ? _digraph->source(_it) : INVALID); 1047 1047 } 1048 1048 /// Constructor 1049 PathNodeIt(const Digraph& digraph, const Path& path, const Node& src) 1049 PathNodeIt(const Digraph& digraph, const Path& path, const Node& src) 1050 1050 : _digraph(&digraph), _it(path), _nd(src) {} 1051 1051 … … 1059 1059 if (_it == INVALID) _nd = INVALID; 1060 1060 else { 1061 1062 1061 _nd = _digraph->target(_it); 1062 ++_it; 1063 1063 } 1064 1064 return *this; … … 1066 1066 1067 1067 /// Comparison operator 1068 bool operator==(const PathNodeIt& n) const { 1069 return _it == n._it && _nd == n._nd; 1068 bool operator==(const PathNodeIt& n) const { 1069 return _it == n._it && _nd == n._nd; 1070 1070 } 1071 1071 /// Comparison operator 1072 bool operator!=(const PathNodeIt& n) const { 1073 return _it != n._it || _nd != n._nd; 1072 bool operator!=(const PathNodeIt& n) const { 1073 return _it != n._it || _nd != n._nd; 1074 1074 } 1075 1075 /// Comparison operator 1076 bool operator<(const PathNodeIt& n) const { 1076 bool operator<(const PathNodeIt& n) const { 1077 1077 return (_it < n._it && _nd != INVALID); 1078 1078 } 1079 1079 1080 1080 }; 1081 1081 1082 1082 ///@} 1083 1083
Note: See TracChangeset
for help on using the changeset viewer.