COIN-OR::LEMON - Graph Library

Ticket #68: 68-8-afad5d01ef8e.patch

File 68-8-afad5d01ef8e.patch, 1.9 KB (added by Peter Kovacs, 15 years ago)
  • lemon/static_graph.h

    # 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  
    238238
    239239  protected:
    240240
    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];
    243243    }
    244244
    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];
    250247    }
    251248
    252249  protected:
     
    404401    void clear() {
    405402      Parent::clear();
    406403    }
    407 
    408   protected:
    409 
    410     using Parent::fastFirstOut;
    411     using Parent::fastNextOut;
    412     using Parent::fastLastOut;
    413404   
    414405  public:
    415406
     
    421412      OutArcIt(Invalid i) : Arc(i) { }
    422413
    423414      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;
    427418      }
    428419
    429420      OutArcIt(const StaticDigraph& digraph, const Arc& arc) : Arc(arc) {
    430421        if (arc != INVALID) {
    431           digraph.fastLastOut(last, digraph.source(arc));
     422          end = digraph.outArcsEnd(digraph.source(arc));
    432423        }
    433424      }
    434425
    435426      OutArcIt& operator++() {
    436         StaticDigraph::fastNextOut(*this);
    437         if (last == *this) *this = INVALID;
     427        id = id+1 != end ? id+1 : -1;
    438428        return *this;
    439429      }
    440430
    441431    private:
    442       Arc last;
     432      int end;
    443433    };
    444434
    445435    Node baseNode(const OutArcIt &arc) const {