COIN-OR::LEMON - Graph Library

Changeset 617:4137ef9aacc6 in lemon-1.2 for lemon/bits


Ignore:
Timestamp:
04/24/09 11:54:48 (15 years ago)
Author:
Peter Kovacs <kpeter@…>
Branch:
default
Phase:
public
Message:

Fix and uniform the usage of Graph and Parent typedefs (#268)

  • Rename Graph typedefs to GraphType? in the implementation of graph maps and MapExtender? to prevent conflicts (especially using VS). They are not public.
  • Make Parent typedefs private in all classes.
  • Replace Digraph with Graph in some places (fix faulty renamings of the script).
  • Use Graph and Digraph typedefs (more) consequently.
Location:
lemon/bits
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • lemon/bits/array_map.h

    r492 r617  
    4848  public:
    4949    // The graph type.
    50     typedef _Graph Graph;
     50    typedef _Graph GraphType;
    5151    // The item type.
    5252    typedef _Item Item;
     
    6464    typedef _Value& Reference;
    6565
     66    // The map type.
     67    typedef ArrayMap Map;
     68
    6669    // The notifier type.
    6770    typedef typename ItemSetTraits<_Graph, _Item>::ItemNotifier Notifier;
    6871
     72  private:
     73 
    6974    // The MapBase of the Map which imlements the core regisitry function.
    7075    typedef typename Notifier::ObserverBase Parent;
    7176
    72   private:
    7377    typedef std::allocator<Value> Allocator;
    7478
     
    7882    //
    7983    // Graph initialized map constructor.
    80     explicit ArrayMap(const Graph& graph) {
     84    explicit ArrayMap(const GraphType& graph) {
    8185      Parent::attach(graph.notifier(Item()));
    8286      allocate_memory();
     
    9296    //
    9397    // It constructs a map and initialize all of the the map.
    94     ArrayMap(const Graph& graph, const Value& value) {
     98    ArrayMap(const GraphType& graph, const Value& value) {
    9599      Parent::attach(graph.notifier(Item()));
    96100      allocate_memory();
  • lemon/bits/base_extender.h

    r440 r617  
    3939  template <typename Base>
    4040  class UndirDigraphExtender : public Base {
     41    typedef Base Parent;
    4142
    4243  public:
    4344
    44     typedef Base Parent;
    4545    typedef typename Parent::Arc Edge;
    4646    typedef typename Parent::Node Node;
     
    281281  template <typename Base>
    282282  class BidirBpGraphExtender : public Base {
     283    typedef Base Parent;
     284
    283285  public:
    284     typedef Base Parent;
    285286    typedef BidirBpGraphExtender Digraph;
    286287
  • lemon/bits/default_map.h

    r535 r617  
    154154  class DefaultMap
    155155    : public DefaultMapSelector<_Graph, _Item, _Value>::Map {
     156    typedef typename DefaultMapSelector<_Graph, _Item, _Value>::Map Parent;
     157
    156158  public:
    157     typedef typename DefaultMapSelector<_Graph, _Item, _Value>::Map Parent;
    158159    typedef DefaultMap<_Graph, _Item, _Value> Map;
    159 
    160     typedef typename Parent::Graph Graph;
     160   
     161    typedef typename Parent::GraphType GraphType;
    161162    typedef typename Parent::Value Value;
    162163
    163     explicit DefaultMap(const Graph& graph) : Parent(graph) {}
    164     DefaultMap(const Graph& graph, const Value& value)
     164    explicit DefaultMap(const GraphType& graph) : Parent(graph) {}
     165    DefaultMap(const GraphType& graph, const Value& value)
    165166      : Parent(graph, value) {}
    166167
  • lemon/bits/edge_set_extender.h

    r559 r617  
    3535  template <typename Base>
    3636  class ArcSetExtender : public Base {
     37    typedef Base Parent;
     38
    3739  public:
    3840
    39     typedef Base Parent;
    4041    typedef ArcSetExtender Digraph;
    4142
     
    219220    class ArcMap
    220221      : public MapExtender<DefaultMap<Digraph, Arc, _Value> > {
    221     public:
    222       typedef ArcSetExtender Digraph;
    223222      typedef MapExtender<DefaultMap<Digraph, Arc, _Value> > Parent;
    224223
     224    public:
    225225      explicit ArcMap(const Digraph& _g)
    226226        : Parent(_g) {}
     
    275275  template <typename Base>
    276276  class EdgeSetExtender : public Base {
     277    typedef Base Parent;
    277278
    278279  public:
    279280
    280     typedef Base Parent;
    281     typedef EdgeSetExtender Digraph;
     281    typedef EdgeSetExtender Graph;
    282282
    283283    typedef typename Parent::Node Node;
    284284    typedef typename Parent::Arc Arc;
    285285    typedef typename Parent::Edge Edge;
    286 
    287286
    288287    int maxId(Node) const {
     
    351350
    352351    class NodeIt : public Node {
    353       const Digraph* digraph;
     352      const Graph* graph;
    354353    public:
    355354
     
    358357      NodeIt(Invalid i) : Node(i) { }
    359358
    360       explicit NodeIt(const Digraph& _graph) : digraph(&_graph) {
     359      explicit NodeIt(const Graph& _graph) : graph(&_graph) {
    361360        _graph.first(static_cast<Node&>(*this));
    362361      }
    363362
    364       NodeIt(const Digraph& _graph, const Node& node)
    365         : Node(node), digraph(&_graph) {}
     363      NodeIt(const Graph& _graph, const Node& node)
     364        : Node(node), graph(&_graph) {}
    366365
    367366      NodeIt& operator++() {
    368         digraph->next(*this);
     367        graph->next(*this);
    369368        return *this;
    370369      }
     
    374373
    375374    class ArcIt : public Arc {
    376       const Digraph* digraph;
     375      const Graph* graph;
    377376    public:
    378377
     
    381380      ArcIt(Invalid i) : Arc(i) { }
    382381
    383       explicit ArcIt(const Digraph& _graph) : digraph(&_graph) {
     382      explicit ArcIt(const Graph& _graph) : graph(&_graph) {
    384383        _graph.first(static_cast<Arc&>(*this));
    385384      }
    386385
    387       ArcIt(const Digraph& _graph, const Arc& e) :
    388         Arc(e), digraph(&_graph) { }
     386      ArcIt(const Graph& _graph, const Arc& e) :
     387        Arc(e), graph(&_graph) { }
    389388
    390389      ArcIt& operator++() {
    391         digraph->next(*this);
     390        graph->next(*this);
    392391        return *this;
    393392      }
     
    397396
    398397    class OutArcIt : public Arc {
    399       const Digraph* digraph;
     398      const Graph* graph;
    400399    public:
    401400
     
    404403      OutArcIt(Invalid i) : Arc(i) { }
    405404
    406       OutArcIt(const Digraph& _graph, const Node& node)
    407         : digraph(&_graph) {
     405      OutArcIt(const Graph& _graph, const Node& node)
     406        : graph(&_graph) {
    408407        _graph.firstOut(*this, node);
    409408      }
    410409
    411       OutArcIt(const Digraph& _graph, const Arc& arc)
    412         : Arc(arc), digraph(&_graph) {}
     410      OutArcIt(const Graph& _graph, const Arc& arc)
     411        : Arc(arc), graph(&_graph) {}
    413412
    414413      OutArcIt& operator++() {
    415         digraph->nextOut(*this);
     414        graph->nextOut(*this);
    416415        return *this;
    417416      }
     
    421420
    422421    class InArcIt : public Arc {
    423       const Digraph* digraph;
     422      const Graph* graph;
    424423    public:
    425424
     
    428427      InArcIt(Invalid i) : Arc(i) { }
    429428
    430       InArcIt(const Digraph& _graph, const Node& node)
    431         : digraph(&_graph) {
     429      InArcIt(const Graph& _graph, const Node& node)
     430        : graph(&_graph) {
    432431        _graph.firstIn(*this, node);
    433432      }
    434433
    435       InArcIt(const Digraph& _graph, const Arc& arc) :
    436         Arc(arc), digraph(&_graph) {}
     434      InArcIt(const Graph& _graph, const Arc& arc) :
     435        Arc(arc), graph(&_graph) {}
    437436
    438437      InArcIt& operator++() {
    439         digraph->nextIn(*this);
     438        graph->nextIn(*this);
    440439        return *this;
    441440      }
     
    445444
    446445    class EdgeIt : public Parent::Edge {
    447       const Digraph* digraph;
     446      const Graph* graph;
    448447    public:
    449448
     
    452451      EdgeIt(Invalid i) : Edge(i) { }
    453452
    454       explicit EdgeIt(const Digraph& _graph) : digraph(&_graph) {
     453      explicit EdgeIt(const Graph& _graph) : graph(&_graph) {
    455454        _graph.first(static_cast<Edge&>(*this));
    456455      }
    457456
    458       EdgeIt(const Digraph& _graph, const Edge& e) :
    459         Edge(e), digraph(&_graph) { }
     457      EdgeIt(const Graph& _graph, const Edge& e) :
     458        Edge(e), graph(&_graph) { }
    460459
    461460      EdgeIt& operator++() {
    462         digraph->next(*this);
     461        graph->next(*this);
    463462        return *this;
    464463      }
     
    468467    class IncEdgeIt : public Parent::Edge {
    469468      friend class EdgeSetExtender;
    470       const Digraph* digraph;
     469      const Graph* graph;
    471470      bool direction;
    472471    public:
     
    476475      IncEdgeIt(Invalid i) : Edge(i), direction(false) { }
    477476
    478       IncEdgeIt(const Digraph& _graph, const Node &n) : digraph(&_graph) {
     477      IncEdgeIt(const Graph& _graph, const Node &n) : graph(&_graph) {
    479478        _graph.firstInc(*this, direction, n);
    480479      }
    481480
    482       IncEdgeIt(const Digraph& _graph, const Edge &ue, const Node &n)
    483         : digraph(&_graph), Edge(ue) {
     481      IncEdgeIt(const Graph& _graph, const Edge &ue, const Node &n)
     482        : graph(&_graph), Edge(ue) {
    484483        direction = (_graph.source(ue) == n);
    485484      }
    486485
    487486      IncEdgeIt& operator++() {
    488         digraph->nextInc(*this, direction);
     487        graph->nextInc(*this, direction);
    489488        return *this;
    490489      }
     
    535534    template <typename _Value>
    536535    class ArcMap
    537       : public MapExtender<DefaultMap<Digraph, Arc, _Value> > {
    538     public:
    539       typedef EdgeSetExtender Digraph;
    540       typedef MapExtender<DefaultMap<Digraph, Arc, _Value> > Parent;
    541 
    542       ArcMap(const Digraph& _g)
     536      : public MapExtender<DefaultMap<Graph, Arc, _Value> > {
     537      typedef MapExtender<DefaultMap<Graph, Arc, _Value> > Parent;
     538
     539    public:
     540      ArcMap(const Graph& _g)
    543541        : Parent(_g) {}
    544       ArcMap(const Digraph& _g, const _Value& _v)
     542      ArcMap(const Graph& _g, const _Value& _v)
    545543        : Parent(_g, _v) {}
    546544
     
    560558    template <typename _Value>
    561559    class EdgeMap
    562       : public MapExtender<DefaultMap<Digraph, Edge, _Value> > {
    563     public:
    564       typedef EdgeSetExtender Digraph;
    565       typedef MapExtender<DefaultMap<Digraph, Edge, _Value> > Parent;
    566 
    567       EdgeMap(const Digraph& _g)
     560      : public MapExtender<DefaultMap<Graph, Edge, _Value> > {
     561      typedef MapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
     562
     563    public:
     564      EdgeMap(const Graph& _g)
    568565        : Parent(_g) {}
    569566
    570       EdgeMap(const Digraph& _g, const _Value& _v)
     567      EdgeMap(const Graph& _g, const _Value& _v)
    571568        : Parent(_g, _v) {}
    572569
  • lemon/bits/graph_adaptor_extender.h

    r580 r617  
    2727  template <typename _Digraph>
    2828  class DigraphAdaptorExtender : public _Digraph {
     29    typedef _Digraph Parent;
     30
    2931  public:
    3032
    31     typedef _Digraph Parent;
    3233    typedef _Digraph Digraph;
    3334    typedef DigraphAdaptorExtender Adaptor;
     
    174175  template <typename _Graph>
    175176  class GraphAdaptorExtender : public _Graph {
     177    typedef _Graph Parent;
     178
    176179  public:
    177180
    178     typedef _Graph Parent;
    179181    typedef _Graph Graph;
    180182    typedef GraphAdaptorExtender Adaptor;
  • lemon/bits/graph_extender.h

    r440 r617  
    3838  template <typename Base>
    3939  class DigraphExtender : public Base {
     40    typedef Base Parent;
     41
    4042  public:
    4143
    42     typedef Base Parent;
    4344    typedef DigraphExtender Digraph;
    4445
     
    219220    class NodeMap
    220221      : public MapExtender<DefaultMap<Digraph, Node, _Value> > {
    221     public:
    222       typedef DigraphExtender Digraph;
    223222      typedef MapExtender<DefaultMap<Digraph, Node, _Value> > Parent;
    224223
     224    public:
    225225      explicit NodeMap(const Digraph& digraph)
    226226        : Parent(digraph) {}
     
    244244    class ArcMap
    245245      : public MapExtender<DefaultMap<Digraph, Arc, _Value> > {
    246     public:
    247       typedef DigraphExtender Digraph;
    248246      typedef MapExtender<DefaultMap<Digraph, Arc, _Value> > Parent;
    249247
     248    public:
    250249      explicit ArcMap(const Digraph& digraph)
    251250        : Parent(digraph) {}
     
    331330  template <typename Base>
    332331  class GraphExtender : public Base {
     332    typedef Base Parent;
     333
    333334  public:
    334335
    335     typedef Base Parent;
    336336    typedef GraphExtender Graph;
    337337
     
    602602    class NodeMap
    603603      : public MapExtender<DefaultMap<Graph, Node, _Value> > {
    604     public:
    605       typedef GraphExtender Graph;
    606604      typedef MapExtender<DefaultMap<Graph, Node, _Value> > Parent;
    607605
     606    public:
    608607      NodeMap(const Graph& graph)
    609608        : Parent(graph) {}
     
    627626    class ArcMap
    628627      : public MapExtender<DefaultMap<Graph, Arc, _Value> > {
    629     public:
    630       typedef GraphExtender Graph;
    631628      typedef MapExtender<DefaultMap<Graph, Arc, _Value> > Parent;
    632629
     630    public:
    633631      ArcMap(const Graph& graph)
    634632        : Parent(graph) {}
     
    652650    class EdgeMap
    653651      : public MapExtender<DefaultMap<Graph, Edge, _Value> > {
    654     public:
    655       typedef GraphExtender Graph;
    656652      typedef MapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
    657653
     654    public:
    658655      EdgeMap(const Graph& graph)
    659656        : Parent(graph) {}
  • lemon/bits/map_extender.h

    r580 r617  
    3737  template <typename _Map>
    3838  class MapExtender : public _Map {
    39   public:
    40 
    4139    typedef _Map Parent;
     40    typedef typename Parent::GraphType GraphType;
     41
     42  public:
     43
    4244    typedef MapExtender Map;
    43 
    44 
    45     typedef typename Parent::Graph Graph;
    4645    typedef typename Parent::Key Item;
    4746
     
    5958  public:
    6059
    61     MapExtender(const Graph& graph)
     60    MapExtender(const GraphType& graph)
    6261      : Parent(graph) {}
    6362
    64     MapExtender(const Graph& graph, const Value& value)
     63    MapExtender(const GraphType& graph, const Value& value)
    6564      : Parent(graph, value) {}
    6665
     
    7877  public:
    7978    class MapIt : public Item {
    80     public:
    81 
    82       typedef Item Parent;
     79      typedef Item Parent;
     80
     81    public:
     82
    8383      typedef typename Map::Value Value;
    8484
     
    117117
    118118    class ConstMapIt : public Item {
    119     public:
    120 
    121       typedef Item Parent;
     119      typedef Item Parent;
     120
     121    public:
    122122
    123123      typedef typename Map::Value Value;
     
    148148
    149149    class ItemIt : public Item {
    150     public:
    151 
    152       typedef Item Parent;
     150      typedef Item Parent;
     151
     152    public:
    153153
    154154      ItemIt() {}
     
    179179  template <typename _Graph, typename _Map>
    180180  class SubMapExtender : public _Map {
    181   public:
    182 
    183181    typedef _Map Parent;
     182    typedef _Graph GraphType;
     183
     184  public:
     185
    184186    typedef SubMapExtender Map;
    185 
    186     typedef _Graph Graph;
    187 
    188187    typedef typename Parent::Key Item;
    189188
     
    201200  public:
    202201
    203     SubMapExtender(const Graph& _graph)
     202    SubMapExtender(const GraphType& _graph)
    204203      : Parent(_graph), graph(_graph) {}
    205204
    206     SubMapExtender(const Graph& _graph, const Value& _value)
     205    SubMapExtender(const GraphType& _graph, const Value& _value)
    207206      : Parent(_graph, _value), graph(_graph) {}
    208207
     
    224223  public:
    225224    class MapIt : public Item {
    226     public:
    227 
    228       typedef Item Parent;
     225      typedef Item Parent;
     226
     227    public:
    229228      typedef typename Map::Value Value;
    230229
     
    263262
    264263    class ConstMapIt : public Item {
    265     public:
    266 
    267       typedef Item Parent;
     264      typedef Item Parent;
     265
     266    public:
    268267
    269268      typedef typename Map::Value Value;
     
    294293
    295294    class ItemIt : public Item {
    296     public:
    297 
    298       typedef Item Parent;
     295      typedef Item Parent;
     296
     297    public:
    299298
    300299      ItemIt() {}
     
    321320  private:
    322321
    323     const Graph& graph;
     322    const GraphType& graph;
    324323
    325324  };
  • lemon/bits/vector_map.h

    r492 r617  
    5757
    5858    // The graph type of the map.
    59     typedef _Graph Graph;
     59    typedef _Graph GraphType;
    6060    // The item type of the map.
    6161    typedef _Item Item;
     
    7373    // The map type.
    7474    typedef VectorMap Map;
    75     // The base class of the map.
    76     typedef typename Notifier::ObserverBase Parent;
    7775
    7876    // The reference type of the map;
     
    8179    typedef typename Container::const_reference ConstReference;
    8280
     81  private:
     82
     83    // The base class of the map.
     84    typedef typename Notifier::ObserverBase Parent;
     85
     86  public:
    8387
    8488    // \brief Constructor to attach the new map into the notifier.
     
    8690    // It constructs a map and attachs it into the notifier.
    8791    // It adds all the items of the graph to the map.
    88     VectorMap(const Graph& graph) {
     92    VectorMap(const GraphType& graph) {
    8993      Parent::attach(graph.notifier(Item()));
    9094      container.resize(Parent::notifier()->maxId() + 1);
     
    9599    // It constructs a map uses a given value to initialize the map.
    96100    // It adds all the items of the graph to the map.
    97     VectorMap(const Graph& graph, const Value& value) {
     101    VectorMap(const GraphType& graph, const Value& value) {
    98102      Parent::attach(graph.notifier(Item()));
    99103      container.resize(Parent::notifier()->maxId() + 1, value);
Note: See TracChangeset for help on using the changeset viewer.