COIN-OR::LEMON - Graph Library

Changeset 1990:15fb7a4ea6be in lemon-0.x for lemon/iterable_maps.h


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

Some classes assumed that the GraphMaps? should be inherited
from an ObserverBase?. These classes parents replaced with
DefaultMap? which cause that the graph maps should not be
inherited from the ObserverBase?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/iterable_maps.h

    r1956 r1990  
    2020#include <lemon/invalid.h>
    2121
     22#include <lemon/bits/default_map.h>
     23
    2224#include <vector>
    2325#include <map>
     
    4850  /// \param _Item One of the graph's item type, the key of the map.
    4951  template <typename _Graph, typename _Item>
    50   class IterableBoolMap
    51     : protected ItemSetTraits<_Graph, _Item>::template Map<int>::Parent {
     52  class IterableBoolMap : protected DefaultMap<_Graph, _Item, int> {
    5253  private:
    5354    typedef _Graph Graph;
    5455   
    5556    typedef typename ItemSetTraits<Graph, _Item>::ItemIt KeyIt;
    56     typedef typename ItemSetTraits<Graph, _Item>
    57     ::template Map<int>::Parent Parent;
     57    typedef DefaultMap<_Graph, _Item, int> Parent;
    5858   
    5959    std::vector<_Item> array;
     
    400400  /// \param _Item One of the graph's item type, the key of the map.
    401401  template <typename _Graph, typename _Item>
    402   class IterableIntMap : protected ItemSetTraits<_Graph, _Item>
    403   ::template Map<_iterable_maps_bits::IterableIntMapNode<_Item> >::Parent {
     402  class IterableIntMap
     403    : protected DefaultMap<_Graph, _Item, _iterable_maps_bits::
     404                           IterableIntMapNode<_Item> > {
    404405  public:
    405     typedef typename ItemSetTraits<_Graph, _Item>
    406     ::template Map<_iterable_maps_bits::IterableIntMapNode<_Item> >
    407     ::Parent Parent;
     406    typedef DefaultMap<_Graph, _Item, _iterable_maps_bits::
     407                       IterableIntMapNode<_Item> >
     408    Parent;
    408409
    409410    /// The key type
     
    688689  /// \param _Value Any comparable value type.
    689690  template <typename _Graph, typename _Item, typename _Value>
    690   class IterableValueMap : protected ItemSetTraits<_Graph, _Item>
    691   ::template Map<_iterable_maps_bits::IterableValueMapNode<_Item, _Value> >
    692   ::Parent {
     691  class IterableValueMap
     692    : protected DefaultMap<_Graph, _Item, _iterable_maps_bits::
     693                           IterableValueMapNode<_Item, _Value> > {
    693694  public:
    694     typedef typename ItemSetTraits<_Graph, _Item>
    695     ::template Map<_iterable_maps_bits::IterableValueMapNode<_Item, _Value> >
    696     ::Parent Parent;
     695    typedef DefaultMap<_Graph, _Item, _iterable_maps_bits::
     696                       IterableValueMapNode<_Item, _Value> > Parent;
    697697
    698698    /// The key type
     
    703703    typedef _Graph Graph;
    704704
     705  protected:
     706
     707    typedef typename ItemSetTraits<_Graph, Key>::ItemIt KeyIt;
     708
     709  public:
     710
    705711    /// \brief Constructor of the Map with a given value.
    706712    ///
     
    708714    explicit IterableValueMap(const Graph& graph,
    709715                              const Value& value = Value())
    710       : Parent(graph, _iterable_maps_bits::IterableValueMapNode<_Item,
    711                _Value>(value)) {
    712       for (typename Parent::ItemIt it(*this); it != INVALID; ++it) {
     716      : Parent(graph, _iterable_maps_bits::
     717               IterableValueMapNode<_Item, _Value>(value)) {
     718      for (KeyIt it(*Parent::getGraph()); it != INVALID; ++it) {
    713719        lace(it);
    714720      }
    715721    }
    716722
    717   private:
     723  protected:
    718724   
    719725    void unlace(const Key& key) {
     
    872878  protected:
    873879   
     880    virtual void add(const Key& key) {
     881      Parent::add(key);
     882      unlace(key);
     883    }
     884
     885    virtual void add(const std::vector<Key>& keys) {
     886      Parent::add(keys);
     887      for (int i = 0; i < (int)keys.size(); ++i) {
     888        lace(keys[i]);
     889      }
     890    }
     891
    874892    virtual void erase(const Key& key) {
    875893      unlace(key);
     
    884902    }
    885903
     904    virtual void build() {
     905      Parent::build();
     906      for (KeyIt it(*Parent::getGraph()); it != INVALID; ++it) {
     907        lace(it);
     908      }
     909    }
     910
    886911    virtual void clear() {
    887912      first.clear();
Note: See TracChangeset for help on using the changeset viewer.