lemon/bits/default_map.h
author deba
Mon, 21 Nov 2005 18:12:11 +0000
changeset 1824 3a15b39a7c78
parent 1703 eb90e3d6bddc
child 1842 8abf74160dc4
permissions -rw-r--r--
Erasing old header
Correcting makefile
alpar@906
     1
/* -*- C++ -*-
ladanyi@1435
     2
 * lemon/default_map.h - Part of LEMON, a generic C++ optimization library
alpar@906
     3
 *
alpar@1164
     4
 * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@1359
     5
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
alpar@906
     6
 *
alpar@906
     7
 * Permission to use, modify and distribute this software is granted
alpar@906
     8
 * provided that this copyright notice appears in all copies. For
alpar@906
     9
 * precise terms see the accompanying LICENSE file.
alpar@906
    10
 *
alpar@906
    11
 * This software is provided "AS IS" with no warranty of any kind,
alpar@906
    12
 * express or implied, and with no claim as to its suitability for any
alpar@906
    13
 * purpose.
alpar@906
    14
 *
alpar@906
    15
 */
alpar@906
    16
alpar@921
    17
#ifndef LEMON_DEFAULT_MAP_H
alpar@921
    18
#define LEMON_DEFAULT_MAP_H
deba@822
    19
deba@822
    20
deba@1307
    21
#include <lemon/bits/array_map.h>
deba@1307
    22
#include <lemon/bits/vector_map.h>
deba@822
    23
alpar@1587
    24
///\ingroup graphmapfactory
deba@822
    25
///\file
klao@946
    26
///\brief Graph maps that construct and destruct
deba@822
    27
///their elements dynamically.
deba@822
    28
alpar@921
    29
namespace lemon {
deba@822
    30
deba@822
    31
deba@1267
    32
  template <typename _Graph, typename _Item, typename _Value>
klao@946
    33
  struct DefaultMapSelector {
deba@1267
    34
    typedef ArrayMap<_Graph, _Item, _Value> Map;
klao@946
    35
  };
deba@822
    36
klao@946
    37
  // bool
deba@1267
    38
  template <typename _Graph, typename _Item>
deba@1267
    39
  struct DefaultMapSelector<_Graph, _Item, bool> {
deba@980
    40
    typedef VectorMap<_Graph, _Item, bool> Map;
klao@946
    41
  };
deba@822
    42
klao@946
    43
  // char
deba@1267
    44
  template <typename _Graph, typename _Item>
deba@1267
    45
  struct DefaultMapSelector<_Graph, _Item, char> {
deba@980
    46
    typedef VectorMap<_Graph, _Item, char> Map;
klao@946
    47
  };
deba@822
    48
deba@1267
    49
  template <typename _Graph, typename _Item>
deba@1267
    50
  struct DefaultMapSelector<_Graph, _Item, signed char> {
deba@980
    51
    typedef VectorMap<_Graph, _Item, signed char> Map;
klao@946
    52
  };
deba@822
    53
deba@1267
    54
  template <typename _Graph, typename _Item>
deba@1267
    55
  struct DefaultMapSelector<_Graph, _Item, unsigned char> {
deba@980
    56
    typedef VectorMap<_Graph, _Item, unsigned char> Map;
klao@946
    57
  };
deba@822
    58
deba@822
    59
klao@946
    60
  // int
deba@1267
    61
  template <typename _Graph, typename _Item>
deba@1267
    62
  struct DefaultMapSelector<_Graph, _Item, signed int> {
deba@980
    63
    typedef VectorMap<_Graph, _Item, signed int> Map;
klao@946
    64
  };
deba@822
    65
deba@1267
    66
  template <typename _Graph, typename _Item>
deba@1267
    67
  struct DefaultMapSelector<_Graph, _Item, unsigned int> {
deba@980
    68
    typedef VectorMap<_Graph, _Item, unsigned int> Map;
klao@946
    69
  };
deba@822
    70
deba@822
    71
klao@946
    72
  // short
deba@1267
    73
  template <typename _Graph, typename _Item>
deba@1267
    74
  struct DefaultMapSelector<_Graph, _Item, signed short> {
deba@980
    75
    typedef VectorMap<_Graph, _Item, signed short> Map;
klao@946
    76
  };
deba@822
    77
deba@1267
    78
  template <typename _Graph, typename _Item>
deba@1267
    79
  struct DefaultMapSelector<_Graph, _Item, unsigned short> {
deba@980
    80
    typedef VectorMap<_Graph, _Item, unsigned short> Map;
klao@946
    81
  };
klao@946
    82
klao@946
    83
klao@946
    84
  // long
deba@1267
    85
  template <typename _Graph, typename _Item>
deba@1267
    86
  struct DefaultMapSelector<_Graph, _Item, signed long> {
deba@980
    87
    typedef VectorMap<_Graph, _Item, signed long> Map;
klao@946
    88
  };
klao@946
    89
deba@1267
    90
  template <typename _Graph, typename _Item>
deba@1267
    91
  struct DefaultMapSelector<_Graph, _Item, unsigned long> {
deba@980
    92
    typedef VectorMap<_Graph, _Item, unsigned long> Map;
klao@946
    93
  };
klao@946
    94
klao@946
    95
  // \todo handling long long type
klao@946
    96
klao@946
    97
klao@946
    98
  // float
deba@1267
    99
  template <typename _Graph, typename _Item>
deba@1267
   100
  struct DefaultMapSelector<_Graph, _Item, float> {
deba@980
   101
    typedef VectorMap<_Graph, _Item, float> Map;
klao@946
   102
  };
klao@946
   103
klao@946
   104
klao@946
   105
  // double
deba@1267
   106
  template <typename _Graph, typename _Item>
deba@1267
   107
  struct DefaultMapSelector<_Graph, _Item, double> {
deba@980
   108
    typedef VectorMap<_Graph, _Item,  double> Map;
klao@946
   109
  };
klao@946
   110
klao@946
   111
klao@946
   112
  // long double
deba@1267
   113
  template <typename _Graph, typename _Item>
deba@1267
   114
  struct DefaultMapSelector<_Graph, _Item, long double> {
deba@980
   115
    typedef VectorMap<_Graph, _Item, long double> Map;
klao@946
   116
  };
klao@946
   117
klao@946
   118
klao@946
   119
  // pointer
deba@1267
   120
  template <typename _Graph, typename _Item, typename _Ptr>
deba@1267
   121
  struct DefaultMapSelector<_Graph, _Item, _Ptr*> {
deba@980
   122
    typedef VectorMap<_Graph, _Item, _Ptr*> Map;
klao@946
   123
  };
klao@946
   124
deba@1669
   125
  /// \e
deba@1267
   126
  template <
deba@1267
   127
    typename _Graph, 
deba@1267
   128
    typename _Item,
deba@1267
   129
    typename _Value>
deba@1267
   130
  class DefaultMap 
deba@1267
   131
    : public DefaultMapSelector<_Graph, _Item, _Value>::Map {
klao@946
   132
  public:
deba@1267
   133
    typedef typename DefaultMapSelector<_Graph, _Item, _Value>::Map Parent;
deba@1267
   134
    typedef DefaultMap<_Graph, _Item, _Value> Map;
klao@946
   135
    
klao@946
   136
    typedef typename Parent::Graph Graph;
alpar@987
   137
    typedef typename Parent::Value Value;
klao@946
   138
deba@980
   139
    DefaultMap(const Graph& _g) : Parent(_g) {}
alpar@987
   140
    DefaultMap(const Graph& _g, const Value& _v) : Parent(_g, _v) {}
deba@1669
   141
klao@946
   142
  };
klao@946
   143
klao@946
   144
deba@1669
   145
  /// \e
klao@946
   146
  template <typename _Base> 
deba@1669
   147
  class MappableGraphExtender : public _Base {
klao@946
   148
  public:
klao@946
   149
deba@1669
   150
    typedef MappableGraphExtender<_Base> Graph;
klao@946
   151
    typedef _Base Parent;
klao@946
   152
klao@946
   153
    typedef typename Parent::Node Node;
klao@946
   154
    typedef typename Parent::NodeIt NodeIt;
klao@946
   155
klao@946
   156
    typedef typename Parent::Edge Edge;
klao@946
   157
    typedef typename Parent::EdgeIt EdgeIt;
klao@946
   158
klao@946
   159
    
klao@946
   160
    template <typename _Value>
deba@1267
   161
    class NodeMap 
deba@1267
   162
      : public IterableMapExtender<DefaultMap<Graph, Node, _Value> > {
klao@946
   163
    public:
deba@1669
   164
      typedef MappableGraphExtender Graph;
deba@1267
   165
      typedef IterableMapExtender<DefaultMap<Graph, Node, _Value> > Parent;
klao@946
   166
deba@980
   167
      NodeMap(const Graph& _g) 
deba@980
   168
	: Parent(_g) {}
klao@1022
   169
      NodeMap(const Graph& _g, const _Value& _v) 
deba@980
   170
	: Parent(_g, _v) {}
deba@1669
   171
deba@1672
   172
      NodeMap& operator=(const NodeMap& cmap) {
deba@1672
   173
	return operator=<NodeMap>(cmap);
deba@1672
   174
      }
deba@1672
   175
deba@1672
   176
deba@1669
   177
      /// \brief Template assign operator.
deba@1669
   178
      ///
deba@1669
   179
      /// The given parameter should be conform to the ReadMap
deba@1669
   180
      /// concecpt and could be indiced by the current item set of
deba@1669
   181
      /// the NodeMap. In this case the value for each item
deba@1669
   182
      /// is assigned by the value of the given ReadMap. 
deba@1669
   183
      template <typename CMap>
deba@1669
   184
      NodeMap& operator=(const CMap& cmap) {
deba@1669
   185
	checkConcept<concept::ReadMap<Node, _Value>, CMap>();
deba@1669
   186
	const typename Parent::Graph* graph = Parent::getGraph();
deba@1669
   187
	Node it;
deba@1669
   188
	for (graph->first(it); it != INVALID; graph->next(it)) {
deba@1669
   189
	  Parent::set(it, cmap[it]);
deba@1669
   190
	}
deba@1669
   191
	return *this;
deba@1669
   192
      }
deba@1669
   193
klao@946
   194
    };
klao@946
   195
klao@946
   196
    template <typename _Value>
deba@1267
   197
    class EdgeMap 
deba@1267
   198
      : public IterableMapExtender<DefaultMap<Graph, Edge, _Value> > {
klao@946
   199
    public:
deba@1669
   200
      typedef MappableGraphExtender Graph;
deba@1267
   201
      typedef IterableMapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
klao@946
   202
deba@980
   203
      EdgeMap(const Graph& _g) 
deba@980
   204
	: Parent(_g) {}
klao@1022
   205
      EdgeMap(const Graph& _g, const _Value& _v) 
deba@980
   206
	: Parent(_g, _v) {}
deba@1669
   207
deba@1672
   208
      EdgeMap& operator=(const EdgeMap& cmap) {
deba@1672
   209
	return operator=<EdgeMap>(cmap);
deba@1672
   210
      }
deba@1672
   211
deba@1669
   212
      template <typename CMap>
deba@1669
   213
      EdgeMap& operator=(const CMap& cmap) {
deba@1669
   214
	checkConcept<concept::ReadMap<Edge, _Value>, CMap>();
deba@1669
   215
	const typename Parent::Graph* graph = Parent::getGraph();
deba@1669
   216
	Edge it;
deba@1669
   217
	for (graph->first(it); it != INVALID; graph->next(it)) {
deba@1669
   218
	  Parent::set(it, cmap[it]);
deba@1669
   219
	}
deba@1669
   220
	return *this;
deba@1669
   221
      }
klao@946
   222
    };
klao@946
   223
    
klao@946
   224
  };
klao@946
   225
deba@1669
   226
  /// \e
klao@1022
   227
  template <typename _Base> 
klao@1022
   228
  class MappableUndirGraphExtender : 
deba@1669
   229
    public MappableGraphExtender<_Base> {
klao@1022
   230
  public:
klao@1022
   231
klao@1022
   232
    typedef MappableUndirGraphExtender Graph;
deba@1669
   233
    typedef MappableGraphExtender<_Base> Parent;
klao@1022
   234
klao@1022
   235
    typedef typename Parent::UndirEdge UndirEdge;
klao@1022
   236
klao@1022
   237
    template <typename _Value>
deba@1267
   238
    class UndirEdgeMap 
deba@1267
   239
      : public IterableMapExtender<DefaultMap<Graph, UndirEdge, _Value> > {
klao@1022
   240
    public:
klao@1022
   241
      typedef MappableUndirGraphExtender Graph;
deba@1267
   242
      typedef IterableMapExtender<
deba@1267
   243
	DefaultMap<Graph, UndirEdge, _Value> > Parent;
klao@1022
   244
klao@1022
   245
      UndirEdgeMap(const Graph& _g) 
klao@1022
   246
	: Parent(_g) {}
klao@1022
   247
      UndirEdgeMap(const Graph& _g, const _Value& _v) 
klao@1022
   248
	: Parent(_g, _v) {}
deba@1669
   249
deba@1672
   250
      UndirEdgeMap& operator=(const UndirEdgeMap& cmap) {
deba@1672
   251
	return operator=<UndirEdgeMap>(cmap);
deba@1672
   252
      }
deba@1672
   253
deba@1669
   254
      template <typename CMap>
deba@1669
   255
      UndirEdgeMap& operator=(const CMap& cmap) {
deba@1669
   256
	checkConcept<concept::ReadMap<UndirEdge, _Value>, CMap>();
deba@1669
   257
	const typename Parent::Graph* graph = Parent::getGraph();
deba@1669
   258
	UndirEdge it;
deba@1669
   259
	for (graph->first(it); it != INVALID; graph->next(it)) {
deba@1669
   260
	  Parent::set(it, cmap[it]);
deba@1669
   261
	}
deba@1669
   262
	return *this;
deba@1669
   263
      }
klao@1022
   264
    };
klao@1022
   265
klao@1022
   266
klao@1022
   267
  };
deba@822
   268
deba@1820
   269
deba@1820
   270
  template <typename _Base>
deba@1820
   271
  class MappableUndirBipartiteGraphExtender : public _Base {
deba@1820
   272
  public:
deba@1820
   273
deba@1820
   274
    typedef _Base Parent;
deba@1820
   275
    typedef MappableUndirBipartiteGraphExtender Graph;
deba@1820
   276
deba@1820
   277
    typedef typename Parent::Node Node;
deba@1820
   278
    typedef typename Parent::UpperNode UpperNode;
deba@1820
   279
    typedef typename Parent::LowerNode LowerNode;
deba@1820
   280
    typedef typename Parent::Edge Edge;
deba@1820
   281
    typedef typename Parent::UndirEdge UndirEdge;
deba@1820
   282
    
deba@1820
   283
    template <typename _Value>
deba@1820
   284
    class UpperNodeMap 
deba@1820
   285
      : public IterableMapExtender<DefaultMap<Graph, UpperNode, _Value> > {
deba@1820
   286
    public:
deba@1820
   287
      typedef MappableUndirBipartiteGraphExtender Graph;
deba@1820
   288
      typedef IterableMapExtender<DefaultMap<Graph, UpperNode, _Value> > 
deba@1820
   289
      Parent;
deba@1820
   290
    
deba@1820
   291
      UpperNodeMap(const Graph& _g) 
deba@1820
   292
	: Parent(_g) {}
deba@1820
   293
      UpperNodeMap(const Graph& _g, const _Value& _v) 
deba@1820
   294
	: Parent(_g, _v) {}
deba@1820
   295
    
deba@1820
   296
      UpperNodeMap& operator=(const UpperNodeMap& cmap) {
deba@1820
   297
	return operator=<UpperNodeMap>(cmap);
deba@1820
   298
      }
deba@1820
   299
    
deba@1820
   300
deba@1820
   301
      /// \brief Template assign operator.
deba@1820
   302
      ///
deba@1820
   303
      /// The given parameter should be conform to the ReadMap
deba@1820
   304
      /// concept and could be indiced by the current item set of
deba@1820
   305
      /// the UpperNodeMap. In this case the value for each item
deba@1820
   306
      /// is assigned by the value of the given ReadMap. 
deba@1820
   307
      template <typename CMap>
deba@1820
   308
      UpperNodeMap& operator=(const CMap& cmap) {
deba@1820
   309
	checkConcept<concept::ReadMap<UpperNode, _Value>, CMap>();
deba@1820
   310
	const typename Parent::Graph* graph = Parent::getGraph();
deba@1820
   311
	UpperNode it;
deba@1820
   312
	for (graph->first(it); it != INVALID; graph->next(it)) {
deba@1820
   313
	  Parent::set(it, cmap[it]);
deba@1820
   314
	}
deba@1820
   315
	return *this;
deba@1820
   316
      }
deba@1820
   317
    
deba@1820
   318
    };
deba@1820
   319
deba@1820
   320
    template <typename _Value>
deba@1820
   321
    class LowerNodeMap 
deba@1820
   322
      : public IterableMapExtender<DefaultMap<Graph, LowerNode, _Value> > {
deba@1820
   323
    public:
deba@1820
   324
      typedef MappableUndirBipartiteGraphExtender Graph;
deba@1820
   325
      typedef IterableMapExtender<DefaultMap<Graph, LowerNode, _Value> > 
deba@1820
   326
      Parent;
deba@1820
   327
    
deba@1820
   328
      LowerNodeMap(const Graph& _g) 
deba@1820
   329
	: Parent(_g) {}
deba@1820
   330
      LowerNodeMap(const Graph& _g, const _Value& _v) 
deba@1820
   331
	: Parent(_g, _v) {}
deba@1820
   332
    
deba@1820
   333
      LowerNodeMap& operator=(const LowerNodeMap& cmap) {
deba@1820
   334
	return operator=<LowerNodeMap>(cmap);
deba@1820
   335
      }
deba@1820
   336
    
deba@1820
   337
deba@1820
   338
      /// \brief Template assign operator.
deba@1820
   339
      ///
deba@1820
   340
      /// The given parameter should be conform to the ReadMap
deba@1820
   341
      /// concept and could be indiced by the current item set of
deba@1820
   342
      /// the LowerNodeMap. In this case the value for each item
deba@1820
   343
      /// is assigned by the value of the given ReadMap. 
deba@1820
   344
      template <typename CMap>
deba@1820
   345
      LowerNodeMap& operator=(const CMap& cmap) {
deba@1820
   346
	checkConcept<concept::ReadMap<LowerNode, _Value>, CMap>();
deba@1820
   347
	const typename Parent::Graph* graph = Parent::getGraph();
deba@1820
   348
	LowerNode it;
deba@1820
   349
	for (graph->first(it); it != INVALID; graph->next(it)) {
deba@1820
   350
	  Parent::set(it, cmap[it]);
deba@1820
   351
	}
deba@1820
   352
	return *this;
deba@1820
   353
      }
deba@1820
   354
    
deba@1820
   355
    };
deba@1820
   356
deba@1820
   357
  protected:
deba@1820
   358
deba@1820
   359
    template <typename _Value>
deba@1820
   360
    class NodeMapBase : public Parent::NodeNotifier::ObserverBase {
deba@1820
   361
    public:
deba@1820
   362
      typedef MappableUndirBipartiteGraphExtender Graph;
deba@1820
   363
deba@1820
   364
      typedef Node Key;
deba@1820
   365
      typedef _Value Value;
deba@1820
   366
deba@1820
   367
      /// The reference type of the map;
deba@1820
   368
      typedef typename LowerNodeMap<_Value>::Reference Reference;
deba@1820
   369
      /// The pointer type of the map;
deba@1820
   370
      typedef typename LowerNodeMap<_Value>::Pointer Pointer;
deba@1820
   371
      
deba@1820
   372
      /// The const value type of the map.
deba@1820
   373
      typedef const Value ConstValue;
deba@1820
   374
      /// The const reference type of the map;
deba@1820
   375
      typedef typename LowerNodeMap<_Value>::ConstReference ConstReference;
deba@1820
   376
      /// The pointer type of the map;
deba@1820
   377
      typedef typename LowerNodeMap<_Value>::ConstPointer ConstPointer;
deba@1820
   378
deba@1820
   379
      typedef True ReferenceMapTag;
deba@1820
   380
deba@1820
   381
      NodeMapBase(const Graph& _g) 
deba@1820
   382
	: graph(&_g), lowerMap(_g), upperMap(_g) {
deba@1820
   383
	Parent::NodeNotifier::ObserverBase::attach(_g.getNotifier(Node()));
deba@1820
   384
      }
deba@1820
   385
      NodeMapBase(const Graph& _g, const _Value& _v) 
deba@1820
   386
	: graph(&_g), lowerMap(_g, _v), 
deba@1820
   387
	  upperMap(_g, _v) {
deba@1820
   388
	Parent::NodeNotifier::ObserverBase::attach(_g.getNotifier(Node()));
deba@1820
   389
      }
deba@1820
   390
deba@1820
   391
      virtual ~NodeMapBase() {      
deba@1820
   392
	if (Parent::NodeNotifier::ObserverBase::attached()) {
deba@1820
   393
	  Parent::NodeNotifier::ObserverBase::detach();
deba@1820
   394
	}
deba@1820
   395
      }
deba@1820
   396
    
deba@1820
   397
      ConstReference operator[](const Key& node) const {
deba@1820
   398
	if (Parent::upper(node)) {
deba@1820
   399
	  return upperMap[node];
deba@1820
   400
	} else {
deba@1820
   401
	  return lowerMap[node];
deba@1820
   402
	}
deba@1820
   403
      } 
deba@1820
   404
deba@1820
   405
      Reference operator[](const Key& node) {
deba@1820
   406
	if (Parent::upper(node)) {
deba@1820
   407
	  return upperMap[node];
deba@1820
   408
	} else {
deba@1820
   409
	  return lowerMap[node];
deba@1820
   410
	}
deba@1820
   411
      }
deba@1820
   412
deba@1820
   413
      void set(const Key& node, const Value& value) {
deba@1820
   414
	if (Parent::upper(node)) {
deba@1820
   415
	  upperMap.set(node, value);
deba@1820
   416
	} else {
deba@1820
   417
	  lowerMap.set(node, value);
deba@1820
   418
	}
deba@1820
   419
      }
deba@1820
   420
deba@1820
   421
    protected:
deba@1820
   422
      
deba@1820
   423
      virtual void add(const Node&) {}
deba@1820
   424
      virtual void erase(const Node&) {}
deba@1820
   425
      virtual void clear() {}
deba@1820
   426
      virtual void build() {}
deba@1820
   427
deba@1820
   428
      const Graph* getGraph() const { return graph; }
deba@1820
   429
      
deba@1820
   430
    private:
deba@1820
   431
      const Graph* graph;
deba@1820
   432
      LowerNodeMap<_Value> lowerMap;
deba@1820
   433
      UpperNodeMap<_Value> upperMap;
deba@1820
   434
    };
deba@1820
   435
    
deba@1820
   436
  public:
deba@1820
   437
deba@1820
   438
    template <typename _Value>
deba@1820
   439
    class NodeMap 
deba@1820
   440
      : public IterableMapExtender<NodeMapBase<_Value> > {
deba@1820
   441
    public:
deba@1820
   442
      typedef MappableUndirBipartiteGraphExtender Graph;
deba@1820
   443
      typedef IterableMapExtender< NodeMapBase<_Value> > Parent;
deba@1820
   444
    
deba@1820
   445
      NodeMap(const Graph& _g) 
deba@1820
   446
	: Parent(_g) {}
deba@1820
   447
      NodeMap(const Graph& _g, const _Value& _v) 
deba@1820
   448
	: Parent(_g, _v) {}
deba@1820
   449
    
deba@1820
   450
      NodeMap& operator=(const NodeMap& cmap) {
deba@1820
   451
	return operator=<NodeMap>(cmap);
deba@1820
   452
      }
deba@1820
   453
    
deba@1820
   454
deba@1820
   455
      /// \brief Template assign operator.
deba@1820
   456
      ///
deba@1820
   457
      /// The given parameter should be conform to the ReadMap
deba@1820
   458
      /// concept and could be indiced by the current item set of
deba@1820
   459
      /// the NodeMap. In this case the value for each item
deba@1820
   460
      /// is assigned by the value of the given ReadMap. 
deba@1820
   461
      template <typename CMap>
deba@1820
   462
      NodeMap& operator=(const CMap& cmap) {
deba@1820
   463
	checkConcept<concept::ReadMap<Node, _Value>, CMap>();
deba@1820
   464
	const typename Parent::Graph* graph = Parent::getGraph();
deba@1820
   465
	Node it;
deba@1820
   466
	for (graph->first(it); it != INVALID; graph->next(it)) {
deba@1820
   467
	  Parent::set(it, cmap[it]);
deba@1820
   468
	}
deba@1820
   469
	return *this;
deba@1820
   470
      }
deba@1820
   471
    
deba@1820
   472
    };
deba@1820
   473
deba@1820
   474
deba@1820
   475
deba@1820
   476
    template <typename _Value>
deba@1820
   477
    class EdgeMap 
deba@1820
   478
      : public IterableMapExtender<DefaultMap<Graph, Edge, _Value> > {
deba@1820
   479
    public:
deba@1820
   480
      typedef MappableUndirBipartiteGraphExtender Graph;
deba@1820
   481
      typedef IterableMapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
deba@1820
   482
    
deba@1820
   483
      EdgeMap(const Graph& _g) 
deba@1820
   484
	: Parent(_g) {}
deba@1820
   485
      EdgeMap(const Graph& _g, const _Value& _v) 
deba@1820
   486
	: Parent(_g, _v) {}
deba@1820
   487
    
deba@1820
   488
      EdgeMap& operator=(const EdgeMap& cmap) {
deba@1820
   489
	return operator=<EdgeMap>(cmap);
deba@1820
   490
      }
deba@1820
   491
    
deba@1820
   492
      template <typename CMap>
deba@1820
   493
      EdgeMap& operator=(const CMap& cmap) {
deba@1820
   494
	checkConcept<concept::ReadMap<Edge, _Value>, CMap>();
deba@1820
   495
	const typename Parent::Graph* graph = Parent::getGraph();
deba@1820
   496
	Edge it;
deba@1820
   497
	for (graph->first(it); it != INVALID; graph->next(it)) {
deba@1820
   498
	  Parent::set(it, cmap[it]);
deba@1820
   499
	}
deba@1820
   500
	return *this;
deba@1820
   501
      }
deba@1820
   502
    };
deba@1820
   503
deba@1820
   504
    template <typename _Value>
deba@1820
   505
    class UndirEdgeMap 
deba@1820
   506
      : public IterableMapExtender<DefaultMap<Graph, UndirEdge, _Value> > {
deba@1820
   507
    public:
deba@1820
   508
      typedef MappableUndirBipartiteGraphExtender Graph;
deba@1820
   509
      typedef IterableMapExtender<DefaultMap<Graph, UndirEdge, _Value> > 
deba@1820
   510
      Parent;
deba@1820
   511
    
deba@1820
   512
      UndirEdgeMap(const Graph& _g) 
deba@1820
   513
	: Parent(_g) {}
deba@1820
   514
      UndirEdgeMap(const Graph& _g, const _Value& _v) 
deba@1820
   515
	: Parent(_g, _v) {}
deba@1820
   516
    
deba@1820
   517
      UndirEdgeMap& operator=(const UndirEdgeMap& cmap) {
deba@1820
   518
	return operator=<UndirEdgeMap>(cmap);
deba@1820
   519
      }
deba@1820
   520
    
deba@1820
   521
      template <typename CMap>
deba@1820
   522
      UndirEdgeMap& operator=(const CMap& cmap) {
deba@1820
   523
	checkConcept<concept::ReadMap<UndirEdge, _Value>, CMap>();
deba@1820
   524
	const typename Parent::Graph* graph = Parent::getGraph();
deba@1820
   525
	UndirEdge it;
deba@1820
   526
	for (graph->first(it); it != INVALID; graph->next(it)) {
deba@1820
   527
	  Parent::set(it, cmap[it]);
deba@1820
   528
	}
deba@1820
   529
	return *this;
deba@1820
   530
      }
deba@1820
   531
    };
deba@1820
   532
  
deba@1820
   533
  };
deba@1820
   534
deba@822
   535
}
deba@822
   536
deba@822
   537
#endif