Changeset 369:dc9c19f4ca9a in lemon0.x
 Timestamp:
 04/22/04 01:47:01 (17 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@497
 Location:
 src/work/klao
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

src/work/klao/path.h
r227 r369 11 11 12 12 #include <deque> 13 #include <vector> 13 14 #include <algorithm> 14 15 … … 16 17 17 18 namespace hugo { 19 20 template<typename Graph> 21 class DirPath { 22 public: 23 typedef typename Graph::Edge GraphEdge; 24 typedef typename Graph::Node GraphNode; 25 class NodeIt; 26 class EdgeIt; 27 28 protected: 29 const Graph *gr; 30 typedef std::vector<GraphEdge> Container; 31 Container edges; 32 33 public: 34 35 DirPath(const Graph &_G) : gr(&_G) {} 36 37 /// Subpath defined by two nodes. 38 /// It is an error if the two edges are not in order! 39 DirPath(const DirPath &P, const NodeIt &a, const NodeIt &b); 40 /// Subpath defined by two edges. Contains edges in [a,b) 41 /// It is an error if the two edges are not in order! 42 DirPath(const DirPath &P, const EdgeIt &a, const EdgeIt &b); 43 44 size_t length() const { return edges.size(); } 45 bool empty() const { return edges.empty(); } 46 GraphNode from() const { 47 return empty() ? INVALID : gr>tail(edges[0]); 48 } 49 GraphNode to() const { 50 return empty() ? INVALID : gr>head(edges[length()1]); 51 } 52 53 template<typename It> 54 It& first(It &i) const { return i=It(*this); } 55 56 template<typename It> 57 It& nth(It &i, int n) const { return i=It(*this, n); } 58 59 template<typename It> 60 bool valid(const It &i) const { return i.valid(); } 61 62 template<typename It> 63 It& next(It &e) const { return ++e; } 64 65 /// \todo ! 66 NodeIt head(const EdgeIt& e) const; 67 NodeIt tail(const EdgeIt& e) const; 68 69 70 /*** Iterator classes ***/ 71 class EdgeIt { 72 friend class DirPath; 73 74 int idx; 75 const DirPath *p; 76 public: 77 EdgeIt() {} 78 EdgeIt(Invalid) : idx(1), p(0) {} 79 EdgeIt(const DirPath &_p, int _idx = 0) : 80 idx(_idx), p(&_p) { validate(); } 81 82 bool valid() const { return idx!=1; } 83 84 operator GraphEdge () const { 85 return valid() ? p>edges[idx] : INVALID; 86 } 87 EdgeIt& operator++() { ++idx; validate(); return *this; } 88 89 bool operator==(const EdgeIt& e) const { return idx==e.idx; } 90 bool operator!=(const EdgeIt& e) const { return idx!=e.idx; } 91 bool operator<(const EdgeIt& e) const { return idx<e.idx; } 92 93 private: 94 // FIXME: comparison between signed and unsigned... 95 // Jo ez igy? Vagy esetleg legyen a length() int? 96 void validate() { if( size_t(idx) >= p>length() ) idx=1; } 97 }; 98 99 class NodeIt { 100 friend class DirPath; 101 102 int idx; 103 const DirPath *p; 104 public: 105 NodeIt() {} 106 NodeIt(Invalid) : idx(1), p(0) {} 107 NodeIt(const DirPath &_p, int _idx = 0) : 108 idx(_idx), p(&_p) { validate(); } 109 110 bool valid() const { return idx!=1; } 111 112 operator const GraphEdge& () const { 113 if(idx >= p>length()) 114 return p>to(); 115 else if(idx >= 0) 116 return p>gr>tail(p>edges[idx]); 117 else 118 return INVALID; 119 } 120 NodeIt& operator++() { ++idx; validate(); return *this; } 121 122 bool operator==(const NodeIt& e) const { return idx==e.idx; } 123 bool operator!=(const NodeIt& e) const { return idx!=e.idx; } 124 bool operator<(const NodeIt& e) const { return idx<e.idx; } 125 126 private: 127 void validate() { if( size_t(idx) > p>length() ) idx=1; } 128 }; 129 130 friend class Builder; 131 class Builder { 132 DirPath &P; 133 Container d; 134 135 public: 136 Builder(DirPath &_P) : P(_P) {} 137 138 bool pushFront(const GraphEdge& e) { 139 if( empty()  P.gr>head(e)==from() ) { 140 d.push_back(e); 141 return true; 142 } 143 return false; 144 } 145 bool pushBack(const GraphEdge& e) { 146 if( empty()  P.gr>tail(e)==to() ) { 147 P.edges.push_back(e); 148 return true; 149 } 150 return false; 151 } 152 153 void commit() { 154 if( !d.empty() ) { 155 P.edges.insert(P.edges.begin(), d.rbegin(), d.rend()); 156 d.clear(); 157 } 158 } 159 160 ~Builder() { commit(); } 161 162 // FIXME: Hmm, pontosan hogy is kene ezt csinalni? 163 // Hogy kenyelmes egy ilyet hasznalni? 164 void reserve(size_t r) { 165 d.reserve(r); 166 P.edges.reserve(P.length()+r); 167 } 168 169 private: 170 bool empty() { return d.empty() && P.empty(); } 171 172 GraphNode from() const { 173 if( ! d.empty() ) 174 return P.gr>tail(d[d.size()1]); 175 else if( ! P.empty() ) 176 return P.gr>tail(P.edges[0]); 177 else 178 return INVALID; 179 } 180 GraphNode to() const { 181 if( ! P.empty() ) 182 return P.gr>head(P.edges[P.length()1]); 183 else if( ! d.empty() ) 184 return P.gr>head(d[0]); 185 else 186 return INVALID; 187 } 188 189 }; 190 191 }; 192 193 194 195 196 197 198 199 200 201 202 203 /**********************************************************************/ 204 18 205 19 206 /* Ennek az allocatorosdinak sokkal jobban utana kene nezni a hasznalata … … 21 208 22 209 template<typename Graph> 23 class Path {210 class DynamicPath { 24 211 25 212 public: … … 39 226 public: 40 227 41 Path(Graph &_G) : G(_G), _first(INVALID), _last(INVALID) {}228 DynamicPath(Graph &_G) : G(_G), _first(INVALID), _last(INVALID) {} 42 229 43 230 /// Subpath defined by two nodes. 44 231 /// Nodes may be in reversed order, then 45 232 /// we contstruct the reversed path. 46 Path(constPath &P, const NodeIt &a, const NodeIt &b);233 DynamicPath(const DynamicPath &P, const NodeIt &a, const NodeIt &b); 47 234 /// Subpath defined by two edges. Contains edges in [a,b) 48 235 /// It is an error if the two edges are not in order! 49 Path(constPath &P, const EdgeIt &a, const EdgeIt &b);236 DynamicPath(const DynamicPath &P, const EdgeIt &a, const EdgeIt &b); 50 237 51 238 size_t length() const { return edges.size(); } … … 113 300 /*** Iterator classes ***/ 114 301 class EdgeIt { 115 friend class Path;302 friend class DynamicPath; 116 303 117 304 typename Container::const_iterator it; … … 129 316 130 317 class NodeIt { 131 friend class Path; 132 friend class EdgeIt; 318 friend class DynamicPath; 133 319 134 320 size_t idx; … … 151 337 152 338 template<typename Gr> 153 typename Path<Gr>::EdgeIt&154 Path<Gr>::next(Path::EdgeIt &e) const {339 typename DynamicPath<Gr>::EdgeIt& 340 DynamicPath<Gr>::next(DynamicPath::EdgeIt &e) const { 155 341 if( e.it == edges.end() ) 156 342 return e; … … 170 356 171 357 template<typename Gr> 172 typename Path<Gr>::NodeIt&Path<Gr>::next(NodeIt &n) const {358 typename DynamicPath<Gr>::NodeIt& DynamicPath<Gr>::next(NodeIt &n) const { 173 359 if( n.idx >= length() ) { 174 360 // FIXME: invalid … … 192 378 193 379 template<typename Gr> 194 bool Path<Gr>::edgeIncident(const GraphEdge &e, const GraphNode &a,380 bool DynamicPath<Gr>::edgeIncident(const GraphEdge &e, const GraphNode &a, 195 381 GraphNode &b) { 196 382 if( G.tail(e) == a ) { … … 206 392 207 393 template<typename Gr> 208 bool Path<Gr>::connectTwoEdges(const GraphEdge &e,394 bool DynamicPath<Gr>::connectTwoEdges(const GraphEdge &e, 209 395 const GraphEdge &f) { 210 396 if( edgeIncident(f, G.tail(e), _last) ) { … … 220 406 221 407 template<typename Gr> 222 bool Path<Gr>::pushFront(const GraphEdge &e) {408 bool DynamicPath<Gr>::pushFront(const GraphEdge &e) { 223 409 if( G.valid(_first) ) { 224 410 if( edgeIncident(e, _first, _first) ) { … … 238 424 239 425 template<typename Gr> 240 bool Path<Gr>::pushBack(const GraphEdge &e) {426 bool DynamicPath<Gr>::pushBack(const GraphEdge &e) { 241 427 if( G.valid(_last) ) { 242 428 if( edgeIncident(e, _last, _last) ) { … … 257 443 258 444 template<typename Gr> 259 bool Path<Gr>::setFrom(const GraphNode &n) {445 bool DynamicPath<Gr>::setFrom(const GraphNode &n) { 260 446 if( G.valid(_first) ) { 261 447 return _first == n; … … 277 463 278 464 template<typename Gr> 279 bool Path<Gr>::setTo(const GraphNode &n) {465 bool DynamicPath<Gr>::setTo(const GraphNode &n) { 280 466 if( G.valid(_last) ) { 281 467 return _last == n; … … 298 484 299 485 template<typename Gr> 300 typename Path<Gr>::NodeIt301 Path<Gr>::tail(const EdgeIt& e) const {486 typename DynamicPath<Gr>::NodeIt 487 DynamicPath<Gr>::tail(const EdgeIt& e) const { 302 488 NodeIt n; 303 489 … … 315 501 316 502 template<typename Gr> 317 typename Path<Gr>::NodeIt318 Path<Gr>::head(const EdgeIt& e) const {503 typename DynamicPath<Gr>::NodeIt 504 DynamicPath<Gr>::head(const EdgeIt& e) const { 319 505 if( e.it == edges.end()1 ) { 320 506 return _last; … … 327 513 328 514 template<typename Gr> 329 typename Path<Gr>::GraphEdge330 Path<Gr>::graphEdge(const EdgeIt& e) const {515 typename DynamicPath<Gr>::GraphEdge 516 DynamicPath<Gr>::graphEdge(const EdgeIt& e) const { 331 517 if( e.it != edges.end() ) { 332 518 return *e.it; … … 338 524 339 525 template<typename Gr> 340 typename Path<Gr>::GraphNode341 Path<Gr>::graphNode(const NodeIt& n) const {526 typename DynamicPath<Gr>::GraphNode 527 DynamicPath<Gr>::graphNode(const NodeIt& n) const { 342 528 if( n.idx < length() ) { 343 529 return n.tail ? G.tail(edges[n.idx]) : G.head(edges[n.idx]); … … 352 538 353 539 template<typename Gr> 354 typename Path<Gr>::EdgeIt& Path<Gr>::nth(EdgeIt &e, size_t k) const { 540 typename DynamicPath<Gr>::EdgeIt& 541 DynamicPath<Gr>::nth(EdgeIt &e, size_t k) const { 355 542 if( k<0  k>=length() ) { 356 543 // FIXME: invalid EdgeIt … … 372 559 373 560 template<typename Gr> 374 typename Path<Gr>::NodeIt& Path<Gr>::nth(NodeIt &n, size_t k) const { 561 typename DynamicPath<Gr>::NodeIt& 562 DynamicPath<Gr>::nth(NodeIt &n, size_t k) const { 375 563 if( k<0  k>length() ) { 376 564 // FIXME: invalid NodeIt … … 392 580 393 581 template<typename Gr> 394 Path<Gr>::Path(const Path &P, const EdgeIt &a, const EdgeIt &b) : 582 DynamicPath<Gr>::DynamicPath(const DynamicPath &P, const EdgeIt &a, 583 const EdgeIt &b) : 395 584 G(P.G), edges(a.it, b.it) // WARNING: if b.it < a.it this will blow up! 396 585 { … … 407 596 408 597 template<typename Gr> 409 Path<Gr>::Path(const Path &P, const NodeIt &a, const NodeIt &b) :410 598 DynamicPath<Gr>::DynamicPath(const DynamicPath &P, const NodeIt &a, 599 const NodeIt &b) : G(P.G) 411 600 { 412 601 if( !P.valid(a)  !P.valid(b) ) 
src/work/klao/path_test.cc
r227 r369 44 44 bool rc; 45 45 46 cout << "Ures path letrehozasa" << endl; 47 typedef Path<ListGraph> LPath; 48 LPath P(G); 49 50 cout << "P.length() == " << P.length() << endl; 51 check(P.length() == 0); 52 53 cout << "P.from() valid? " << G.valid(P.from()) << endl; 54 check(! G.valid(P.from())); 55 56 cout << "Hozzaadunk ket elet..." << endl; 57 check(P.pushBack(e1)); 58 check(P.pushBack(e3)); 59 cout << "P.length() == " << P.length() << endl; 60 check(P.length() == 2); 61 62 cout << "P.from() valid? " << G.valid(P.from()) << endl; 63 check(G.valid(P.from())); 46 { 47 cout << "DynamicPath tesztelese...\n"; 48 49 cout << "Ures path letrehozasa" << endl; 50 typedef DynamicPath<ListGraph> LPath; 51 LPath P(G); 52 53 cout << "P.length() == " << P.length() << endl; 54 check(P.length() == 0); 55 56 cout << "P.from() valid? " << G.valid(P.from()) << endl; 57 check(! G.valid(P.from())); 58 59 cout << "Hozzaadunk ket elet..." << endl; 60 check(P.pushBack(e1)); 61 check(P.pushBack(e3)); 62 cout << "P.length() == " << P.length() << endl; 63 check(P.length() == 2); 64 65 cout << "P.from() valid? " << G.valid(P.from()) << endl; 66 check(G.valid(P.from())); 64 67 65 cout << "P.from()==s ? " << (P.from()==s) << endl; 66 check(P.from() == s); 67 68 cout << "Hozzaadunk egy nem illeszkedo elt." << endl; 69 rc = P.pushBack(e8); 70 cout << "Sukerult: " << rc << endl; 71 check(!rc); 72 73 cout << "Meg 3 el hozzaadasa, nem mind elore iranyu..." << endl; 74 check(P.pushBack(e6)); 75 check(P.pushBack(e8)); 76 check(P.pushBack(e10)); 77 78 cout << "P.length() == " << P.length() << endl; 79 check(P.length() == 5); 80 81 cout << "P.from()==s ? " << (P.from()==s) << endl; 82 check(P.from() == s); 83 cout << "P.to()==t ? " << (P.to()==t) << endl; 84 check(P.to() == t); 85 86 cout << "Vegpont bellitasa: " << endl; 87 rc = P.setTo(v2); 88 cout << "Hibasra: " << rc << endl; 89 check(!rc); 90 rc = P.setTo(t); 91 cout << "Helyesre: " << rc << endl; 92 check(rc); 93 94 cout << "Elek iranyitasanak ellenorzese." << endl; 95 cout << "El: " << e1 << ", G.tail(el): " << G.head(e1) << endl; 96 check(G.tail(e1)==s); 97 98 cout << "Vegigiteralunk az eleken." << endl; 99 typedef LPath::NodeIt NodeIt; 100 typedef LPath::EdgeIt EdgeIt; 101 EdgeIt e = P.first<EdgeIt>(); 102 int i=1; 103 for(; P.valid(e); P.next(e), ++i) { 104 cout << i << ". el: " << P.graphEdge(e) 105 << ", elore el? " << P.isForward(e) << endl; 106 if(i>=3 && i<5) 107 check(!P.isForward(e)); 108 else 109 check(P.isForward(e)); 68 cout << "P.from()==s ? " << (P.from()==s) << endl; 69 check(P.from() == s); 70 71 cout << "Hozzaadunk egy nem illeszkedo elt." << endl; 72 rc = P.pushBack(e8); 73 cout << "Sukerult: " << rc << endl; 74 check(!rc); 75 76 cout << "Meg 3 el hozzaadasa, nem mind elore iranyu..." << endl; 77 check(P.pushBack(e6)); 78 check(P.pushBack(e8)); 79 check(P.pushBack(e10)); 80 81 cout << "P.length() == " << P.length() << endl; 82 check(P.length() == 5); 83 84 cout << "P.from()==s ? " << (P.from()==s) << endl; 85 check(P.from() == s); 86 cout << "P.to()==t ? " << (P.to()==t) << endl; 87 check(P.to() == t); 88 89 cout << "Vegpont bellitasa: " << endl; 90 rc = P.setTo(v2); 91 cout << "Hibasra: " << rc << endl; 92 check(!rc); 93 rc = P.setTo(t); 94 cout << "Helyesre: " << rc << endl; 95 check(rc); 96 97 cout << "Elek iranyitasanak ellenorzese." << endl; 98 cout << "El: " << e1 << ", G.tail(el): " << G.head(e1) << endl; 99 check(G.tail(e1)==s); 100 101 cout << "Vegigiteralunk az eleken." << endl; 102 typedef LPath::NodeIt NodeIt; 103 typedef LPath::EdgeIt EdgeIt; 104 EdgeIt e = P.first<EdgeIt>(); 105 int i=1; 106 for(; P.valid(e); P.next(e), ++i) { 107 cout << i << ". el: " << P.graphEdge(e) 108 << ", elore el? " << P.isForward(e) << endl; 109 if(i>=3 && i<5) 110 check(!P.isForward(e)); 111 else 112 check(P.isForward(e)); 113 } 114 115 { 116 cout << "Reszut letrehozasa: [2. el, 4. el)..." << endl; 117 LPath P2(P, P.nth<EdgeIt>(1), P.nth<EdgeIt>(3)); 118 119 cout << "P2.length() == " << P2.length() << endl; 120 check(P2.length() == 2); 121 122 cout << "P2.from()==v1 ? " << (P2.from()==v1) << endl; 123 check(P2.from() == v1); 124 cout << "P2.to()==v3 ? " << (P2.to()==v3) << endl; 125 check(P2.to() == v3); 126 } 127 { 128 cout << "Reszut letrehozasa: [1. el, 6. el)..." << endl; 129 LPath P2(P, P.nth<EdgeIt>(0), P.nth<EdgeIt>(5)); 130 131 cout << "P2.length() == " << P2.length() << endl; 132 check(P2.length() == 5); 133 134 cout << "P2.from()==s ? " << (P2.from()==s) << endl; 135 check(P2.from() == s); 136 cout << "P2.to()==t ? " << (P2.to()==t) << endl; 137 check(P2.to() == t); 138 } 139 140 { 141 cout << "Ket pont altal megadott reszut letrehozasa: [2. pont, 4. pont]..." 142 << endl; 143 LPath P2(P, P.nth<NodeIt>(1), P.nth<NodeIt>(3)); 144 145 cout << "P2.length() == " << P2.length() << endl; 146 check(P2.length() == 2); 147 148 cout << "P2.from()==v1 ? " << (P2.from()==v1) << endl; 149 check(P2.from() == v1); 150 cout << "P2.to()==v3 ? " << (P2.to()==v3) << endl; 151 check(P2.to() == v3); 152 } 153 { 154 cout << "Egy pontu reszut letrehozasa: [4. pont, 4. pont]..." 155 << endl; 156 LPath P2(P, P.nth<NodeIt>(3), P.nth<NodeIt>(3)); 157 158 cout << "P2.length() == " << P2.length() << endl; 159 check(P2.length() == 0); 160 161 cout << "P2.from()==v3 ? " << (P2.from()==v3) << endl; 162 check(P2.from() == v3); 163 cout << "P2.to()==v3 ? " << (P2.to()==v3) << endl; 164 check(P2.to() == v3); 165 } 166 { 167 cout << "Forditott ut letrehozasa: [6. pont, 1. pont]..." 168 << endl; 169 LPath P2(P, P.nth<NodeIt>(5), P.nth<NodeIt>(0)); 170 171 cout << "P2.length() == " << P2.length() << endl; 172 check(P2.length() == 5); 173 174 cout << "P2.from()==t ? " << (P2.from()==t) << endl; 175 check(P2.from() == t); 176 cout << "P2.to()==s ? " << (P2.to()==s) << endl; 177 check(P2.to() == s); 178 } 179 110 180 } 111 181 112 182 { 113 cout << "Reszut letrehozasa: [2. el, 4. el)..." << endl; 114 LPath P2(P, P.nth<EdgeIt>(1), P.nth<EdgeIt>(3)); 115 116 cout << "P2.length() == " << P2.length() << endl; 117 check(P2.length() == 2); 118 119 cout << "P2.from()==v1 ? " << (P2.from()==v1) << endl; 120 check(P2.from() == v1); 121 cout << "P2.to()==v3 ? " << (P2.to()==v3) << endl; 122 check(P2.to() == v3); 183 cout << "\n\n\nDirPath tesztelese...\n"; 184 185 186 cout << "Ures path letrehozasa" << endl; 187 typedef DirPath<ListGraph> DPath; 188 DPath P(G); 189 190 cout << "P.length() == " << P.length() << endl; 191 check(P.length() == 0); 192 193 cout << "P.from() valid? " << G.valid(P.from()) << endl; 194 check(! G.valid(P.from())); 195 196 { 197 cout << "Builder objektum letrehozasa" << endl; 198 DPath::Builder B(P); 199 200 cout << "Hozzaadunk az elejehez ket elet..." << endl; 201 check(B.pushFront(e6)); 202 check(B.pushFront(e5)); 203 cout << "P.length() == " << P.length() << endl; 204 check(P.length() == 0); 205 206 cout << "Commitolunk..." << endl; 207 B.commit(); 208 209 cout << "P.length() == " << P.length() << endl; 210 check(P.length() == 2); 211 cout << "P.from() valid? " << G.valid(P.from()) << endl; 212 check(G.valid(P.from())); 213 cout << "P.from()==v1 ? " << (P.from()==v1) << endl; 214 check(P.from() == v1); 215 216 cout << "Hozzaadunk az elejehez egy nem illeszkedo elet..." << endl; 217 check(!B.pushFront(e3)); 218 219 cout << "Hozzaadunk a vegehez ket elet..." << endl; 220 check(B.pushBack(e7)); 221 check(B.pushBack(e8)); 222 cout << "P.length() == " << P.length() << endl; 223 check(P.length() == 4); 224 225 cout << "Hozzaadunk az elejehez meg egy elet..." << endl; 226 check(B.pushFront(e4)); 227 cout << "P.length() == " << P.length() << endl; 228 check(P.length() == 4); 229 230 cout << "Es megvarjuk, amig megszunik a Builder...\n"; 231 } 232 cout << "P.length() == " << P.length() << endl; 233 check(P.length() == 5); 234 cout << "P.from()==v2 ? " << (P.from()==v2) << endl; 235 check(P.from() == v2); 236 237 cout << "Vegigiteralunk az eleken." << endl; 238 typedef DPath::NodeIt NodeIt; 239 typedef DPath::EdgeIt EdgeIt; 240 EdgeIt e; 241 int i=1; 242 for(P.first(e); P.valid(e); P.next(e), ++i) { 243 cout << i << ". el: " << e << endl; 244 } 123 245 } 124 {125 cout << "Reszut letrehozasa: [1. el, 6. el)..." << endl;126 LPath P2(P, P.nth<EdgeIt>(0), P.nth<EdgeIt>(5));127 128 cout << "P2.length() == " << P2.length() << endl;129 check(P2.length() == 5);130 131 cout << "P2.from()==s ? " << (P2.from()==s) << endl;132 check(P2.from() == s);133 cout << "P2.to()==t ? " << (P2.to()==t) << endl;134 check(P2.to() == t);135 }136 137 {138 cout << "Ket pont altal megadott reszut letrehozasa: [2. pont, 4. pont]..."139 << endl;140 LPath P2(P, P.nth<NodeIt>(1), P.nth<NodeIt>(3));141 142 cout << "P2.length() == " << P2.length() << endl;143 check(P2.length() == 2);144 145 cout << "P2.from()==v1 ? " << (P2.from()==v1) << endl;146 check(P2.from() == v1);147 cout << "P2.to()==v3 ? " << (P2.to()==v3) << endl;148 check(P2.to() == v3);149 }150 {151 cout << "Egy pontu reszut letrehozasa: [4. pont, 4. pont]..."152 << endl;153 LPath P2(P, P.nth<NodeIt>(3), P.nth<NodeIt>(3));154 155 cout << "P2.length() == " << P2.length() << endl;156 check(P2.length() == 0);157 158 cout << "P2.from()==v3 ? " << (P2.from()==v3) << endl;159 check(P2.from() == v3);160 cout << "P2.to()==v3 ? " << (P2.to()==v3) << endl;161 check(P2.to() == v3);162 }163 {164 cout << "Forditott ut letrehozasa: [6. pont, 1. pont]..."165 << endl;166 LPath P2(P, P.nth<NodeIt>(5), P.nth<NodeIt>(0));167 168 cout << "P2.length() == " << P2.length() << endl;169 check(P2.length() == 5);170 171 cout << "P2.from()==t ? " << (P2.from()==t) << endl;172 check(P2.from() == t);173 cout << "P2.to()==s ? " << (P2.to()==s) << endl;174 check(P2.to() == s);175 }176 177 246 178 247 cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
Note: See TracChangeset
for help on using the changeset viewer.