# HG changeset patch
# User Peter Kovacs <kpeter@inf.elte.hu>
# Date 1251236018 -7200
# Node ID afad5d01ef8e6510a734f77735be66a372fbf568
# Parent 4cad1981d18da48cd043d39cb4c827ada4ddf146
Simplify StaticDigraph::OutArcIt implementation (#68)
diff --git a/lemon/static_graph.h b/lemon/static_graph.h
a
|
b
|
|
238 | 238 | |
239 | 239 | protected: |
240 | 240 | |
241 | | void fastFirstOut(Arc& e, const Node& n) const { |
242 | | e.id = node_first_out[n.id]; |
| 241 | int outArcsBegin(const Node& n) const { |
| 242 | return node_first_out[n.id]; |
243 | 243 | } |
244 | 244 | |
245 | | static void fastNextOut(Arc& e) { |
246 | | ++e.id; |
247 | | } |
248 | | void fastLastOut(Arc& e, const Node& n) const { |
249 | | e.id = node_first_out[n.id + 1]; |
| 245 | int outArcsEnd(const Node& n) const { |
| 246 | return node_first_out[n.id + 1]; |
250 | 247 | } |
251 | 248 | |
252 | 249 | protected: |
… |
… |
|
404 | 401 | void clear() { |
405 | 402 | Parent::clear(); |
406 | 403 | } |
407 | | |
408 | | protected: |
409 | | |
410 | | using Parent::fastFirstOut; |
411 | | using Parent::fastNextOut; |
412 | | using Parent::fastLastOut; |
413 | 404 | |
414 | 405 | public: |
415 | 406 | |
… |
… |
|
421 | 412 | OutArcIt(Invalid i) : Arc(i) { } |
422 | 413 | |
423 | 414 | OutArcIt(const StaticDigraph& digraph, const Node& node) { |
424 | | digraph.fastFirstOut(*this, node); |
425 | | digraph.fastLastOut(last, node); |
426 | | if (last == *this) *this = INVALID; |
| 415 | id = digraph.outArcsBegin(node); |
| 416 | end = digraph.outArcsEnd(node); |
| 417 | if (id == end) id = -1; |
427 | 418 | } |
428 | 419 | |
429 | 420 | OutArcIt(const StaticDigraph& digraph, const Arc& arc) : Arc(arc) { |
430 | 421 | if (arc != INVALID) { |
431 | | digraph.fastLastOut(last, digraph.source(arc)); |
| 422 | end = digraph.outArcsEnd(digraph.source(arc)); |
432 | 423 | } |
433 | 424 | } |
434 | 425 | |
435 | 426 | OutArcIt& operator++() { |
436 | | StaticDigraph::fastNextOut(*this); |
437 | | if (last == *this) *this = INVALID; |
| 427 | id = id+1 != end ? id+1 : -1; |
438 | 428 | return *this; |
439 | 429 | } |
440 | 430 | |
441 | 431 | private: |
442 | | Arc last; |
| 432 | int end; |
443 | 433 | }; |
444 | 434 | |
445 | 435 | Node baseNode(const OutArcIt &arc) const { |