src/work/marci/for_each_macros.h
changeset 332 5dc61ba30730
child 333 e0a80761dfd9
equal deleted inserted replaced
-1:000000000000 0:6ab05139030a
       
     1 // -*- c++ -*-
       
     2 #ifndef FOR_EACH_MACROS_H
       
     3 #define FOR_EACH_MACROS_H
       
     4 
       
     5 namespace hugo {
       
     6 
       
     7 #define FOR_EACH(e, g) for((g).first((e)); (g).valid((e)); (g).next((e)))
       
     8 #define FOR_EACH_INC(e, g, v) for((g).first((e), (v)); (g).valid((e)); (g).next((e)))
       
     9 
       
    10 #define FOR_EACH_EDGE(e, g) for((g).first((e)); (g).valid((e)); (g).next((e)))
       
    11 #define FOR_EACH_NODE(e, g) for((g).first((e)); (g).valid((e)); (g).next((e)))
       
    12 #define FOR_EACH_INEDGE(e, g, v) for((g).first((e), (v)); (g).valid((e)); (g).next((e)))
       
    13 #define FOR_EACH_OUTEDGE(e, g, v) for((g).first((e), (v)); (g).valid((e)); (g).next((e)))
       
    14 
       
    15 //   template<typename It, typename Graph> 
       
    16 //   It loopFirst(const Graph& g) const {
       
    17 //     It e; g.first(e); return e; 
       
    18 //   }
       
    19 
       
    20 //   template<typename It, typename Graph> 
       
    21 //   It loopFirst(const Graph& g, const Node& v) const {
       
    22 //     It e; g.first(e, v); return e; 
       
    23 //   }
       
    24 
       
    25 //   template<typename Graph> 
       
    26 //   typename Graph::NodeIt loopFirstNode(const Graph& g) const {
       
    27 //     typename Graph::NodeIt e; g.first(e); return e; 
       
    28 //   }
       
    29 //   template<typename Graph> 
       
    30 //   typename Graph::EdgeIt loopFirstEdge(const Graph& g) const {
       
    31 //     typename Graph::EdgeIt e; g.first(e); return e; 
       
    32 //   }
       
    33 //   template<typename Graph> 
       
    34 //   typename Graph::OutEdgeIt 
       
    35 //   loopFirstOutEdge(const Graph& g, const Node& n) const {
       
    36 //     typename Graph::OutEdgeIt e; g.first(e, n); return e; 
       
    37 //   }
       
    38 //   template<typename Graph> 
       
    39 //   typename Graph::InEdgeIt 
       
    40 //   loopFirstIn Edge(const Graph& g, const Node& n) const {
       
    41 //     typename Graph::InEdgeIt e; g.first(e, n); return e; 
       
    42 //   }
       
    43 
       
    44 //FIXME ezt hogy a gorcsbe birja levezetni. Csak ugy leveszi a const-ot??
       
    45   template<typename It, typename Graph> 
       
    46   It loopFirst(const It& i, const Graph& g) {
       
    47     It e=i; g.first(e); return e; 
       
    48   }
       
    49 
       
    50   template<typename It, typename Graph, typename Node> 
       
    51   It loopFirst(const It& i, const Graph& g, const Node& v) {
       
    52     It e=i; g.first(e, v); return e; 
       
    53   }
       
    54 
       
    55 //   template<typename Graph> 
       
    56 //   typename Graph::NodeIt loopFirstNode(const Graph& g) const {
       
    57 //     typename Graph::NodeIt e; g.first(e); return e; 
       
    58 //   }
       
    59 //   template<typename Graph> 
       
    60 //   typename Graph::EdgeIt loopFirstEdge(const Graph& g) const {
       
    61 //     typename Graph::EdgeIt e; g.first(e); return e; 
       
    62 //   }
       
    63 //   template<typename Graph> 
       
    64 //   typename Graph::OutEdgeIt 
       
    65 //   loopFirstOutEdge(const Graph& g, const Node& n) const {
       
    66 //     typename Graph::OutEdgeIt e; g.first(e, n); return e; 
       
    67 //   }
       
    68 //   template<typename Graph> 
       
    69 //   typename Graph::InEdgeIt 
       
    70 //   loopFirstIn Edge(const Graph& g, const Node& n) const {
       
    71 //     typename Graph::InEdgeIt e; g.first(e, n); return e; 
       
    72 //   }
       
    73 
       
    74 #define FOR_EACH_LOC(Ittype, e, g) for(Ittype (e)=loopFirst(Ittype(), (g)); (g).valid((e)); (g).next((e)))
       
    75 #define FOR_EACH_INC_LOC(Ittype, e, g, v) for(Ittype (e)=loopFirst(Ittype(), (g), (v)); (g).valid((e)); (g).next((e)))
       
    76 
       
    77 // #define FOR_EACH_EDGE_LOC(e, g) for((g).first((e)); (g).valid((e)); (g).next((e)))
       
    78 // #define FOR_EACH_NODE_LOC(e, g) for((g).first((e)); (g).valid((e)); (g).next((e)))
       
    79 // #define FOR_EACH_INEDGE_LOC(e, g, v) for((g).first((e), (v)); (g).valid((e)); (g).next((e)))
       
    80 // #define FOR_EACH_OUTEDGE_LOC(e, g, v) for((g).first((e), (v)); (g).valid((e)); (g).next((e)))
       
    81 
       
    82 
       
    83 } //namespace hugo
       
    84 
       
    85 #endif //FOR_EACH_MACROS_H