COIN-OR::LEMON - Graph Library

Changeset 897:ef09eee53b09 in lemon-0.x


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.

Location:
src/hugo
Files:
9 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) {
  • src/hugo/default_map.h

    r891 r897  
    3838typedef typename MapRegistry::Graph Graph; \
    3939\
    40 DefaultMap() : Parent() {} \
    4140DefaultMap(const Graph& g, MapRegistry& r) : Parent(g, r) {} \
    4241DefaultMap(const Graph& g, MapRegistry& r, const Value& v) \
     
    4544  : Parent(static_cast<const Parent&>(copy)) {} \
    4645template <typename TT> \
    47 DefaultMap(const DefaultMap<MapRegistry, TT>& copy) { \
     46DefaultMap(const DefaultMap<MapRegistry, TT>& copy) \
     47  : { \
    4848  Parent::MapBase::operator= \
    4949    (static_cast<const typename Parent::MapBase&>(copy)); \
     
    6161template <typename TT> \
    6262DefaultMap& operator=(const DefaultMap<MapRegistry, TT>& copy) { \
    63   Parent::clear(); \
    64   Parent::MapBase::operator=(copy); \
     63  if (Parent::getGraph() != copy.getGraph()) { \
     64    Parent::clear(); \
     65    Parent::MapBase::operator=(copy); \
     66    Parent::construct(); \
     67  } \
    6568  if (Parent::getGraph()) { \
    6669    for (typename Parent::KeyIt it(*Parent::getGraph()); it!=INVALID; ++it) {\
    67       Parent::add(it); \
    6870      Parent::operator[](it) = copy[it]; \
    6971    } \
  • src/hugo/extended_pair.h

    r782 r897  
    3737bool operator<(const extended_pair<T1, LA1, T2, LA2>& left,
    3838                const extended_pair<T1, RA1, T2, RA2>& right) {
    39   if (left.first == right.first) return left.second == right.second;
    40   return left.first < right.first;
     39  return left.first < right.first ||
     40           (!(right.first<left.first) && left.second < right.second);
    4141}
    4242
  • src/hugo/full_graph.h

    r880 r897  
    1414
    1515#include <hugo/map_registry.h>
    16 #include <hugo/default_map.h>
     16#include <hugo/array_map.h>
    1717
    1818#include <hugo/map_defines.h>
     
    5454    CREATE_MAP_REGISTRIES;
    5555    /// Creating node and edge maps.
    56     CREATE_MAPS(DefaultMap);
     56    CREATE_MAPS(ArrayMap);
    5757   
    5858  public:
  • src/hugo/list_graph.h

    r891 r897  
    1414
    1515#include <hugo/map_registry.h>
    16 #include <hugo/default_map.h>
     16#include <hugo/array_map.h>
    1717
    1818#include <hugo/sym_map.h>
     
    8181    /// \todo
    8282    /// It apears in the documentation as if it were a function definition.
    83     CREATE_MAPS(DefaultMap);
     83    CREATE_MAPS(ArrayMap);
    8484
    8585  public:
     
    446446    CREATE_SYM_EDGE_MAP_REGISTRY;
    447447    /// Creating symmetric edge map.
    448     CREATE_SYM_EDGE_MAP(DefaultMap);
     448    CREATE_SYM_EDGE_MAP(ArrayMap);
    449449
    450450    SymListGraph() : ListGraph() { }
     
    531531    CREATE_NODE_MAP_REGISTRY;
    532532    /// Creating node maps.
    533     CREATE_NODE_MAP(DefaultMap);
     533    CREATE_NODE_MAP(ArrayMap);
    534534
    535535    /// Creating empty map structure for edges.
     
    537537    class EdgeMap {
    538538    public:
    539       EdgeMap() {}
    540539      EdgeMap(const Graph&) {}
    541540      EdgeMap(const Graph&, const Value&) {}
     
    883882    CREATE_EDGE_MAP_REGISTRY;
    884883    /// Creates edge maps.
    885     CREATE_EDGE_MAP(DefaultMap);
     884    CREATE_EDGE_MAP(ArrayMap);
    886885
    887886    /// Imports node maps from the NodeGraphType.
  • src/hugo/map_defines.h

    r891 r897  
    4141public: \
    4242typedef DynMap<NodeMapRegistry, Value> Parent; \
    43 NodeMap() {} \
    4443NodeMap(const typename Parent::Graph& g) \
    4544  : Parent(g, g.node_maps) {} \
     
    7372typedef DynMap<EdgeMapRegistry, Value> Parent; \
    7473\
    75 EdgeMap() {} \
    7674EdgeMap(const typename Parent::Graph& g) \
    7775  : Parent(g, g.edge_maps) {} \
     
    119117typedef SymMap<DynMap, SymEdgeMapRegistry, Value> Parent; \
    120118\
    121 SymEdgeMap() {} \
    122119SymEdgeMap(const typename Parent::Graph& g) \
    123120  : Parent(g, g.sym_edge_maps) {} \
     
    149146typedef typename From::template NodeMap<Value> Parent; \
    150147\
    151 NodeMap() : Parent() {} \
    152148NodeMap(const To& to) \
    153149  : Parent(static_cast<const From&>(from)) { } \
     
    179175typedef typename From::template EdgeMap<Value> Parent; \
    180176\
    181 EdgeMap() : Parent() {} \
    182177EdgeMap(const To& to) \
    183178  : Parent(static_cast<const From&>(from)) { } \
  • src/hugo/smart_graph.h

    r891 r897  
    1313#include <hugo/invalid.h>
    1414
    15 #include <hugo/default_map.h>
     15#include <hugo/array_map.h>
    1616#include <hugo/sym_map.h>
    1717
     
    7777    CREATE_MAP_REGISTRIES;
    7878    /// Creating node and edge maps.
    79     CREATE_MAPS(DefaultMap);
     79    CREATE_MAPS(ArrayMap);
    8080   
    8181  public:
     
    321321    CREATE_SYM_EDGE_MAP_REGISTRY;
    322322    /// Creating symmetric edge map.
    323     CREATE_SYM_EDGE_MAP(DefaultMap);
     323    CREATE_SYM_EDGE_MAP(ArrayMap);
    324324
    325325
  • src/hugo/sym_map.h

    r891 r897  
    8686
    8787
    88     /** Default constructor for the map.
    89      */
    90     SymMap() : MapImpl() {}
    91 
    9288    /** Graph and Registry initialized map constructor.
    9389     */
  • src/hugo/vector_map.h

    r891 r897  
    7070    typedef typename Container::const_pointer ConstPointerType;
    7171
    72     /** Default constructor for the map.
    73      */
    74     VectorMap() {}
    75                
    7672    /** Graph and Registry initialized map constructor.
    7773     */
     
    9995    template <typename TT>
    10096    VectorMap& operator=(const VectorMap<MapRegistry, TT>& c) {
    101       container.resize(c.container.size());
    102       MapBase::operator=(c);
     97      if (MapBase::getGraph() != c.getGraph()) {
     98        MapBase::operator=(c);
     99        container.resize(c.container.size());
     100      }
    103101      for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
    104102        int id = KeyInfo<Graph, KeyIt>::id(*MapBase::getGraph(), it);
Note: See TracChangeset for help on using the changeset viewer.