COIN-OR::LEMON - Graph Library

Changeset 1910:f95eea8c34b0 in lemon-0.x for lemon/bits/static_map.h


Ignore:
Timestamp:
01/26/06 17:24:40 (18 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2485
Message:

Bipartite => Bp
Upper => A
Lower => B

+ some bug fix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/bits/static_map.h

    r1909 r1910  
    33 *
    44 * Copyright (C) 2006 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    5  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     5 * (Egervary Research Groin on Combinatorial Optimization, EGRES).
    66 *
    77 * Permission to use, modify and distribute this software is granted
     
    2828#include <lemon/concept/maps.h>
    2929
    30 /// \ingroup graphmaps
     30/// \ingroin graphmaps
    3131///
    3232///\file
     
    3535namespace lemon {
    3636
    37   /// \ingroup graphmaps
     37  /// \ingroin graphmaps
    3838  ///
    3939  /// \brief Graph map with static sized storage.
    4040  ///
    4141  /// The StaticMap template class is graph map structure what
    42   /// does not update automatically the map when a key is added to or
     42  /// does not indate automatically the map when a key is added to or
    4343  /// erased from the map rather it throws an exception. This map factory
    4444  /// uses the allocators to implement the container functionality.
     
    5555  public:
    5656
    57     /// \brief Exception class for unsupported exceptions.
    58     class UnsupportedOperation : public lemon::LogicError {
     57    /// \brief Exception class for unsinported exceptions.
     58    class UnsinportedOperation : public lemon::LogicError {
    5959    public:
    6060      virtual const char* exceptionName() const {
    61         return "lemon::StaticMap::UnsupportedOperation";
     61        return "lemon::StaticMap::UnsinportedOperation";
    6262      }
    6363    };
     
    186186     
    187187    void add(const Key&) {
    188       throw UnsupportedOperation();
     188      throw UnsinportedOperation();
    189189    }
    190190
     
    194194    /// and it overrides the erase() member function of the observer base.     
    195195    void erase(const Key&) {
    196       throw UnsupportedOperation();
     196      throw UnsinportedOperation();
    197197    }
    198198
     
    347347
    348348  template <typename _Base>
    349   class StaticMappableUBipartiteGraphExtender : public _Base {
     349  class StaticMappableBpUGraphExtender : public _Base {
    350350  public:
    351351
    352352    typedef _Base Parent;
    353     typedef StaticMappableUBipartiteGraphExtender Graph;
     353    typedef StaticMappableBpUGraphExtender Graph;
    354354
    355355    typedef typename Parent::Node Node;
    356     typedef typename Parent::UpperNode UpperNode;
    357     typedef typename Parent::LowerNode LowerNode;
     356    typedef typename Parent::ANode ANode;
     357    typedef typename Parent::BNode BNode;
    358358    typedef typename Parent::Edge Edge;
    359359    typedef typename Parent::UEdge UEdge;
    360360   
    361361    template <typename _Value>
    362     class UpperNodeMap
    363       : public IterableMapExtender<StaticMap<Graph, UpperNode, _Value> > {
    364     public:
    365       typedef StaticMappableUBipartiteGraphExtender Graph;
    366       typedef IterableMapExtender<StaticMap<Graph, UpperNode, _Value> >
     362    class ANodeMap
     363      : public IterableMapExtender<StaticMap<Graph, ANode, _Value> > {
     364    public:
     365      typedef StaticMappableBpUGraphExtender Graph;
     366      typedef IterableMapExtender<StaticMap<Graph, ANode, _Value> >
    367367      Parent;
    368368   
    369       UpperNodeMap(const Graph& _g)
    370         : Parent(_g) {}
    371       UpperNodeMap(const Graph& _g, const _Value& _v)
    372         : Parent(_g, _v) {}
    373    
    374       UpperNodeMap& operator=(const UpperNodeMap& cmap) {
    375         return operator=<UpperNodeMap>(cmap);
     369      ANodeMap(const Graph& _g)
     370        : Parent(_g) {}
     371      ANodeMap(const Graph& _g, const _Value& _v)
     372        : Parent(_g, _v) {}
     373   
     374      ANodeMap& operator=(const ANodeMap& cmap) {
     375        return operator=<ANodeMap>(cmap);
    376376      }
    377377   
     
    381381      /// The given parameter should be conform to the ReadMap
    382382      /// concept and could be indiced by the current item set of
    383       /// the UpperNodeMap. In this case the value for each item
     383      /// the ANodeMap. In this case the value for each item
    384384      /// is assigned by the value of the given ReadMap.
    385385      template <typename CMap>
    386       UpperNodeMap& operator=(const CMap& cmap) {
    387         checkConcept<concept::ReadMap<UpperNode, _Value>, CMap>();
    388         const typename Parent::Graph* graph = Parent::getGraph();
    389         UpperNode it;
    390         for (graph->first(it); it != INVALID; graph->next(it)) {
    391           Parent::set(it, cmap[it]);
    392         }
    393         return *this;
    394       }
    395    
    396     };
    397 
    398     template <typename _Value>
    399     class LowerNodeMap
    400       : public IterableMapExtender<StaticMap<Graph, LowerNode, _Value> > {
    401     public:
    402       typedef StaticMappableUBipartiteGraphExtender Graph;
    403       typedef IterableMapExtender<StaticMap<Graph, LowerNode, _Value> >
     386      ANodeMap& operator=(const CMap& cmap) {
     387        checkConcept<concept::ReadMap<ANode, _Value>, CMap>();
     388        const typename Parent::Graph* graph = Parent::getGraph();
     389        ANode it;
     390        for (graph->first(it); it != INVALID; graph->next(it)) {
     391          Parent::set(it, cmap[it]);
     392        }
     393        return *this;
     394      }
     395   
     396    };
     397
     398    template <typename _Value>
     399    class BNodeMap
     400      : public IterableMapExtender<StaticMap<Graph, BNode, _Value> > {
     401    public:
     402      typedef StaticMappableBpUGraphExtender Graph;
     403      typedef IterableMapExtender<StaticMap<Graph, BNode, _Value> >
    404404      Parent;
    405405   
    406       LowerNodeMap(const Graph& _g)
    407         : Parent(_g) {}
    408       LowerNodeMap(const Graph& _g, const _Value& _v)
    409         : Parent(_g, _v) {}
    410    
    411       LowerNodeMap& operator=(const LowerNodeMap& cmap) {
    412         return operator=<LowerNodeMap>(cmap);
     406      BNodeMap(const Graph& _g)
     407        : Parent(_g) {}
     408      BNodeMap(const Graph& _g, const _Value& _v)
     409        : Parent(_g, _v) {}
     410   
     411      BNodeMap& operator=(const BNodeMap& cmap) {
     412        return operator=<BNodeMap>(cmap);
    413413      }
    414414   
     
    418418      /// The given parameter should be conform to the ReadMap
    419419      /// concept and could be indiced by the current item set of
    420       /// the LowerNodeMap. In this case the value for each item
     420      /// the BNodeMap. In this case the value for each item
    421421      /// is assigned by the value of the given ReadMap.
    422422      template <typename CMap>
    423       LowerNodeMap& operator=(const CMap& cmap) {
    424         checkConcept<concept::ReadMap<LowerNode, _Value>, CMap>();
    425         const typename Parent::Graph* graph = Parent::getGraph();
    426         LowerNode it;
     423      BNodeMap& operator=(const CMap& cmap) {
     424        checkConcept<concept::ReadMap<BNode, _Value>, CMap>();
     425        const typename Parent::Graph* graph = Parent::getGraph();
     426        BNode it;
    427427        for (graph->first(it); it != INVALID; graph->next(it)) {
    428428          Parent::set(it, cmap[it]);
     
    438438    class NodeMapBase : public Parent::NodeNotifier::ObserverBase {
    439439    public:
    440       typedef StaticMappableUBipartiteGraphExtender Graph;
     440      typedef StaticMappableBpUGraphExtender Graph;
    441441
    442442      typedef Node Key;
     
    444444
    445445      /// The reference type of the map;
    446       typedef typename LowerNodeMap<_Value>::Reference Reference;
     446      typedef typename BNodeMap<_Value>::Reference Reference;
    447447      /// The pointer type of the map;
    448       typedef typename LowerNodeMap<_Value>::Pointer Pointer;
     448      typedef typename BNodeMap<_Value>::Pointer Pointer;
    449449     
    450450      /// The const value type of the map.
    451451      typedef const Value ConstValue;
    452452      /// The const reference type of the map;
    453       typedef typename LowerNodeMap<_Value>::ConstReference ConstReference;
     453      typedef typename BNodeMap<_Value>::ConstReference ConstReference;
    454454      /// The pointer type of the map;
    455       typedef typename LowerNodeMap<_Value>::ConstPointer ConstPointer;
     455      typedef typename BNodeMap<_Value>::ConstPointer ConstPointer;
    456456
    457457      typedef True ReferenceMapTag;
    458458
    459459      NodeMapBase(const Graph& _g)
    460         : graph(&_g), lowerMap(_g), upperMap(_g) {
     460        : graph(&_g), bNodeMap(_g), aNodeMap(_g) {
    461461        Parent::NodeNotifier::ObserverBase::attach(_g.getNotifier(Node()));
    462462      }
    463463      NodeMapBase(const Graph& _g, const _Value& _v)
    464         : graph(&_g), lowerMap(_g, _v),
    465           upperMap(_g, _v) {
     464        : graph(&_g), bNodeMap(_g, _v),
     465          aNodeMap(_g, _v) {
    466466        Parent::NodeNotifier::ObserverBase::attach(_g.getNotifier(Node()));
    467467      }
     
    474474   
    475475      ConstReference operator[](const Key& node) const {
    476         if (Parent::upper(node)) {
    477           return upperMap[node];
     476        if (Parent::aNode(node)) {
     477          return aNodeMap[node];
    478478        } else {
    479           return lowerMap[node];
     479          return bNodeMap[node];
    480480        }
    481481      }
    482482
    483483      Reference operator[](const Key& node) {
    484         if (Parent::upper(node)) {
    485           return upperMap[node];
     484        if (Parent::aNode(node)) {
     485          return aNodeMap[node];
    486486        } else {
    487           return lowerMap[node];
     487          return bNodeMap[node];
    488488        }
    489489      }
    490490
    491491      void set(const Key& node, const Value& value) {
    492         if (Parent::upper(node)) {
    493           upperMap.set(node, value);
     492        if (Parent::aNode(node)) {
     493          aNodeMap.set(node, value);
    494494        } else {
    495           lowerMap.set(node, value);
     495          bNodeMap.set(node, value);
    496496        }
    497497      }
     
    508508    private:
    509509      const Graph* graph;
    510       LowerNodeMap<_Value> lowerMap;
    511       UpperNodeMap<_Value> upperMap;
     510      BNodeMap<_Value> bNodeMap;
     511      ANodeMap<_Value> aNodeMap;
    512512    };
    513513   
     
    518518      : public IterableMapExtender<NodeMapBase<_Value> > {
    519519    public:
    520       typedef StaticMappableUBipartiteGraphExtender Graph;
     520      typedef StaticMappableBpUGraphExtender Graph;
    521521      typedef IterableMapExtender< NodeMapBase<_Value> > Parent;
    522522   
     
    556556      : public IterableMapExtender<StaticMap<Graph, Edge, _Value> > {
    557557    public:
    558       typedef StaticMappableUBipartiteGraphExtender Graph;
     558      typedef StaticMappableBpUGraphExtender Graph;
    559559      typedef IterableMapExtender<StaticMap<Graph, Edge, _Value> > Parent;
    560560   
     
    584584      : public IterableMapExtender<StaticMap<Graph, UEdge, _Value> > {
    585585    public:
    586       typedef StaticMappableUBipartiteGraphExtender Graph;
     586      typedef StaticMappableBpUGraphExtender Graph;
    587587      typedef IterableMapExtender<StaticMap<Graph, UEdge, _Value> >
    588588      Parent;
Note: See TracChangeset for help on using the changeset viewer.