COIN-OR::LEMON - Graph Library

Changeset 209:765619b7cbb2 in lemon-1.2 for lemon/bits


Ignore:
Timestamp:
07/13/08 20:51:02 (16 years ago)
Author:
Alpar Juttner <alpar@…>
Branch:
default
Phase:
public
Message:

Apply unify-sources.sh to the source tree

Location:
lemon/bits
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • lemon/bits/alteration_notifier.h

    r157 r209  
    1 /* -*- C++ -*-
     1/* -*- mode: C++; indent-tabs-mode: nil; -*-
    22 *
    3  * This file is a part of LEMON, a generic C++ optimization library
     3 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    55 * Copyright (C) 2003-2008
     
    3333  /// \ingroup graphbits
    3434  ///
    35   /// \brief Notifier class to notify observes about alterations in 
     35  /// \brief Notifier class to notify observes about alterations in
    3636  /// a container.
    3737  ///
     
    5050  /// alteration of the graph.
    5151  ///
    52   /// This class provides an interface to the container. The \e first() and \e 
     52  /// This class provides an interface to the container. The \e first() and \e
    5353  /// next() member functions make possible to iterate on the keys of the
    5454  /// container. The \e id() function returns an integer id for each key.
     
    6161  /// from the graph. If all items are erased from the graph or from an empty
    6262  /// graph a new graph is builded then it can be signaled with the
    63   /// clear() and build() members. Important rule that if we erase items 
     63  /// clear() and build() members. Important rule that if we erase items
    6464  /// from graph we should first signal the alteration and after that erase
    6565  /// them from the container, on the other way on item addition we should
     
    6969  /// \e ObserverBase nested class. The signals can be handled with
    7070  /// overriding the virtual functions defined in the base class.  The
    71   /// observer base can be attached to the notifier with the 
     71  /// observer base can be attached to the notifier with the
    7272  /// \e attach() member and can be detached with detach() function. The
    7373  /// alteration handlers should not call any function which signals
     
    8080  /// be rolled back by calling the \e erase() or \e clear()
    8181  /// functions. Thence the \e erase() and \e clear() should not throw
    82   /// exception. Actullay, it can be throw only 
     82  /// exception. Actullay, it can be throw only
    8383  /// \ref AlterationObserver::ImmediateDetach ImmediateDetach
    8484  /// exception which detach the observer from the notifier.
     
    8686  /// There are some place when the alteration observing is not completly
    8787  /// reliable. If we want to carry out the node degree in the graph
    88   /// as in the \ref InDegMap and we use the reverseEdge that cause 
     88  /// as in the \ref InDegMap and we use the reverseEdge that cause
    8989  /// unreliable functionality. Because the alteration observing signals
    9090  /// only erasing and adding but not the reversing it will stores bad
     
    105105    typedef _Item Item;
    106106
    107     /// \brief Exception which can be called from \e clear() and 
     107    /// \brief Exception which can be called from \e clear() and
    108108    /// \e erase().
    109109    ///
     
    128128    /// The build() and clear() members are to notify the observer
    129129    /// about the container is built from an empty container or
    130     /// is cleared to an empty container. 
     130    /// is cleared to an empty container.
    131131
    132132    class ObserverBase {
     
    139139      ///
    140140      /// Default constructor for ObserverBase.
    141       /// 
     141      ///
    142142      ObserverBase() : _notifier(0) {}
    143143
     
    152152      ///
    153153      /// Constructor which attach the obserever to the same notifier as
    154       /// the other observer is attached to. 
     154      /// the other observer is attached to.
    155155      ObserverBase(const ObserverBase& copy) {
    156         if (copy.attached()) {
     156        if (copy.attached()) {
    157157          attach(*copy.notifier());
    158         }
    159       }
    160        
     158        }
     159      }
     160
    161161      /// \brief Destructor
    162162      virtual ~ObserverBase() {
     
    171171      ///
    172172      void attach(AlterationNotifier& nf) {
    173         nf.attach(*this);
    174       }
    175      
     173        nf.attach(*this);
     174      }
     175
    176176      /// \brief Detaches the observer into an AlterationNotifier.
    177177      ///
     
    181181        _notifier->detach(*this);
    182182      }
    183      
    184       /// \brief Gives back a pointer to the notifier which the map 
     183
     184      /// \brief Gives back a pointer to the notifier which the map
    185185      /// attached into.
    186186      ///
     
    189189      ///
    190190      Notifier* notifier() const { return const_cast<Notifier*>(_notifier); }
    191      
     191
    192192      /// Gives back true when the observer is attached into a notifier.
    193193      bool attached() const { return _notifier != 0; }
     
    198198
    199199    protected:
    200      
     200
    201201      Notifier* _notifier;
    202202      typename std::list<ObserverBase*>::iterator _index;
     
    210210      virtual void add(const Item&) = 0;
    211211
    212       /// \brief The member function to notificate the observer about 
     212      /// \brief The member function to notificate the observer about
    213213      /// more item is added to the container.
    214214      ///
     
    223223      /// The erase() member function notificates the observer about an
    224224      /// item is erased from the container. It have to be overrided in
    225       /// the subclasses.       
     225      /// the subclasses.
    226226      virtual void erase(const Item&) = 0;
    227227
    228       /// \brief The member function to notificate the observer about 
     228      /// \brief The member function to notificate the observer about
    229229      /// more item is erased from the container.
    230230      ///
     
    248248      /// The clear() member function notificates the observer about all
    249249      /// items are erased from the container. It have to be overrided in
    250       /// the subclasses.     
     250      /// the subclasses.
    251251      virtual void clear() = 0;
    252252
    253253    };
    254        
     254
    255255  protected:
    256256
    257257    const Container* container;
    258258
    259     typedef std::list<ObserverBase*> Observers; 
     259    typedef std::list<ObserverBase*> Observers;
    260260    Observers _observers;
    261261
    262                
     262
    263263  public:
    264264
    265265    /// \brief Default constructor.
    266266    ///
    267     /// The default constructor of the AlterationNotifier. 
     267    /// The default constructor of the AlterationNotifier.
    268268    /// It creates an empty notifier.
    269     AlterationNotifier() 
     269    AlterationNotifier()
    270270      : container(0) {}
    271271
     
    273273    ///
    274274    /// Constructor with the observed container parameter.
    275     AlterationNotifier(const Container& _container) 
     275    AlterationNotifier(const Container& _container)
    276276      : container(&_container) {}
    277277
    278     /// \brief Copy Constructor of the AlterationNotifier. 
    279     ///
    280     /// Copy constructor of the AlterationNotifier. 
     278    /// \brief Copy Constructor of the AlterationNotifier.
     279    ///
     280    /// Copy constructor of the AlterationNotifier.
    281281    /// It creates only an empty notifier because the copiable
    282282    /// notifier's observers have to be registered still into that notifier.
    283     AlterationNotifier(const AlterationNotifier& _notifier) 
     283    AlterationNotifier(const AlterationNotifier& _notifier)
    284284      : container(_notifier.container) {}
    285285
    286286    /// \brief Destructor.
    287     ///         
     287    ///
    288288    /// Destructor of the AlterationNotifier.
    289289    ///
     
    291291      typename Observers::iterator it;
    292292      for (it = _observers.begin(); it != _observers.end(); ++it) {
    293         (*it)->_notifier = 0;
     293        (*it)->_notifier = 0;
    294294      }
    295295    }
     
    339339      return container->maxId(Item());
    340340    }
    341                
     341
    342342  protected:
    343343
     
    345345      observer._index = _observers.insert(_observers.begin(), &observer);
    346346      observer._notifier = this;
    347     } 
     347    }
    348348
    349349    void detach(ObserverBase& observer) {
     
    354354
    355355  public:
    356        
    357     /// \brief Notifies all the registed observers about an item added to 
    358     /// the container.
    359     ///
    360     /// It notifies all the registed observers about an item added to 
    361     /// the container.
    362     /// 
     356
     357    /// \brief Notifies all the registed observers about an item added to
     358    /// the container.
     359    ///
     360    /// It notifies all the registed observers about an item added to
     361    /// the container.
     362    ///
    363363    void add(const Item& item) {
    364364      typename Observers::reverse_iterator it;
     
    374374        throw;
    375375      }
    376     }   
    377 
    378     /// \brief Notifies all the registed observers about more item added to 
    379     /// the container.
    380     ///
    381     /// It notifies all the registed observers about more item added to 
    382     /// the container.
    383     /// 
     376    }
     377
     378    /// \brief Notifies all the registed observers about more item added to
     379    /// the container.
     380    ///
     381    /// It notifies all the registed observers about more item added to
     382    /// the container.
     383    ///
    384384    void add(const std::vector<Item>& items) {
    385385      typename Observers::reverse_iterator it;
     
    395395        throw;
    396396      }
    397     }   
    398 
    399     /// \brief Notifies all the registed observers about an item erased from 
    400     /// the container.
    401     /// 
    402     /// It notifies all the registed observers about an item erased from 
    403     /// the container.
    404     /// 
     397    }
     398
     399    /// \brief Notifies all the registed observers about an item erased from
     400    /// the container.
     401    ///
     402    /// It notifies all the registed observers about an item erased from
     403    /// the container.
     404    ///
    405405    void erase(const Item& item) throw() {
    406406      typename Observers::iterator it = _observers.begin();
     
    417417    }
    418418
    419     /// \brief Notifies all the registed observers about more item erased 
     419    /// \brief Notifies all the registed observers about more item erased
    420420    /// from the container.
    421     /// 
    422     /// It notifies all the registed observers about more item erased from 
    423     /// the container.
    424     /// 
     421    ///
     422    /// It notifies all the registed observers about more item erased from
     423    /// the container.
     424    ///
    425425    void erase(const std::vector<Item>& items) {
    426426      typename Observers::iterator it = _observers.begin();
     
    437437    }
    438438
    439     /// \brief Notifies all the registed observers about the container is 
     439    /// \brief Notifies all the registed observers about the container is
    440440    /// built.
    441     ///         
     441    ///
    442442    /// Notifies all the registed observers about the container is built
    443443    /// from an empty container.
     
    457457    }
    458458
    459     /// \brief Notifies all the registed observers about all items are 
     459    /// \brief Notifies all the registed observers about all items are
    460460    /// erased.
    461461    ///
  • lemon/bits/array_map.h

    r107 r209  
    1 /* -*- C++ -*-
    2  *
    3  * This file is a part of LEMON, a generic C++ optimization library
     1/* -*- mode: C++; indent-tabs-mode: nil; -*-
     2 *
     3 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    55 * Copyright (C) 2003-2008
     
    3939  /// The ArrayMap template class is graph map structure what
    4040  /// automatically updates the map when a key is added to or erased from
    41   /// the map. This map uses the allocators to implement 
     41  /// the map. This map uses the allocators to implement
    4242  /// the container functionality.
    4343  ///
     
    4545  /// the Value type of the map.
    4646  template <typename _Graph, typename _Item, typename _Value>
    47   class ArrayMap 
     47  class ArrayMap
    4848    : public ItemSetTraits<_Graph, _Item>::ItemNotifier::ObserverBase {
    4949  public:
    50     /// The graph type of the maps. 
     50    /// The graph type of the maps.
    5151    typedef _Graph Graph;
    5252    /// The item type of the map.
     
    7070    /// The MapBase of the Map which imlements the core regisitry function.
    7171    typedef typename Notifier::ObserverBase Parent;
    72                
     72
    7373  private:
    7474    typedef std::allocator<Value> Allocator;
     
    8585      Item it;
    8686      for (nf->first(it); it != INVALID; nf->next(it)) {
    87         int id = nf->id(it);;
    88         allocator.construct(&(values[id]), Value());
    89       }                                                         
    90     }
    91 
    92     /// \brief Constructor to use default value to initialize the map. 
    93     ///
    94     /// It constructs a map and initialize all of the the map. 
     87        int id = nf->id(it);;
     88        allocator.construct(&(values[id]), Value());
     89      }
     90    }
     91
     92    /// \brief Constructor to use default value to initialize the map.
     93    ///
     94    /// It constructs a map and initialize all of the the map.
    9595    ArrayMap(const Graph& graph, const Value& value) {
    9696      Parent::attach(graph.notifier(Item()));
     
    9999      Item it;
    100100      for (nf->first(it); it != INVALID; nf->next(it)) {
    101         int id = nf->id(it);;
    102         allocator.construct(&(values[id]), value);
    103       }                                                         
     101        int id = nf->id(it);;
     102        allocator.construct(&(values[id]), value);
     103      }
    104104    }
    105105
    106106    /// \brief Constructor to copy a map of the same map type.
    107107    ///
    108     /// Constructor to copy a map of the same map type.     
     108    /// Constructor to copy a map of the same map type.
    109109    ArrayMap(const ArrayMap& copy) : Parent() {
    110110      if (copy.attached()) {
    111         attach(*copy.notifier());
     111        attach(*copy.notifier());
    112112      }
    113113      capacity = copy.capacity;
     
    117117      Item it;
    118118      for (nf->first(it); it != INVALID; nf->next(it)) {
    119         int id = nf->id(it);;
    120         allocator.construct(&(values[id]), copy.values[id]);
     119        int id = nf->id(it);;
     120        allocator.construct(&(values[id]), copy.values[id]);
    121121      }
    122122    }
     
    125125    ///
    126126    /// This operator assigns for each item in the map the
    127     /// value mapped to the same item in the copied map. 
     127    /// value mapped to the same item in the copied map.
    128128    /// The parameter map should be indiced with the same
    129129    /// itemset because this assign operator does not change
    130     /// the container of the map. 
     130    /// the container of the map.
    131131    ArrayMap& operator=(const ArrayMap& cmap) {
    132132      return operator=<ArrayMap>(cmap);
     
    139139    /// concecpt and could be indiced by the current item set of
    140140    /// the NodeMap. In this case the value for each item
    141     /// is assigned by the value of the given ReadMap. 
     141    /// is assigned by the value of the given ReadMap.
    142142    template <typename CMap>
    143143    ArrayMap& operator=(const CMap& cmap) {
     
    152152
    153153    /// \brief The destructor of the map.
    154     ///     
     154    ///
    155155    /// The destructor of the map.
    156     virtual ~ArrayMap() {     
     156    virtual ~ArrayMap() {
    157157      if (attached()) {
    158         clear();
    159         detach();
    160       }
    161     }
    162                
     158        clear();
     159        detach();
     160      }
     161    }
     162
    163163  protected:
    164164
     
    169169  public:
    170170
    171     /// \brief The subscript operator. 
     171    /// \brief The subscript operator.
    172172    ///
    173173    /// The subscript operator. The map can be subscripted by the
    174     /// actual keys of the graph. 
     174    /// actual keys of the graph.
    175175    Value& operator[](const Key& key) {
    176176      int id = Parent::notifier()->id(key);
    177177      return values[id];
    178     } 
    179                
     178    }
     179
    180180    /// \brief The const subscript operator.
    181181    ///
    182182    /// The const subscript operator. The map can be subscripted by the
    183     /// actual keys of the graph. 
     183    /// actual keys of the graph.
    184184    const Value& operator[](const Key& key) const {
    185185      int id = Parent::notifier()->id(key);
     
    188188
    189189    /// \brief Setter function of the map.
    190     /// 
     190    ///
    191191    /// Setter function of the map. Equivalent with map[key] = val.
    192192    /// This is a compatibility feature with the not dereferable maps.
     
    198198
    199199    /// \brief Adds a new key to the map.
    200     ///         
     200    ///
    201201    /// It adds a new key to the map. It called by the observer notifier
    202     /// and it overrides the add() member function of the observer base.     
     202    /// and it overrides the add() member function of the observer base.
    203203    virtual void add(const Key& key) {
    204204      Notifier* nf = Parent::notifier();
    205205      int id = nf->id(key);
    206206      if (id >= capacity) {
    207         int new_capacity = (capacity == 0 ? 1 : capacity);
    208         while (new_capacity <= id) {
    209           new_capacity <<= 1;
    210         }
    211         Value* new_values = allocator.allocate(new_capacity);
    212         Item it;
    213         for (nf->first(it); it != INVALID; nf->next(it)) {
    214           int jd = nf->id(it);;
    215           if (id != jd) {
    216             allocator.construct(&(new_values[jd]), values[jd]);
    217             allocator.destroy(&(values[jd]));
    218           }
    219         }
    220         if (capacity != 0) allocator.deallocate(values, capacity);
    221         values = new_values;
    222         capacity = new_capacity;
     207        int new_capacity = (capacity == 0 ? 1 : capacity);
     208        while (new_capacity <= id) {
     209          new_capacity <<= 1;
     210        }
     211        Value* new_values = allocator.allocate(new_capacity);
     212        Item it;
     213        for (nf->first(it); it != INVALID; nf->next(it)) {
     214          int jd = nf->id(it);;
     215          if (id != jd) {
     216            allocator.construct(&(new_values[jd]), values[jd]);
     217            allocator.destroy(&(values[jd]));
     218          }
     219        }
     220        if (capacity != 0) allocator.deallocate(values, capacity);
     221        values = new_values;
     222        capacity = new_capacity;
    223223      }
    224224      allocator.construct(&(values[id]), Value());
     
    226226
    227227    /// \brief Adds more new keys to the map.
    228     ///         
     228    ///
    229229    /// It adds more new keys to the map. It called by the observer notifier
    230     /// and it overrides the add() member function of the observer base.     
     230    /// and it overrides the add() member function of the observer base.
    231231    virtual void add(const std::vector<Key>& keys) {
    232232      Notifier* nf = Parent::notifier();
    233233      int max_id = -1;
    234234      for (int i = 0; i < int(keys.size()); ++i) {
    235         int id = nf->id(keys[i]);
    236         if (id > max_id) {
    237           max_id = id;
    238         }
     235        int id = nf->id(keys[i]);
     236        if (id > max_id) {
     237          max_id = id;
     238        }
    239239      }
    240240      if (max_id >= capacity) {
    241         int new_capacity = (capacity == 0 ? 1 : capacity);
    242         while (new_capacity <= max_id) {
    243           new_capacity <<= 1;
    244         }
    245         Value* new_values = allocator.allocate(new_capacity);
    246         Item it;
    247         for (nf->first(it); it != INVALID; nf->next(it)) {
    248           int id = nf->id(it);
    249           bool found = false;
    250           for (int i = 0; i < int(keys.size()); ++i) {
    251             int jd = nf->id(keys[i]);
    252             if (id == jd) {
    253               found = true;
    254               break;
    255             }
    256           }
    257           if (found) continue;
    258           allocator.construct(&(new_values[id]), values[id]);
    259           allocator.destroy(&(values[id]));
    260         }
    261         if (capacity != 0) allocator.deallocate(values, capacity);
    262         values = new_values;
    263         capacity = new_capacity;
     241        int new_capacity = (capacity == 0 ? 1 : capacity);
     242        while (new_capacity <= max_id) {
     243          new_capacity <<= 1;
     244        }
     245        Value* new_values = allocator.allocate(new_capacity);
     246        Item it;
     247        for (nf->first(it); it != INVALID; nf->next(it)) {
     248          int id = nf->id(it);
     249          bool found = false;
     250          for (int i = 0; i < int(keys.size()); ++i) {
     251            int jd = nf->id(keys[i]);
     252            if (id == jd) {
     253              found = true;
     254              break;
     255            }
     256          }
     257          if (found) continue;
     258          allocator.construct(&(new_values[id]), values[id]);
     259          allocator.destroy(&(values[id]));
     260        }
     261        if (capacity != 0) allocator.deallocate(values, capacity);
     262        values = new_values;
     263        capacity = new_capacity;
    264264      }
    265265      for (int i = 0; i < int(keys.size()); ++i) {
    266         int id = nf->id(keys[i]);
    267         allocator.construct(&(values[id]), Value());
    268       }
    269     }
    270                
     266        int id = nf->id(keys[i]);
     267        allocator.construct(&(values[id]), Value());
     268      }
     269    }
     270
    271271    /// \brief Erase a key from the map.
    272272    ///
    273273    /// Erase a key from the map. It called by the observer notifier
    274     /// and it overrides the erase() member function of the observer base.     
     274    /// and it overrides the erase() member function of the observer base.
    275275    virtual void erase(const Key& key) {
    276276      int id = Parent::notifier()->id(key);
     
    281281    ///
    282282    /// Erase more keys from the map. It called by the observer notifier
    283     /// and it overrides the erase() member function of the observer base.     
     283    /// and it overrides the erase() member function of the observer base.
    284284    virtual void erase(const std::vector<Key>& keys) {
    285285      for (int i = 0; i < int(keys.size()); ++i) {
    286         int id = Parent::notifier()->id(keys[i]);
    287         allocator.destroy(&(values[id]));
     286        int id = Parent::notifier()->id(keys[i]);
     287        allocator.destroy(&(values[id]));
    288288      }
    289289    }
    290290
    291291    /// \brief Buildes the map.
    292     /// 
     292    ///
    293293    /// It buildes the map. It called by the observer notifier
    294     /// and it overrides the build() member function of the observer base. 
     294    /// and it overrides the build() member function of the observer base.
    295295    virtual void build() {
    296296      Notifier* nf = Parent::notifier();
     
    298298      Item it;
    299299      for (nf->first(it); it != INVALID; nf->next(it)) {
    300         int id = nf->id(it);;
    301         allocator.construct(&(values[id]), Value());
    302       }                                                         
     300        int id = nf->id(it);;
     301        allocator.construct(&(values[id]), Value());
     302      }
    303303    }
    304304
     
    306306    ///
    307307    /// It erase all items from the map. It called by the observer notifier
    308     /// and it overrides the clear() member function of the observer base.     
    309     virtual void clear() {     
     308    /// and it overrides the clear() member function of the observer base.
     309    virtual void clear() {
    310310      Notifier* nf = Parent::notifier();
    311311      if (capacity != 0) {
    312         Item it;
    313         for (nf->first(it); it != INVALID; nf->next(it)) {
    314           int id = nf->id(it);
    315           allocator.destroy(&(values[id]));
    316         }                                                               
    317         allocator.deallocate(values, capacity);
    318         capacity = 0;
     312        Item it;
     313        for (nf->first(it); it != INVALID; nf->next(it)) {
     314          int id = nf->id(it);
     315          allocator.destroy(&(values[id]));
     316        }
     317        allocator.deallocate(values, capacity);
     318        capacity = 0;
    319319      }
    320320    }
    321321
    322322  private:
    323      
     323
    324324    void allocate_memory() {
    325325      int max_id = Parent::notifier()->maxId();
    326326      if (max_id == -1) {
    327         capacity = 0;
    328         values = 0;
    329         return;
     327        capacity = 0;
     328        values = 0;
     329        return;
    330330      }
    331331      capacity = 1;
    332332      while (capacity <= max_id) {
    333         capacity <<= 1;
    334       }
    335       values = allocator.allocate(capacity);   
    336     }     
     333        capacity <<= 1;
     334      }
     335      values = allocator.allocate(capacity);
     336    }
    337337
    338338    int capacity;
     
    340340    Allocator allocator;
    341341
    342   };           
     342  };
    343343
    344344}
    345345
    346 #endif 
     346#endif
  • lemon/bits/base_extender.h

    r107 r209  
    1 /* -*- C++ -*-
     1/* -*- mode: C++; indent-tabs-mode: nil; -*-
    22 *
    3  * This file is a part of LEMON, a generic C++ optimization library
     3 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    55 * Copyright (C) 2003-2008
     
    6464
    6565      bool operator==(const Arc &that) const {
    66         return forward==that.forward && Edge(*this)==Edge(that);
     66        return forward==that.forward && Edge(*this)==Edge(that);
    6767      }
    6868      bool operator!=(const Arc &that) const {
    69         return forward!=that.forward || Edge(*this)!=Edge(that);
     69        return forward!=that.forward || Edge(*this)!=Edge(that);
    7070      }
    7171      bool operator<(const Arc &that) const {
    72         return forward<that.forward ||
    73           (!(that.forward<forward) && Edge(*this)<Edge(that));
     72        return forward<that.forward ||
     73          (!(that.forward<forward) && Edge(*this)<Edge(that));
    7474      }
    7575    };
     
    118118    void next(Arc &e) const {
    119119      if( e.forward ) {
    120         e.forward = false;
     120        e.forward = false;
    121121      }
    122122      else {
    123         Parent::next(e);
    124         e.forward = true;
     123        Parent::next(e);
     124        e.forward = true;
    125125      }
    126126    }
     
    129129      Parent::firstIn(e,n);
    130130      if( Edge(e) != INVALID ) {
    131         e.forward = false;
     131        e.forward = false;
    132132      }
    133133      else {
    134         Parent::firstOut(e,n);
    135         e.forward = true;
     134        Parent::firstOut(e,n);
     135        e.forward = true;
    136136      }
    137137    }
    138138    void nextOut(Arc &e) const {
    139139      if( ! e.forward ) {
    140         Node n = Parent::target(e);
    141         Parent::nextIn(e);
    142         if( Edge(e) == INVALID ) {
    143           Parent::firstOut(e, n);
    144           e.forward = true;
    145         }
     140        Node n = Parent::target(e);
     141        Parent::nextIn(e);
     142        if( Edge(e) == INVALID ) {
     143          Parent::firstOut(e, n);
     144          e.forward = true;
     145        }
    146146      }
    147147      else {
    148         Parent::nextOut(e);
     148        Parent::nextOut(e);
    149149      }
    150150    }
     
    153153      Parent::firstOut(e,n);
    154154      if( Edge(e) != INVALID ) {
    155         e.forward = false;
     155        e.forward = false;
    156156      }
    157157      else {
    158         Parent::firstIn(e,n);
    159         e.forward = true;
     158        Parent::firstIn(e,n);
     159        e.forward = true;
    160160      }
    161161    }
    162162    void nextIn(Arc &e) const {
    163163      if( ! e.forward ) {
    164         Node n = Parent::source(e);
    165         Parent::nextOut(e);
    166         if( Edge(e) == INVALID ) {
    167           Parent::firstIn(e, n);
    168           e.forward = true;
    169         }
     164        Node n = Parent::source(e);
     165        Parent::nextOut(e);
     166        if( Edge(e) == INVALID ) {
     167          Parent::firstIn(e, n);
     168          e.forward = true;
     169        }
    170170      }
    171171      else {
    172         Parent::nextIn(e);
     172        Parent::nextIn(e);
    173173      }
    174174    }
     
    184184    void nextInc(Edge &e, bool &d) const {
    185185      if (d) {
    186         Node s = Parent::source(e);
    187         Parent::nextOut(e);
    188         if (e != INVALID) return;
    189         d = false;
    190         Parent::firstIn(e, s);
    191       } else {
    192         Parent::nextIn(e);
     186        Node s = Parent::source(e);
     187        Parent::nextOut(e);
     188        if (e != INVALID) return;
     189        d = false;
     190        Parent::firstIn(e, s);
     191      } else {
     192        Parent::nextIn(e);
    193193      }
    194194    }
     
    241241    Arc findArc(Node s, Node t, Arc p = INVALID) const {
    242242      if (p == INVALID) {
    243         Edge arc = Parent::findArc(s, t);
    244         if (arc != INVALID) return direct(arc, true);
    245         arc = Parent::findArc(t, s);
    246         if (arc != INVALID) return direct(arc, false);
     243        Edge arc = Parent::findArc(s, t);
     244        if (arc != INVALID) return direct(arc, true);
     245        arc = Parent::findArc(t, s);
     246        if (arc != INVALID) return direct(arc, false);
    247247      } else if (direction(p)) {
    248         Edge arc = Parent::findArc(s, t, p);
    249         if (arc != INVALID) return direct(arc, true);
    250         arc = Parent::findArc(t, s);
    251         if (arc != INVALID) return direct(arc, false); 
    252       } else {
    253         Edge arc = Parent::findArc(t, s, p);
    254         if (arc != INVALID) return direct(arc, false);       
     248        Edge arc = Parent::findArc(s, t, p);
     249        if (arc != INVALID) return direct(arc, true);
     250        arc = Parent::findArc(t, s);
     251        if (arc != INVALID) return direct(arc, false);
     252      } else {
     253        Edge arc = Parent::findArc(t, s, p);
     254        if (arc != INVALID) return direct(arc, false);
    255255      }
    256256      return INVALID;
     
    268268          if (arc != INVALID) return arc;
    269269          arc = Parent::findArc(t, s);
    270           if (arc != INVALID) return arc;       
     270          if (arc != INVALID) return arc;
    271271        } else {
    272272          Edge arc = Parent::findArc(t, s, p);
    273           if (arc != INVALID) return arc;             
     273          if (arc != INVALID) return arc;
    274274        }
    275275      } else {
     
    300300      Red() {}
    301301      Red(const Node& node) : Node(node) {
    302         LEMON_ASSERT(Parent::red(node) || node == INVALID,
    303                      typename Parent::NodeSetError());
     302        LEMON_ASSERT(Parent::red(node) || node == INVALID,
     303                     typename Parent::NodeSetError());
    304304      }
    305305      Red& operator=(const Node& node) {
    306         LEMON_ASSERT(Parent::red(node) || node == INVALID,
    307                      typename Parent::NodeSetError());
     306        LEMON_ASSERT(Parent::red(node) || node == INVALID,
     307                     typename Parent::NodeSetError());
    308308        Node::operator=(node);
    309309        return *this;
     
    332332      Blue() {}
    333333      Blue(const Node& node) : Node(node) {
    334         LEMON_ASSERT(Parent::blue(node) || node == INVALID,
    335                      typename Parent::NodeSetError());
     334        LEMON_ASSERT(Parent::blue(node) || node == INVALID,
     335                     typename Parent::NodeSetError());
    336336      }
    337337      Blue& operator=(const Node& node) {
    338         LEMON_ASSERT(Parent::blue(node) || node == INVALID,
    339                      typename Parent::NodeSetError());
     338        LEMON_ASSERT(Parent::blue(node) || node == INVALID,
     339                     typename Parent::NodeSetError());
    340340        Node::operator=(node);
    341341        return *this;
     
    354354      Parent::nextBlue(static_cast<Node&>(node));
    355355    }
    356  
     356
    357357    int id(const Blue& node) const {
    358358      return Parent::redId(node);
     
    368368    void firstInc(Edge& arc, bool& dir, const Node& node) const {
    369369      if (Parent::red(node)) {
    370         Parent::firstFromRed(arc, node);
    371         dir = true;
    372       } else {
    373         Parent::firstFromBlue(arc, node);
    374         dir = static_cast<Edge&>(arc) == INVALID;
     370        Parent::firstFromRed(arc, node);
     371        dir = true;
     372      } else {
     373        Parent::firstFromBlue(arc, node);
     374        dir = static_cast<Edge&>(arc) == INVALID;
    375375      }
    376376    }
    377377    void nextInc(Edge& arc, bool& dir) const {
    378378      if (dir) {
    379         Parent::nextFromRed(arc);
    380       } else {
    381         Parent::nextFromBlue(arc);
    382         if (arc == INVALID) dir = true;
     379        Parent::nextFromRed(arc);
     380      } else {
     381        Parent::nextFromBlue(arc);
     382        if (arc == INVALID) dir = true;
    383383      }
    384384    }
     
    390390
    391391      Arc(const Edge& arc, bool _forward)
    392         : Edge(arc), forward(_forward) {}
     392        : Edge(arc), forward(_forward) {}
    393393
    394394    public:
     
    396396      Arc (Invalid) : Edge(INVALID), forward(true) {}
    397397      bool operator==(const Arc& i) const {
    398         return Edge::operator==(i) && forward == i.forward;
     398        return Edge::operator==(i) && forward == i.forward;
    399399      }
    400400      bool operator!=(const Arc& i) const {
    401         return Edge::operator!=(i) || forward != i.forward;
     401        return Edge::operator!=(i) || forward != i.forward;
    402402      }
    403403      bool operator<(const Arc& i) const {
    404         return Edge::operator<(i) ||
    405           (!(i.forward<forward) && Edge(*this)<Edge(i));
     404        return Edge::operator<(i) ||
     405          (!(i.forward<forward) && Edge(*this)<Edge(i));
    406406      }
    407407    };
     
    414414    void next(Arc& arc) const {
    415415      if (!arc.forward) {
    416         Parent::next(static_cast<Edge&>(arc));
     416        Parent::next(static_cast<Edge&>(arc));
    417417      }
    418418      arc.forward = !arc.forward;
     
    421421    void firstOut(Arc& arc, const Node& node) const {
    422422      if (Parent::red(node)) {
    423         Parent::firstFromRed(arc, node);
    424         arc.forward = true;
    425       } else {
    426         Parent::firstFromBlue(arc, node);
    427         arc.forward = static_cast<Edge&>(arc) == INVALID;
     423        Parent::firstFromRed(arc, node);
     424        arc.forward = true;
     425      } else {
     426        Parent::firstFromBlue(arc, node);
     427        arc.forward = static_cast<Edge&>(arc) == INVALID;
    428428      }
    429429    }
    430430    void nextOut(Arc& arc) const {
    431431      if (arc.forward) {
    432         Parent::nextFromRed(arc);
    433       } else {
    434         Parent::nextFromBlue(arc);
     432        Parent::nextFromRed(arc);
     433      } else {
     434        Parent::nextFromBlue(arc);
    435435        arc.forward = static_cast<Edge&>(arc) == INVALID;
    436436      }
     
    439439    void firstIn(Arc& arc, const Node& node) const {
    440440      if (Parent::blue(node)) {
    441         Parent::firstFromBlue(arc, node);
    442         arc.forward = true;     
    443       } else {
    444         Parent::firstFromRed(arc, node);
    445         arc.forward = static_cast<Edge&>(arc) == INVALID;
     441        Parent::firstFromBlue(arc, node);
     442        arc.forward = true;
     443      } else {
     444        Parent::firstFromRed(arc, node);
     445        arc.forward = static_cast<Edge&>(arc) == INVALID;
    446446      }
    447447    }
    448448    void nextIn(Arc& arc) const {
    449449      if (arc.forward) {
    450         Parent::nextFromBlue(arc);
    451       } else {
    452         Parent::nextFromRed(arc);
    453         arc.forward = static_cast<Edge&>(arc) == INVALID;
     450        Parent::nextFromBlue(arc);
     451      } else {
     452        Parent::nextFromRed(arc);
     453        arc.forward = static_cast<Edge&>(arc) == INVALID;
    454454      }
    455455    }
     
    463463
    464464    int id(const Arc& arc) const {
    465       return (Parent::id(static_cast<const Edge&>(arc)) << 1) + 
     465      return (Parent::id(static_cast<const Edge&>(arc)) << 1) +
    466466        (arc.forward ? 0 : 1);
    467467    }
  • lemon/bits/bezier.h

    r184 r209  
    1 /* -*- C++ -*-
     1/* -*- mode: C++; indent-tabs-mode: nil; -*-
    22 *
    3  * This file is a part of LEMON, a generic C++ optimization library
     3 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    55 * Copyright (C) 2003-2008
     
    4545  Bezier1() {}
    4646  Bezier1(Point _p1, Point _p2) :p1(_p1), p2(_p2) {}
    47  
     47
    4848  Point operator()(double t) const
    4949  {
     
    5555    return Bezier1(p1,conv(p1,p2,t));
    5656  }
    57  
     57
    5858  Bezier1 after(double t) const
    5959  {
     
    8888    return Bezier2(p1,q,conv(q,r,t));
    8989  }
    90  
     90
    9191  Bezier2 after(double t) const
    9292  {
     
    111111  Bezier3(Point _p1, Point _p2, Point _p3, Point _p4)
    112112    : p1(_p1), p2(_p2), p3(_p3), p4(_p4) {}
    113   Bezier3(const Bezier1 &b) : p1(b.p1), p2(conv(b.p1,b.p2,1.0/3.0)), 
    114                               p3(conv(b.p1,b.p2,2.0/3.0)), p4(b.p2) {}
     113  Bezier3(const Bezier1 &b) : p1(b.p1), p2(conv(b.p1,b.p2,1.0/3.0)),
     114                              p3(conv(b.p1,b.p2,2.0/3.0)), p4(b.p2) {}
    115115  Bezier3(const Bezier2 &b) : p1(b.p1), p2(conv(b.p1,b.p2,2.0/3.0)),
    116                               p3(conv(b.p2,b.p3,1.0/3.0)), p4(b.p3) {}
    117  
    118   Point operator()(double t) const 
     116                              p3(conv(b.p2,b.p3,1.0/3.0)), p4(b.p3) {}
     117
     118  Point operator()(double t) const
    119119    {
    120120      //    return Bezier2(conv(p1,p2,t),conv(p2,p3,t),conv(p3,p4,t))(t);
    121121      return ((1-t)*(1-t)*(1-t))*p1+(3*t*(1-t)*(1-t))*p2+
    122         (3*t*t*(1-t))*p3+(t*t*t)*p4;
     122        (3*t*t*(1-t))*p3+(t*t*t)*p4;
    123123    }
    124124  Bezier3 before(double t) const
     
    132132      return Bezier3(p1,p,a,c);
    133133    }
    134  
     134
    135135  Bezier3 after(double t) const
    136136    {
     
    147147  Bezier2 grad() const { return Bezier2(3.0*(p2-p1),3.0*(p3-p2),3.0*(p4-p3)); }
    148148  Bezier2 norm() const { return Bezier2(3.0*rot90(p2-p1),
    149                                   3.0*rot90(p3-p2),
    150                                   3.0*rot90(p4-p3)); }
     149                                  3.0*rot90(p3-p2),
     150                                  3.0*rot90(p4-p3)); }
    151151  Point grad(double t) const { return grad()(t); }
    152152  Point norm(double t) const { return rot90(grad(t)); }
    153153
    154154  template<class R,class F,class S,class D>
    155   R recSplit(F &_f,const S &_s,D _d) const 
     155  R recSplit(F &_f,const S &_s,D _d) const
    156156  {
    157157    const Point a=(p1+p2)/2;
     
    165165    return _s(f1,f2);
    166166  }
    167  
     167
    168168};
    169169
  • lemon/bits/default_map.h

    r107 r209  
    1 /* -*- C++ -*-
     1/* -*- mode: C++; indent-tabs-mode: nil; -*-
    22 *
    3  * This file is a part of LEMON, a generic C++ optimization library
     3 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    55 * Copyright (C) 2003-2008
     
    3030
    3131namespace lemon {
    32  
    33  
     32
     33
    3434  //#ifndef LEMON_USE_DEBUG_MAP
    3535
     
    141141  };
    142142
    143 // #else 
     143// #else
    144144
    145145//   template <typename _Graph, typename _Item, typename _Value>
     
    148148//   };
    149149
    150 // #endif 
     150// #endif
    151151
    152152  /// \e
    153153  template <typename _Graph, typename _Item, typename _Value>
    154   class DefaultMap 
     154  class DefaultMap
    155155    : public DefaultMapSelector<_Graph, _Item, _Value>::Map {
    156156  public:
    157157    typedef typename DefaultMapSelector<_Graph, _Item, _Value>::Map Parent;
    158158    typedef DefaultMap<_Graph, _Item, _Value> Map;
    159    
     159
    160160    typedef typename Parent::Graph Graph;
    161161    typedef typename Parent::Value Value;
    162162
    163163    explicit DefaultMap(const Graph& graph) : Parent(graph) {}
    164     DefaultMap(const Graph& graph, const Value& value) 
     164    DefaultMap(const Graph& graph, const Value& value)
    165165      : Parent(graph, value) {}
    166166
  • lemon/bits/graph_extender.h

    r125 r209  
    1 /* -*- C++ -*-
     1/* -*- mode: C++; indent-tabs-mode: nil; -*-
    22 *
    3  * This file is a part of LEMON, a generic C++ optimization library
     3 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    55 * Copyright (C) 2003-2008
     
    6767    Node oppositeNode(const Node &node, const Arc &arc) const {
    6868      if (node == Parent::source(arc))
    69         return Parent::target(arc);
     69        return Parent::target(arc);
    7070      else if(node == Parent::target(arc))
    71         return Parent::source(arc);
     71        return Parent::source(arc);
    7272      else
    73         return INVALID;
     73        return INVALID;
    7474    }
    7575
     
    9090      return node_notifier;
    9191    }
    92    
     92
    9393    ArcNotifier& notifier(Arc) const {
    9494      return arc_notifier;
    9595    }
    9696
    97     class NodeIt : public Node { 
     97    class NodeIt : public Node {
    9898      const Digraph* _digraph;
    9999    public:
     
    104104
    105105      explicit NodeIt(const Digraph& digraph) : _digraph(&digraph) {
    106         _digraph->first(static_cast<Node&>(*this));
    107       }
    108 
    109       NodeIt(const Digraph& digraph, const Node& node) 
    110         : Node(node), _digraph(&digraph) {}
    111 
    112       NodeIt& operator++() { 
    113         _digraph->next(*this);
    114         return *this;
    115       }
    116 
    117     };
    118 
    119 
    120     class ArcIt : public Arc { 
     106        _digraph->first(static_cast<Node&>(*this));
     107      }
     108
     109      NodeIt(const Digraph& digraph, const Node& node)
     110        : Node(node), _digraph(&digraph) {}
     111
     112      NodeIt& operator++() {
     113        _digraph->next(*this);
     114        return *this;
     115      }
     116
     117    };
     118
     119
     120    class ArcIt : public Arc {
    121121      const Digraph* _digraph;
    122122    public:
     
    127127
    128128      explicit ArcIt(const Digraph& digraph) : _digraph(&digraph) {
    129         _digraph->first(static_cast<Arc&>(*this));
    130       }
    131 
    132       ArcIt(const Digraph& digraph, const Arc& arc) : 
    133         Arc(arc), _digraph(&digraph) { }
    134 
    135       ArcIt& operator++() { 
    136         _digraph->next(*this);
    137         return *this;
    138       }
    139 
    140     };
    141 
    142 
    143     class OutArcIt : public Arc { 
     129        _digraph->first(static_cast<Arc&>(*this));
     130      }
     131
     132      ArcIt(const Digraph& digraph, const Arc& arc) :
     133        Arc(arc), _digraph(&digraph) { }
     134
     135      ArcIt& operator++() {
     136        _digraph->next(*this);
     137        return *this;
     138      }
     139
     140    };
     141
     142
     143    class OutArcIt : public Arc {
    144144      const Digraph* _digraph;
    145145    public:
     
    149149      OutArcIt(Invalid i) : Arc(i) { }
    150150
    151       OutArcIt(const Digraph& digraph, const Node& node) 
    152         : _digraph(&digraph) {
    153         _digraph->firstOut(*this, node);
    154       }
    155 
    156       OutArcIt(const Digraph& digraph, const Arc& arc) 
    157         : Arc(arc), _digraph(&digraph) {}
    158 
    159       OutArcIt& operator++() { 
    160         _digraph->nextOut(*this);
    161         return *this;
    162       }
    163 
    164     };
    165 
    166 
    167     class InArcIt : public Arc { 
     151      OutArcIt(const Digraph& digraph, const Node& node)
     152        : _digraph(&digraph) {
     153        _digraph->firstOut(*this, node);
     154      }
     155
     156      OutArcIt(const Digraph& digraph, const Arc& arc)
     157        : Arc(arc), _digraph(&digraph) {}
     158
     159      OutArcIt& operator++() {
     160        _digraph->nextOut(*this);
     161        return *this;
     162      }
     163
     164    };
     165
     166
     167    class InArcIt : public Arc {
    168168      const Digraph* _digraph;
    169169    public:
     
    173173      InArcIt(Invalid i) : Arc(i) { }
    174174
    175       InArcIt(const Digraph& digraph, const Node& node) 
    176         : _digraph(&digraph) {
    177         _digraph->firstIn(*this, node);
    178       }
    179 
    180       InArcIt(const Digraph& digraph, const Arc& arc) : 
    181         Arc(arc), _digraph(&digraph) {}
    182 
    183       InArcIt& operator++() { 
    184         _digraph->nextIn(*this);
    185         return *this;
     175      InArcIt(const Digraph& digraph, const Node& node)
     176        : _digraph(&digraph) {
     177        _digraph->firstIn(*this, node);
     178      }
     179
     180      InArcIt(const Digraph& digraph, const Arc& arc) :
     181        Arc(arc), _digraph(&digraph) {}
     182
     183      InArcIt& operator++() {
     184        _digraph->nextIn(*this);
     185        return *this;
    186186      }
    187187
     
    216216    }
    217217
    218    
     218
    219219    template <typename _Value>
    220     class NodeMap 
     220    class NodeMap
    221221      : public MapExtender<DefaultMap<Digraph, Node, _Value> > {
    222222    public:
     
    224224      typedef MapExtender<DefaultMap<Digraph, Node, _Value> > Parent;
    225225
    226       explicit NodeMap(const Digraph& digraph) 
    227         : Parent(digraph) {}
    228       NodeMap(const Digraph& digraph, const _Value& value) 
    229         : Parent(digraph, value) {}
     226      explicit NodeMap(const Digraph& digraph)
     227        : Parent(digraph) {}
     228      NodeMap(const Digraph& digraph, const _Value& value)
     229        : Parent(digraph, value) {}
    230230
    231231      NodeMap& operator=(const NodeMap& cmap) {
    232         return operator=<NodeMap>(cmap);
     232        return operator=<NodeMap>(cmap);
    233233      }
    234234
     
    236236      NodeMap& operator=(const CMap& cmap) {
    237237        Parent::operator=(cmap);
    238         return *this;
     238        return *this;
    239239      }
    240240
     
    242242
    243243    template <typename _Value>
    244     class ArcMap 
     244    class ArcMap
    245245      : public MapExtender<DefaultMap<Digraph, Arc, _Value> > {
    246246    public:
     
    248248      typedef MapExtender<DefaultMap<Digraph, Arc, _Value> > Parent;
    249249
    250       explicit ArcMap(const Digraph& digraph) 
    251         : Parent(digraph) {}
    252       ArcMap(const Digraph& digraph, const _Value& value) 
    253         : Parent(digraph, value) {}
     250      explicit ArcMap(const Digraph& digraph)
     251        : Parent(digraph) {}
     252      ArcMap(const Digraph& digraph, const _Value& value)
     253        : Parent(digraph, value) {}
    254254
    255255      ArcMap& operator=(const ArcMap& cmap) {
    256         return operator=<ArcMap>(cmap);
     256        return operator=<ArcMap>(cmap);
    257257      }
    258258
     
    260260      ArcMap& operator=(const CMap& cmap) {
    261261        Parent::operator=(cmap);
    262         return *this;
     262        return *this;
    263263      }
    264264    };
     
    270270      return node;
    271271    }
    272    
     272
    273273    Arc addArc(const Node& from, const Node& to) {
    274274      Arc arc = Parent::addArc(from, to);
     
    294294      Parent::firstOut(arc, node);
    295295      while (arc != INVALID ) {
    296         erase(arc);
    297         Parent::firstOut(arc, node);
    298       } 
     296        erase(arc);
     297        Parent::firstOut(arc, node);
     298      }
    299299
    300300      Parent::firstIn(arc, node);
    301301      while (arc != INVALID ) {
    302         erase(arc);
    303         Parent::firstIn(arc, node);
     302        erase(arc);
     303        Parent::firstIn(arc, node);
    304304      }
    305305
     
    307307      Parent::erase(node);
    308308    }
    309    
     309
    310310    void erase(const Arc& arc) {
    311311      notifier(Arc()).erase(arc);
     
    316316      node_notifier.setContainer(*this);
    317317      arc_notifier.setContainer(*this);
    318     } 
    319    
     318    }
     319
    320320
    321321    ~DigraphExtender() {
     
    328328  ///
    329329  /// \brief Extender for the Graphs
    330   template <typename Base> 
     330  template <typename Base>
    331331  class GraphExtender : public Base {
    332332  public:
    333    
     333
    334334    typedef Base Parent;
    335335    typedef GraphExtender Graph;
     
    341341    typedef typename Parent::Edge Edge;
    342342
    343     // Graph extension   
     343    // Graph extension
    344344
    345345    int maxId(Node) const {
     
    369369    Node oppositeNode(const Node &n, const Edge &e) const {
    370370      if( n == Parent::u(e))
    371         return Parent::v(e);
     371        return Parent::v(e);
    372372      else if( n == Parent::v(e))
    373         return Parent::u(e);
     373        return Parent::u(e);
    374374      else
    375         return INVALID;
     375        return INVALID;
    376376    }
    377377
     
    403403      return node_notifier;
    404404    }
    405    
     405
    406406    ArcNotifier& notifier(Arc) const {
    407407      return arc_notifier;
     
    414414
    415415
    416     class NodeIt : public Node { 
     416    class NodeIt : public Node {
    417417      const Graph* _graph;
    418418    public:
     
    423423
    424424      explicit NodeIt(const Graph& graph) : _graph(&graph) {
    425         _graph->first(static_cast<Node&>(*this));
    426       }
    427 
    428       NodeIt(const Graph& graph, const Node& node) 
    429         : Node(node), _graph(&graph) {}
    430 
    431       NodeIt& operator++() { 
    432         _graph->next(*this);
    433         return *this;
    434       }
    435 
    436     };
    437 
    438 
    439     class ArcIt : public Arc { 
     425        _graph->first(static_cast<Node&>(*this));
     426      }
     427
     428      NodeIt(const Graph& graph, const Node& node)
     429        : Node(node), _graph(&graph) {}
     430
     431      NodeIt& operator++() {
     432        _graph->next(*this);
     433        return *this;
     434      }
     435
     436    };
     437
     438
     439    class ArcIt : public Arc {
    440440      const Graph* _graph;
    441441    public:
     
    446446
    447447      explicit ArcIt(const Graph& graph) : _graph(&graph) {
    448         _graph->first(static_cast<Arc&>(*this));
    449       }
    450 
    451       ArcIt(const Graph& graph, const Arc& arc) : 
    452         Arc(arc), _graph(&graph) { }
    453 
    454       ArcIt& operator++() { 
    455         _graph->next(*this);
    456         return *this;
    457       }
    458 
    459     };
    460 
    461 
    462     class OutArcIt : public Arc { 
     448        _graph->first(static_cast<Arc&>(*this));
     449      }
     450
     451      ArcIt(const Graph& graph, const Arc& arc) :
     452        Arc(arc), _graph(&graph) { }
     453
     454      ArcIt& operator++() {
     455        _graph->next(*this);
     456        return *this;
     457      }
     458
     459    };
     460
     461
     462    class OutArcIt : public Arc {
    463463      const Graph* _graph;
    464464    public:
     
    468468      OutArcIt(Invalid i) : Arc(i) { }
    469469
    470       OutArcIt(const Graph& graph, const Node& node) 
    471         : _graph(&graph) {
    472         _graph->firstOut(*this, node);
    473       }
    474 
    475       OutArcIt(const Graph& graph, const Arc& arc) 
    476         : Arc(arc), _graph(&graph) {}
    477 
    478       OutArcIt& operator++() { 
    479         _graph->nextOut(*this);
    480         return *this;
    481       }
    482 
    483     };
    484 
    485 
    486     class InArcIt : public Arc { 
     470      OutArcIt(const Graph& graph, const Node& node)
     471        : _graph(&graph) {
     472        _graph->firstOut(*this, node);
     473      }
     474
     475      OutArcIt(const Graph& graph, const Arc& arc)
     476        : Arc(arc), _graph(&graph) {}
     477
     478      OutArcIt& operator++() {
     479        _graph->nextOut(*this);
     480        return *this;
     481      }
     482
     483    };
     484
     485
     486    class InArcIt : public Arc {
    487487      const Graph* _graph;
    488488    public:
     
    492492      InArcIt(Invalid i) : Arc(i) { }
    493493
    494       InArcIt(const Graph& graph, const Node& node) 
    495         : _graph(&graph) {
    496         _graph->firstIn(*this, node);
    497       }
    498 
    499       InArcIt(const Graph& graph, const Arc& arc) : 
    500         Arc(arc), _graph(&graph) {}
    501 
    502       InArcIt& operator++() { 
    503         _graph->nextIn(*this);
    504         return *this;
    505       }
    506 
    507     };
    508 
    509 
    510     class EdgeIt : public Parent::Edge { 
     494      InArcIt(const Graph& graph, const Node& node)
     495        : _graph(&graph) {
     496        _graph->firstIn(*this, node);
     497      }
     498
     499      InArcIt(const Graph& graph, const Arc& arc) :
     500        Arc(arc), _graph(&graph) {}
     501
     502      InArcIt& operator++() {
     503        _graph->nextIn(*this);
     504        return *this;
     505      }
     506
     507    };
     508
     509
     510    class EdgeIt : public Parent::Edge {
    511511      const Graph* _graph;
    512512    public:
     
    517517
    518518      explicit EdgeIt(const Graph& graph) : _graph(&graph) {
    519         _graph->first(static_cast<Edge&>(*this));
    520       }
    521 
    522       EdgeIt(const Graph& graph, const Edge& edge) : 
    523         Edge(edge), _graph(&graph) { }
    524 
    525       EdgeIt& operator++() { 
    526         _graph->next(*this);
    527         return *this;
     519        _graph->first(static_cast<Edge&>(*this));
     520      }
     521
     522      EdgeIt(const Graph& graph, const Edge& edge) :
     523        Edge(edge), _graph(&graph) { }
     524
     525      EdgeIt& operator++() {
     526        _graph->next(*this);
     527        return *this;
    528528      }
    529529
     
    541541
    542542      IncEdgeIt(const Graph& graph, const Node &node) : _graph(&graph) {
    543         _graph->firstInc(*this, _direction, node);
     543        _graph->firstInc(*this, _direction, node);
    544544      }
    545545
    546546      IncEdgeIt(const Graph& graph, const Edge &edge, const Node &node)
    547         : _graph(&graph), Edge(edge) {
    548         _direction = (_graph->source(edge) == node);
     547        : _graph(&graph), Edge(edge) {
     548        _direction = (_graph->source(edge) == node);
    549549      }
    550550
    551551      IncEdgeIt& operator++() {
    552         _graph->nextInc(*this, _direction);
    553         return *this;
     552        _graph->nextInc(*this, _direction);
     553        return *this;
    554554      }
    555555    };
     
    599599
    600600    template <typename _Value>
    601     class NodeMap 
     601    class NodeMap
    602602      : public MapExtender<DefaultMap<Graph, Node, _Value> > {
    603603    public:
     
    605605      typedef MapExtender<DefaultMap<Graph, Node, _Value> > Parent;
    606606
    607       NodeMap(const Graph& graph) 
    608         : Parent(graph) {}
    609       NodeMap(const Graph& graph, const _Value& value) 
    610         : Parent(graph, value) {}
     607      NodeMap(const Graph& graph)
     608        : Parent(graph) {}
     609      NodeMap(const Graph& graph, const _Value& value)
     610        : Parent(graph, value) {}
    611611
    612612      NodeMap& operator=(const NodeMap& cmap) {
    613         return operator=<NodeMap>(cmap);
     613        return operator=<NodeMap>(cmap);
    614614      }
    615615
     
    617617      NodeMap& operator=(const CMap& cmap) {
    618618        Parent::operator=(cmap);
    619         return *this;
     619        return *this;
    620620      }
    621621
     
    623623
    624624    template <typename _Value>
    625     class ArcMap 
     625    class ArcMap
    626626      : public MapExtender<DefaultMap<Graph, Arc, _Value> > {
    627627    public:
     
    629629      typedef MapExtender<DefaultMap<Graph, Arc, _Value> > Parent;
    630630
    631       ArcMap(const Graph& graph) 
    632         : Parent(graph) {}
    633       ArcMap(const Graph& graph, const _Value& value) 
    634         : Parent(graph, value) {}
     631      ArcMap(const Graph& graph)
     632        : Parent(graph) {}
     633      ArcMap(const Graph& graph, const _Value& value)
     634        : Parent(graph, value) {}
    635635
    636636      ArcMap& operator=(const ArcMap& cmap) {
    637         return operator=<ArcMap>(cmap);
     637        return operator=<ArcMap>(cmap);
    638638      }
    639639
     
    641641      ArcMap& operator=(const CMap& cmap) {
    642642        Parent::operator=(cmap);
    643         return *this;
     643        return *this;
    644644      }
    645645    };
     
    647647
    648648    template <typename _Value>
    649     class EdgeMap 
     649    class EdgeMap
    650650      : public MapExtender<DefaultMap<Graph, Edge, _Value> > {
    651651    public:
     
    653653      typedef MapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
    654654
    655       EdgeMap(const Graph& graph) 
    656         : Parent(graph) {}
    657 
    658       EdgeMap(const Graph& graph, const _Value& value) 
    659         : Parent(graph, value) {}
     655      EdgeMap(const Graph& graph)
     656        : Parent(graph) {}
     657
     658      EdgeMap(const Graph& graph, const _Value& value)
     659        : Parent(graph, value) {}
    660660
    661661      EdgeMap& operator=(const EdgeMap& cmap) {
    662         return operator=<EdgeMap>(cmap);
     662        return operator=<EdgeMap>(cmap);
    663663      }
    664664
     
    666666      EdgeMap& operator=(const CMap& cmap) {
    667667        Parent::operator=(cmap);
    668         return *this;
     668        return *this;
    669669      }
    670670
     
    684684      std::vector<Arc> ev;
    685685      ev.push_back(Parent::direct(edge, true));
    686       ev.push_back(Parent::direct(edge, false));     
     686      ev.push_back(Parent::direct(edge, false));
    687687      notifier(Arc()).add(ev);
    688688      return edge;
    689689    }
    690    
     690
    691691    void clear() {
    692692      notifier(Arc()).clear();
     
    697697
    698698    template <typename Graph, typename NodeRefMap, typename EdgeRefMap>
    699     void build(const Graph& graph, NodeRefMap& nodeRef, 
     699    void build(const Graph& graph, NodeRefMap& nodeRef,
    700700               EdgeRefMap& edgeRef) {
    701701      Parent::build(graph, nodeRef, edgeRef);
     
    709709      Parent::firstOut(arc, node);
    710710      while (arc != INVALID ) {
    711         erase(arc);
    712         Parent::firstOut(arc, node);
    713       } 
     711        erase(arc);
     712        Parent::firstOut(arc, node);
     713      }
    714714
    715715      Parent::firstIn(arc, node);
    716716      while (arc != INVALID ) {
    717         erase(arc);
    718         Parent::firstIn(arc, node);
     717        erase(arc);
     718        Parent::firstIn(arc, node);
    719719      }
    720720
     
    726726      std::vector<Arc> av;
    727727      av.push_back(Parent::direct(edge, true));
    728       av.push_back(Parent::direct(edge, false));     
     728      av.push_back(Parent::direct(edge, false));
    729729      notifier(Arc()).erase(av);
    730730      notifier(Edge()).erase(edge);
     
    733733
    734734    GraphExtender() {
    735       node_notifier.setContainer(*this); 
     735      node_notifier.setContainer(*this);
    736736      arc_notifier.setContainer(*this);
    737737      edge_notifier.setContainer(*this);
    738     } 
     738    }
    739739
    740740    ~GraphExtender() {
    741741      edge_notifier.clear();
    742742      arc_notifier.clear();
    743       node_notifier.clear(); 
    744     } 
     743      node_notifier.clear();
     744    }
    745745
    746746  };
  • lemon/bits/invalid.h

    r49 r209  
    1 /* -*- C++ -*-
     1/* -*- mode: C++; indent-tabs-mode: nil; -*-
    22 *
    3  * This file is a part of LEMON, a generic C++ optimization library
     3 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    55 * Copyright (C) 2003-2008
     
    3535    bool operator< (Invalid) { return false; }
    3636  };
    37  
     37
    3838  /// \brief Invalid iterators.
    3939  ///
     
    5353
    5454#endif
    55  
     55
  • lemon/bits/map_extender.h

    r107 r209  
    1 /* -*- C++ -*-
    2  *
    3  * This file is a part of LEMON, a generic C++ optimization library
     1/* -*- mode: C++; indent-tabs-mode: nil; -*-
     2 *
     3 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    55 * Copyright (C) 2003-2008
     
    3333
    3434  /// \ingroup graphbits
    35   /// 
     35  ///
    3636  /// \brief Extender for maps
    3737  template <typename _Map>
     
    5757  public:
    5858
    59     MapExtender(const Graph& graph) 
     59    MapExtender(const Graph& graph)
    6060      : Parent(graph) {}
    6161
    62     MapExtender(const Graph& graph, const Value& value) 
     62    MapExtender(const Graph& graph, const Value& value)
    6363      : Parent(graph, value) {}
    6464
     
    7171      Parent::operator=(cmap);
    7272      return *this;
    73     } 
     73    }
    7474
    7575    class MapIt : public Item {
    7676    public:
    77      
     77
    7878      typedef Item Parent;
    7979      typedef typename Map::Value Value;
    80      
     80
    8181      MapIt() {}
    8282
     
    8787      }
    8888
    89       MapIt(const Map& _map, const Item& item) 
    90         : Parent(item), map(_map) {}
    91 
    92       MapIt& operator++() { 
    93         map.notifier()->next(*this);
    94         return *this;
    95       }
    96      
     89      MapIt(const Map& _map, const Item& item)
     90        : Parent(item), map(_map) {}
     91
     92      MapIt& operator++() {
     93        map.notifier()->next(*this);
     94        return *this;
     95      }
     96
    9797      typename MapTraits<Map>::ConstReturnValue operator*() const {
    98         return map[*this];
     98        return map[*this];
    9999      }
    100100
    101101      typename MapTraits<Map>::ReturnValue operator*() {
    102         return map[*this];
    103       }
    104      
     102        return map[*this];
     103      }
     104
    105105      void set(const Value& value) {
    106         map.set(*this, value);
    107       }
    108      
     106        map.set(*this, value);
     107      }
     108
    109109    protected:
    110110      Map& map;
    111      
     111
    112112    };
    113113
     
    118118
    119119      typedef typename Map::Value Value;
    120      
     120
    121121      ConstMapIt() {}
    122122
     
    127127      }
    128128
    129       ConstMapIt(const Map& _map, const Item& item) 
    130         : Parent(item), map(_map) {}
    131 
    132       ConstMapIt& operator++() { 
    133         map.notifier()->next(*this);
    134         return *this;
     129      ConstMapIt(const Map& _map, const Item& item)
     130        : Parent(item), map(_map) {}
     131
     132      ConstMapIt& operator++() {
     133        map.notifier()->next(*this);
     134        return *this;
    135135      }
    136136
    137137      typename MapTraits<Map>::ConstReturnValue operator*() const {
    138         return map[*this];
     138        return map[*this];
    139139      }
    140140
     
    145145    class ItemIt : public Item {
    146146    public:
    147      
    148       typedef Item Parent;
    149      
     147
     148      typedef Item Parent;
     149
    150150      ItemIt() {}
    151151
     
    156156      }
    157157
    158       ItemIt(const Map& _map, const Item& item) 
    159         : Parent(item), map(_map) {}
    160 
    161       ItemIt& operator++() { 
    162         map.notifier()->next(*this);
    163         return *this;
     158      ItemIt(const Map& _map, const Item& item)
     159        : Parent(item), map(_map) {}
     160
     161      ItemIt& operator++() {
     162        map.notifier()->next(*this);
     163        return *this;
    164164      }
    165165
    166166    protected:
    167167      const Map& map;
    168      
     168
    169169    };
    170170  };
    171171
    172172  /// \ingroup graphbits
    173   /// 
     173  ///
    174174  /// \brief Extender for maps which use a subset of the items.
    175175  template <typename _Graph, typename _Map>
     
    195195  public:
    196196
    197     SubMapExtender(const Graph& _graph) 
     197    SubMapExtender(const Graph& _graph)
    198198      : Parent(_graph), graph(_graph) {}
    199199
    200     SubMapExtender(const Graph& _graph, const Value& _value) 
     200    SubMapExtender(const Graph& _graph, const Value& _value)
    201201      : Parent(_graph, _value), graph(_graph) {}
    202202
     
    213213      }
    214214      return *this;
    215     } 
     215    }
    216216
    217217    class MapIt : public Item {
    218218    public:
    219      
     219
    220220      typedef Item Parent;
    221221      typedef typename Map::Value Value;
    222      
     222
    223223      MapIt() {}
    224224
     
    229229      }
    230230
    231       MapIt(const Map& _map, const Item& item) 
    232         : Parent(item), map(_map) {}
    233 
    234       MapIt& operator++() { 
    235         map.graph.next(*this);
    236         return *this;
    237       }
    238      
     231      MapIt(const Map& _map, const Item& item)
     232        : Parent(item), map(_map) {}
     233
     234      MapIt& operator++() {
     235        map.graph.next(*this);
     236        return *this;
     237      }
     238
    239239      typename MapTraits<Map>::ConstReturnValue operator*() const {
    240         return map[*this];
     240        return map[*this];
    241241      }
    242242
    243243      typename MapTraits<Map>::ReturnValue operator*() {
    244         return map[*this];
    245       }
    246      
     244        return map[*this];
     245      }
     246
    247247      void set(const Value& value) {
    248         map.set(*this, value);
    249       }
    250      
     248        map.set(*this, value);
     249      }
     250
    251251    protected:
    252252      Map& map;
    253      
     253
    254254    };
    255255
     
    260260
    261261      typedef typename Map::Value Value;
    262      
     262
    263263      ConstMapIt() {}
    264264
     
    269269      }
    270270
    271       ConstMapIt(const Map& _map, const Item& item) 
    272         : Parent(item), map(_map) {}
    273 
    274       ConstMapIt& operator++() { 
    275         map.graph.next(*this);
    276         return *this;
     271      ConstMapIt(const Map& _map, const Item& item)
     272        : Parent(item), map(_map) {}
     273
     274      ConstMapIt& operator++() {
     275        map.graph.next(*this);
     276        return *this;
    277277      }
    278278
    279279      typename MapTraits<Map>::ConstReturnValue operator*() const {
    280         return map[*this];
     280        return map[*this];
    281281      }
    282282
     
    287287    class ItemIt : public Item {
    288288    public:
    289      
    290       typedef Item Parent;
    291      
     289
     290      typedef Item Parent;
     291
    292292      ItemIt() {}
    293293
     
    298298      }
    299299
    300       ItemIt(const Map& _map, const Item& item) 
    301         : Parent(item), map(_map) {}
    302 
    303       ItemIt& operator++() { 
    304         map.graph.next(*this);
    305         return *this;
     300      ItemIt(const Map& _map, const Item& item)
     301        : Parent(item), map(_map) {}
     302
     303      ItemIt& operator++() {
     304        map.graph.next(*this);
     305        return *this;
    306306      }
    307307
    308308    protected:
    309309      const Map& map;
    310      
    311     };
    312    
     310
     311    };
     312
    313313  private:
    314314
    315315    const Graph& graph;
    316    
     316
    317317  };
    318318
  • lemon/bits/path_dump.h

    r100 r209  
    1 /* -*- C++ -*-
     1/* -*- mode: C++; indent-tabs-mode: nil; -*-
    22 *
    3  * This file is a part of LEMON, a generic C++ optimization library
     3 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    55 * Copyright (C) 2003-2008
     
    5454      RevArcIt() {}
    5555      RevArcIt(Invalid) : path(0), current(INVALID) {}
    56       RevArcIt(const PredMapPath& _path) 
     56      RevArcIt(const PredMapPath& _path)
    5757        : path(&_path), current(_path.target) {
    5858        if (path->predMap[current] == INVALID) current = INVALID;
     
    6969      }
    7070
    71       bool operator==(const RevArcIt& e) const { 
    72         return current == e.current; 
     71      bool operator==(const RevArcIt& e) const {
     72        return current == e.current;
    7373      }
    7474
    7575      bool operator!=(const RevArcIt& e) const {
    76         return current != e.current; 
     76        return current != e.current;
    7777      }
    7878
    79       bool operator<(const RevArcIt& e) const { 
    80         return current < e.current; 
     79      bool operator<(const RevArcIt& e) const {
     80        return current < e.current;
    8181      }
    82      
     82
    8383    private:
    8484      const PredMapPath* path;
     
    102102    typedef _PredMatrixMap PredMatrixMap;
    103103
    104     PredMatrixMapPath(const Digraph& _digraph, 
     104    PredMatrixMapPath(const Digraph& _digraph,
    105105                      const PredMatrixMap& _predMatrixMap,
    106                       typename Digraph::Node _source, 
     106                      typename Digraph::Node _source,
    107107                      typename Digraph::Node _target)
    108       : digraph(_digraph), predMatrixMap(_predMatrixMap), 
     108      : digraph(_digraph), predMatrixMap(_predMatrixMap),
    109109        source(_source), target(_target) {}
    110110
     
    128128      RevArcIt() {}
    129129      RevArcIt(Invalid) : path(0), current(INVALID) {}
    130       RevArcIt(const PredMatrixMapPath& _path) 
     130      RevArcIt(const PredMatrixMapPath& _path)
    131131        : path(&_path), current(_path.target) {
    132         if (path->predMatrixMap(path->source, current) == INVALID) 
     132        if (path->predMatrixMap(path->source, current) == INVALID)
    133133          current = INVALID;
    134134      }
     
    139139
    140140      RevArcIt& operator++() {
    141         current = 
     141        current =
    142142          path->digraph.source(path->predMatrixMap(path->source, current));
    143         if (path->predMatrixMap(path->source, current) == INVALID) 
     143        if (path->predMatrixMap(path->source, current) == INVALID)
    144144          current = INVALID;
    145145        return *this;
    146146      }
    147147
    148       bool operator==(const RevArcIt& e) const { 
    149         return current == e.current; 
     148      bool operator==(const RevArcIt& e) const {
     149        return current == e.current;
    150150      }
    151151
    152152      bool operator!=(const RevArcIt& e) const {
    153         return current != e.current; 
     153        return current != e.current;
    154154      }
    155155
    156       bool operator<(const RevArcIt& e) const { 
    157         return current < e.current; 
     156      bool operator<(const RevArcIt& e) const {
     157        return current < e.current;
    158158      }
    159      
     159
    160160    private:
    161161      const PredMatrixMapPath* path;
  • lemon/bits/traits.h

    r184 r209  
    1 
    2 /* -*- C++ -*-
    3  *
    4  * This file is a part of LEMON, a generic C++ optimization library
     1/* -*- mode: C++; indent-tabs-mode: nil; -*-
     2 *
     3 * This file is a part of LEMON, a generic C++ optimization library.
    54 *
    65 * Copyright (C) 2003-2008
     
    3029  template <typename _Graph, typename _Item>
    3130  class ItemSetTraits {};
    32  
     31
    3332
    3433  template <typename Graph, typename Enable = void>
     
    3837  template <typename Graph>
    3938  struct NodeNotifierIndicator<
    40     Graph, 
     39    Graph,
    4140    typename enable_if<typename Graph::NodeNotifier::Notifier, void>::type
    42   > { 
     41  > {
    4342    typedef typename Graph::NodeNotifier Type;
    4443  };
     
    4746  class ItemSetTraits<_Graph, typename _Graph::Node> {
    4847  public:
    49    
     48
    5049    typedef _Graph Graph;
    5150
     
    5857    class Map : public Graph::template NodeMap<_Value> {
    5958    public:
    60       typedef typename Graph::template NodeMap<_Value> Parent; 
    61       typedef typename Graph::template NodeMap<_Value> Type; 
     59      typedef typename Graph::template NodeMap<_Value> Parent;
     60      typedef typename Graph::template NodeMap<_Value> Type;
    6261      typedef typename Parent::Value Value;
    6362
    6463      Map(const Graph& _digraph) : Parent(_digraph) {}
    65       Map(const Graph& _digraph, const Value& _value) 
    66         : Parent(_digraph, _value) {}
     64      Map(const Graph& _digraph, const Value& _value)
     65        : Parent(_digraph, _value) {}
    6766
    6867     };
     
    7675  template <typename Graph>
    7776  struct ArcNotifierIndicator<
    78     Graph, 
     77    Graph,
    7978    typename enable_if<typename Graph::ArcNotifier::Notifier, void>::type
    80   > { 
     79  > {
    8180    typedef typename Graph::ArcNotifier Type;
    8281  };
     
    8584  class ItemSetTraits<_Graph, typename _Graph::Arc> {
    8685  public:
    87    
     86
    8887    typedef _Graph Graph;
    8988
     
    9695    class Map : public Graph::template ArcMap<_Value> {
    9796    public:
    98       typedef typename Graph::template ArcMap<_Value> Parent; 
    99       typedef typename Graph::template ArcMap<_Value> Type; 
     97      typedef typename Graph::template ArcMap<_Value> Parent;
     98      typedef typename Graph::template ArcMap<_Value> Type;
    10099      typedef typename Parent::Value Value;
    101100
    102101      Map(const Graph& _digraph) : Parent(_digraph) {}
    103       Map(const Graph& _digraph, const Value& _value) 
    104         : Parent(_digraph, _value) {}
     102      Map(const Graph& _digraph, const Value& _value)
     103        : Parent(_digraph, _value) {}
    105104    };
    106105
     
    113112  template <typename Graph>
    114113  struct EdgeNotifierIndicator<
    115     Graph, 
     114    Graph,
    116115    typename enable_if<typename Graph::EdgeNotifier::Notifier, void>::type
    117   > { 
     116  > {
    118117    typedef typename Graph::EdgeNotifier Type;
    119118  };
     
    122121  class ItemSetTraits<_Graph, typename _Graph::Edge> {
    123122  public:
    124    
     123
    125124    typedef _Graph Graph;
    126125
     
    133132    class Map : public Graph::template EdgeMap<_Value> {
    134133    public:
    135       typedef typename Graph::template EdgeMap<_Value> Parent; 
    136       typedef typename Graph::template EdgeMap<_Value> Type; 
     134      typedef typename Graph::template EdgeMap<_Value> Parent;
     135      typedef typename Graph::template EdgeMap<_Value> Type;
    137136      typedef typename Parent::Value Value;
    138137
    139138      Map(const Graph& _digraph) : Parent(_digraph) {}
    140       Map(const Graph& _digraph, const Value& _value) 
    141         : Parent(_digraph, _value) {}
     139      Map(const Graph& _digraph, const Value& _value)
     140        : Parent(_digraph, _value) {}
    142141    };
    143142
     
    157156  template <typename Map>
    158157  struct MapTraits<
    159     Map, typename enable_if<typename Map::ReferenceMapTag, void>::type > 
     158    Map, typename enable_if<typename Map::ReferenceMapTag, void>::type >
    160159  {
    161160    typedef True ReferenceMapTag;
    162    
     161
    163162    typedef typename Map::Key Key;
    164163    typedef typename Map::Value Value;
     
    167166    typedef typename Map::Reference ReturnValue;
    168167
    169     typedef typename Map::ConstReference ConstReference; 
     168    typedef typename Map::ConstReference ConstReference;
    170169    typedef typename Map::Reference Reference;
    171170 };
     
    185184  template <typename MatrixMap>
    186185  struct MatrixMapTraits<
    187     MatrixMap, typename enable_if<typename MatrixMap::ReferenceMapTag, 
    188                                   void>::type > 
     186    MatrixMap, typename enable_if<typename MatrixMap::ReferenceMapTag,
     187                                  void>::type >
    189188  {
    190189    typedef True ReferenceMapTag;
    191    
     190
    192191    typedef typename MatrixMap::FirstKey FirstKey;
    193192    typedef typename MatrixMap::SecondKey SecondKey;
     
    197196    typedef typename MatrixMap::Reference ReturnValue;
    198197
    199     typedef typename MatrixMap::ConstReference ConstReference; 
     198    typedef typename MatrixMap::ConstReference ConstReference;
    200199    typedef typename MatrixMap::Reference Reference;
    201200 };
     
    210209  template <typename Graph>
    211210  struct NodeNumTagIndicator<
    212     Graph, 
     211    Graph,
    213212    typename enable_if<typename Graph::NodeNumTag, void>::type
    214213  > {
     
    223222  template <typename Graph>
    224223  struct EdgeNumTagIndicator<
    225     Graph, 
     224    Graph,
    226225    typename enable_if<typename Graph::EdgeNumTag, void>::type
    227226  > {
     
    236235  template <typename Graph>
    237236  struct FindEdgeTagIndicator<
    238     Graph, 
     237    Graph,
    239238    typename enable_if<typename Graph::FindEdgeTag, void>::type
    240239  > {
     
    249248  template <typename Graph>
    250249  struct UndirectedTagIndicator<
    251     Graph, 
     250    Graph,
    252251    typename enable_if<typename Graph::UndirectedTag, void>::type
    253252  > {
     
    262261  template <typename Graph>
    263262  struct BuildTagIndicator<
    264     Graph, 
     263    Graph,
    265264    typename enable_if<typename Graph::BuildTag, void>::type
    266265  > {
  • lemon/bits/utility.h

    r117 r209  
    1 /* -*- C++ -*-
     1/* -*- mode: C++; indent-tabs-mode: nil; -*-
    22 *
    3  * This file is a part of LEMON, a generic C++ optimization library
     3 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    55 * Copyright (C) 2003-2008
     
    8484
    8585  /**************** enable_if from BOOST ****************/
    86  
     86
    8787  template <typename Type, typename T = void>
    8888  struct exists {
     
    9090  };
    9191
    92  
     92
    9393  template <bool B, class T = void>
    9494  struct enable_if_c {
     
    9999  struct enable_if_c<false, T> {};
    100100
    101   template <class Cond, class T = void> 
     101  template <class Cond, class T = void>
    102102  struct enable_if : public enable_if_c<Cond::value, T> {};
    103103
     
    110110  struct lazy_enable_if_c<false, T> {};
    111111
    112   template <class Cond, class T> 
     112  template <class Cond, class T>
    113113  struct lazy_enable_if : public lazy_enable_if_c<Cond::value, T> {};
    114114
     
    122122  struct disable_if_c<true, T> {};
    123123
    124   template <class Cond, class T = void> 
     124  template <class Cond, class T = void>
    125125  struct disable_if : public disable_if_c<Cond::value, T> {};
    126126
     
    133133  struct lazy_disable_if_c<true, T> {};
    134134
    135   template <class Cond, class T> 
     135  template <class Cond, class T>
    136136  struct lazy_disable_if : public lazy_disable_if_c<Cond::value, T> {};
    137137
  • lemon/bits/vector_map.h

    r157 r209  
    1 /* -*- C++ -*-
    2  *
    3  * This file is a part of LEMON, a generic C++ optimization library
     1/* -*- mode: C++; indent-tabs-mode: nil; -*-
     2 *
     3 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    55 * Copyright (C) 2003-2008
     
    5050  /// \todo Fix the doc: there is _Graph parameter instead of _Notifier.
    5151  template <typename _Graph, typename _Item, typename _Value>
    52   class VectorMap 
     52  class VectorMap
    5353    : public ItemSetTraits<_Graph, _Item>::ItemNotifier::ObserverBase {
    5454  private:
    55                
     55
    5656    /// The container type of the map.
    57     typedef std::vector<_Value> Container;     
     57    typedef std::vector<_Value> Container;
    5858
    5959  public:
    6060
    61     /// The graph type of the map. 
     61    /// The graph type of the map.
    6262    typedef _Graph Graph;
    6363    /// The item type of the map.
     
    9494    }
    9595
    96     /// \brief Constructor uses given value to initialize the map. 
    97     ///
    98     /// It constructs a map uses a given value to initialize the map. 
     96    /// \brief Constructor uses given value to initialize the map.
     97    ///
     98    /// It constructs a map uses a given value to initialize the map.
    9999    /// It adds all the items of the graph to the map.
    100100    VectorMap(const Graph& graph, const Value& value) {
     
    108108    VectorMap(const VectorMap& _copy) : Parent() {
    109109      if (_copy.attached()) {
    110         Parent::attach(*_copy.notifier());
    111         container = _copy.container;
     110        Parent::attach(*_copy.notifier());
     111        container = _copy.container;
    112112      }
    113113    }
     
    116116    ///
    117117    /// This operator assigns for each item in the map the
    118     /// value mapped to the same item in the copied map. 
     118    /// value mapped to the same item in the copied map.
    119119    /// The parameter map should be indiced with the same
    120120    /// itemset because this assign operator does not change
    121     /// the container of the map. 
     121    /// the container of the map.
    122122    VectorMap& operator=(const VectorMap& cmap) {
    123123      return operator=<VectorMap>(cmap);
     
    130130    /// concecpt and could be indiced by the current item set of
    131131    /// the NodeMap. In this case the value for each item
    132     /// is assigned by the value of the given ReadMap. 
     132    /// is assigned by the value of the given ReadMap.
    133133    template <typename CMap>
    134134    VectorMap& operator=(const CMap& cmap) {
     
    141141      return *this;
    142142    }
    143    
     143
    144144  public:
    145145
     
    147147    ///
    148148    /// The subscript operator. The map can be subscripted by the
    149     /// actual items of the graph.     
     149    /// actual items of the graph.
    150150    Reference operator[](const Key& key) {
    151151      return container[Parent::notifier()->id(key)];
    152     } 
    153                
     152    }
     153
    154154    /// \brief The const subcript operator.
    155155    ///
    156156    /// The const subscript operator. The map can be subscripted by the
    157     /// actual items of the graph. 
     157    /// actual items of the graph.
    158158    ConstReference operator[](const Key& key) const {
    159159      return container[Parent::notifier()->id(key)];
     
    171171
    172172    /// \brief Adds a new key to the map.
    173     ///         
     173    ///
    174174    /// It adds a new key to the map. It called by the observer notifier
    175     /// and it overrides the add() member function of the observer base.     
     175    /// and it overrides the add() member function of the observer base.
    176176    virtual void add(const Key& key) {
    177177      int id = Parent::notifier()->id(key);
    178178      if (id >= int(container.size())) {
    179         container.resize(id + 1);
     179        container.resize(id + 1);
    180180      }
    181181    }
    182182
    183183    /// \brief Adds more new keys to the map.
    184     ///         
     184    ///
    185185    /// It adds more new keys to the map. It called by the observer notifier
    186     /// and it overrides the add() member function of the observer base.     
     186    /// and it overrides the add() member function of the observer base.
    187187    virtual void add(const std::vector<Key>& keys) {
    188188      int max = container.size() - 1;
     
    199199    ///
    200200    /// Erase a key from the map. It called by the observer notifier
    201     /// and it overrides the erase() member function of the observer base.     
     201    /// and it overrides the erase() member function of the observer base.
    202202    virtual void erase(const Key& key) {
    203203      container[Parent::notifier()->id(key)] = Value();
     
    207207    ///
    208208    /// Erase more keys from the map. It called by the observer notifier
    209     /// and it overrides the erase() member function of the observer base.     
     209    /// and it overrides the erase() member function of the observer base.
    210210    virtual void erase(const std::vector<Key>& keys) {
    211211      for (int i = 0; i < int(keys.size()); ++i) {
    212         container[Parent::notifier()->id(keys[i])] = Value();
    213       }
    214     }
    215    
     212        container[Parent::notifier()->id(keys[i])] = Value();
     213      }
     214    }
     215
    216216    /// \brief Buildes the map.
    217     /// 
     217    ///
    218218    /// It buildes the map. It called by the observer notifier
    219219    /// and it overrides the build() member function of the observer base.
    220     virtual void build() { 
     220    virtual void build() {
    221221      int size = Parent::notifier()->maxId() + 1;
    222222      container.reserve(size);
     
    227227    ///
    228228    /// It erase all items from the map. It called by the observer notifier
    229     /// and it overrides the clear() member function of the observer base.     
    230     virtual void clear() { 
     229    /// and it overrides the clear() member function of the observer base.
     230    virtual void clear() {
    231231      container.clear();
    232232    }
    233    
     233
    234234  private:
    235                
     235
    236236    Container container;
    237237
Note: See TracChangeset for help on using the changeset viewer.