COIN-OR::LEMON - Graph Library

Changeset 897:ef09eee53b09 in lemon-0.x for src/hugo/array_map.h


Ignore:
Timestamp:
09/22/04 10:04:31 (20 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1205
Message:

The default constructors are removed from the maps.
The ArrayMap? is the map structure of the graphs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/hugo/array_map.h

    r891 r897  
    3030  template <typename MapRegistry, typename Value>
    3131  class ArrayMap : public MapRegistry::MapBase {
     32
     33    template <typename MR, typename V> friend class ArrayMap;
    3234               
    3335  public:
     
    6466
    6567       
    66     /** Default constructor for the map.
    67      */
    68     ArrayMap() : capacity(0), values(0) {}
    69                        
    7068    /** Graph and Registry initialized map constructor.
    7169     */
     
    119117    ArrayMap& operator=(const ArrayMap& copy) {
    120118      if (&copy == this) return *this;
    121 
    122       if (capacity != 0) {
    123         MapBase::destroy();
    124         allocator.deallocate(values, capacity);
    125       }
    126 
    127       MapBase::operator=(copy);
    128 
    129       capacity = copy.capacity;
    130       if (capacity == 0) return *this;
    131       values = allocator.allocate(capacity);
     119     
     120      if (MapBase::getGraph() != copy.getGraph()) {
     121        if (capacity != 0) {
     122          MapBase::destroy();
     123          allocator.deallocate(values, capacity);
     124        }
     125
     126        MapBase::operator=(copy);
     127        capacity = copy.capacity;
     128        if (capacity == 0) return *this;
     129        values = allocator.allocate(capacity);     
     130      }
    132131
    133132      for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
     
    143142    template <typename TT>
    144143    ArrayMap& operator=(const ArrayMap<MapRegistry, TT>& copy) {
    145       if (capacity != 0) {
    146         MapBase::destroy();
    147         allocator.deallocate(values, capacity);
    148       }
    149 
    150       MapBase::operator=(copy);
    151 
    152       capacity = copy.capacity;
    153       if (capacity == 0) return *this;
    154       values = allocator.allocate(capacity);
     144
     145      if (MapBase::getGraph() != copy.getGraph()) {
     146        if (capacity != 0) {
     147          MapBase::destroy();
     148          allocator.deallocate(values, capacity);
     149        }
     150
     151        MapBase::operator=(copy);
     152
     153        capacity = copy.capacity;
     154        if (capacity == 0) return *this;
     155        values = allocator.allocate(capacity);
     156      }
    155157
    156158      for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
Note: See TracChangeset for help on using the changeset viewer.