COIN-OR::LEMON - Graph Library

Changeset 51:90201bb15a8d in lemon


Ignore:
Timestamp:
01/08/08 20:26:48 (17 years ago)
Author:
Alpar Juttner <alpar@…>
Branch:
default
Parents:
50:a34c58ff6e40 (diff), 48:93ae269876de (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Phase:
public
Message:

Merge

Location:
lemon
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • lemon/concepts/maps.h

    r48 r51  
    33 * This file is a part of LEMON, a generic C++ optimization library
    44 *
    5  * Copyright (C) 2003-2007
     5 * Copyright (C) 2003-2008
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • lemon/concepts/maps.h

    r39 r51  
    4949      /// Returns the value associated with a key.
    5050
     51      /// Returns the value associated with a key.
    5152      /// \bug Value shouldn't need to be default constructible.
    5253      ///
     
    114115    };
    115116
    116     /// Read/Writable map concept
     117    /// Read/writable map concept
    117118   
    118119    /// Read/writable map concept.
     
    147148    /// Dereferable map concept.
    148149    ///
     150    /// \todo Rethink this concept.
    149151    template<typename K, typename T, typename R, typename CR>
    150152    class ReferenceMap : public ReadWriteMap<K,T>
     
    166168    public:
    167169
    168       ///Returns a reference to the value associated to a key.
     170      ///Returns a reference to the value associated with a key.
    169171      Reference operator[](const Key &) { return tmp; }
    170       ///Returns a const reference to the value associated to a key.
     172      ///Returns a const reference to the value associated with a key.
    171173      ConstReference operator[](const Key &) const { return tmp; }
    172174      /// Sets the value associated with a key.
    173175      void set(const Key &k,const Value &t) { operator[](k)=t; }
    174176
    175       /// \todo Rethink this concept.
    176177      template<typename _ReferenceMap>
    177178      struct ReferenceMapConcept {
  • lemon/maps.h

    r47 r51  
    33 * This file is a part of LEMON, a generic C++ optimization library
    44 *
    5  * Copyright (C) 2003-2007
     5 * Copyright (C) 2003-2008
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    173173
    174174    typedef MapBase<K, T> Parent;
    175     ///\e
    176     typedef typename Parent::Key Key;
    177     ///\e
    178     typedef typename Parent::Value Value;
    179     ///\e
     175    ///Key type
     176    typedef typename Parent::Key Key;
     177    ///Value type
     178    typedef typename Parent::Value Value;
     179    ///Reference Type
    180180    typedef T& Reference;
    181     ///\e
     181    ///Const reference type
    182182    typedef const T& ConstReference;
    183183
  • lemon/maps.h

    r44 r51  
    8282  /// Constant map.
    8383
    84   /// This is a readable map which assigns a specified value to each key.
    85   /// In other aspects it is equivalent to the \c NullMap.
     84  /// This is a \ref concepts::ReadMap "readable" map which assigns a
     85  /// specified value to each key.
     86  /// In other aspects it is equivalent to \c NullMap.
    8687  template<typename K, typename T>
    8788  class ConstMap : public MapBase<K, T> {
     
    134135  /// Constant map with inlined constant value.
    135136
    136   /// This is a readable map which assigns a specified value to each key.
    137   /// In other aspects it is equivalent to the \c NullMap.
     137  /// This is a \ref concepts::ReadMap "readable" map which assigns a
     138  /// specified value to each key.
     139  /// In other aspects it is equivalent to \c NullMap.
    138140  template<typename K, typename V, V v>
    139141  class ConstMap<K, Const<V, v> > : public MapBase<K, V> {
     
    150152  };
    151153
    152   ///Returns a \c ConstMap class
     154  ///Returns a \c ConstMap class with inlined value
    153155
    154156  ///This function just returns a \c ConstMap class with inlined value.
     
    159161  }
    160162
    161   ///Map based on std::map
     163  ///Map based on \c std::map
    162164
    163165  ///This is essentially a wrapper for \c std::map with addition that
    164166  ///you can specify a default value different from \c Value().
     167  ///It meets the \ref concepts::ReferenceMap "ReferenceMap" concept.
    165168  template <typename K, typename T, typename Compare = std::less<K> >
    166   class StdMap {
     169  class StdMap : public MapBase<K, T> {
    167170    template <typename K1, typename T1, typename C1>
    168171    friend class StdMap;
    169172  public:
    170173
    171     typedef True ReferenceMapTag;
     174    typedef MapBase<K, T> Parent;
    172175    ///Key type
    173     typedef K Key;
     176    typedef typename Parent::Key Key;
    174177    ///Value type
    175     typedef T Value;
     178    typedef typename Parent::Value Value;
    176179    ///Reference Type
    177180    typedef T& Reference;
    178181    ///Const reference type
    179182    typedef const T& ConstReference;
     183
     184    typedef True ReferenceMapTag;
    180185
    181186  private:
     
    189194    /// Constructor with specified default value
    190195    StdMap(const T& value = T()) : _value(value) {}
    191     /// \brief Constructs the map from an appropriate std::map, and explicitly
    192     /// specifies a default value.
     196    /// \brief Constructs the map from an appropriate \c std::map, and
     197    /// explicitly specifies a default value.
    193198    template <typename T1, typename Comp1>
    194199    StdMap(const std::map<Key, T1, Comp1> &map, const T& value = T())
    195200      : _map(map.begin(), map.end()), _value(value) {}
    196201   
    197     /// \brief Constructs a map from an other StdMap.
     202    /// \brief Constructs a map from an other \ref StdMap.
    198203    template<typename T1, typename Comp1>
    199204    StdMap(const StdMap<Key, T1, Comp1> &c)
     
    240245
    241246  };
     247 
     248  ///Returns a \c StdMap class
     249
     250  ///This function just returns a \c StdMap class with specified
     251  ///default value.
     252  ///\relates StdMap
     253  template<typename K, typename V, typename Compare = std::less<K> >
     254  inline StdMap<K, V, Compare> stdMap(const V& value = V()) {
     255    return StdMap<K, V, Compare>(value);
     256  }
     257
     258  ///Returns a \c StdMap class created from an appropriate std::map
     259
     260  ///This function just returns a \c StdMap class created from an
     261  ///appropriate std::map.
     262  ///\relates StdMap
     263  template<typename K, typename V, typename Compare = std::less<K> >
     264  inline StdMap<K, V, Compare> stdMap( const std::map<K, V, Compare> &map,
     265                                       const V& value = V() ) {
     266    return StdMap<K, V, Compare>(map, value);
     267  }
    242268
    243269  /// \brief Map for storing values for keys from the range <tt>[0..size-1]</tt>
    244270  ///
    245   /// The current map has the <tt>[0..size-1]</tt> keyset and the values
     271  /// This map has the <tt>[0..size-1]</tt> keyset and the values
    246272  /// are stored in a \c std::vector<T>  container. It can be used with
    247273  /// some data structures, for example \c UnionFind, \c BinHeap, when
    248   /// the used items are small integer numbers.
     274  /// the used items are small integer numbers.
     275  /// This map meets the \ref concepts::ReferenceMap "ReferenceMap" concept.
    249276  ///
    250277  /// \todo Revise its name
    251278  template <typename T>
    252   class IntegerMap {
     279  class IntegerMap : public MapBase<int, T> {
    253280
    254281    template <typename T1>
     
    257284  public:
    258285
     286    typedef MapBase<int, T> Parent;
     287    ///\e
     288    typedef typename Parent::Key Key;
     289    ///\e
     290    typedef typename Parent::Value Value;
     291    ///\e
     292    typedef T& Reference;
     293    ///\e
     294    typedef const T& ConstReference;
     295
    259296    typedef True ReferenceMapTag;
    260     ///\e
    261     typedef int Key;
    262     ///\e
    263     typedef T Value;
    264     ///\e
    265     typedef T& Reference;
    266     ///\e
    267     typedef const T& ConstReference;
    268297
    269298  private:
     
    277306    IntegerMap(int size = 0, const T& value = T()) : _vector(size, value) {}
    278307
    279     /// \brief Constructs the map from an appropriate std::vector.
     308    /// \brief Constructs the map from an appropriate \c std::vector.
    280309    template <typename T1>
    281310    IntegerMap(const std::vector<T1>& vector)
    282311      : _vector(vector.begin(), vector.end()) {}
    283312   
    284     /// \brief Constructs a map from an other IntegerMap.
     313    /// \brief Constructs a map from an other \ref IntegerMap.
    285314    template <typename T1>
    286315    IntegerMap(const IntegerMap<T1> &c)
     
    314343
    315344  };
     345 
     346  ///Returns an \c IntegerMap class
     347
     348  ///This function just returns an \c IntegerMap class.
     349  ///\relates IntegerMap
     350  template<typename T>
     351  inline IntegerMap<T> integerMap(int size = 0, const T& value = T()) {
     352    return IntegerMap<T>(size, value);
     353  }
    316354
    317355  /// @}
     
    350388  ///the default conversion.
    351389  ///
    352   ///This \c concepts::ReadMap "read only map"
     390  ///This \ref concepts::ReadMap "read only map"
    353391  ///converts the \c Value of a map to type \c T.
    354392  ///Its \c Key is inherited from \c M.
     
    367405    ConvertMap(const M &_m) : m(_m) {};
    368406
    369     /// \brief The subscript operator.
    370     ///
    371     /// The subscript operator.
     407    ///\e
    372408    Value operator[](const Key& k) const {return m[k];}
    373409  };
     
    406442    Value operator[](Key k) const {return m[k];}
    407443  };
     444 
     445  ///Returns a \c SimpleMap class
     446
     447  ///This function just returns a \c SimpleMap class.
     448  ///\relates SimpleMap
     449  template<typename M>
     450  inline SimpleMap<M> simpleMap(const M &m) {
     451    return SimpleMap<M>(m);
     452  }
    408453
    409454  ///Simple writable wrapping of a map
    410455
    411   ///This \ref concepts::WriteMap "write map" returns the simple
     456  ///This \ref concepts::ReadWriteMap "read-write map" returns the simple
    412457  ///wrapping of the given map. Sometimes the reference maps cannot be
    413458  ///combined with simple read-write maps. This map adaptor wraps the
     
    434479  };
    435480
     481  ///Returns a \c SimpleWriteMap class
     482
     483  ///This function just returns a \c SimpleWriteMap class.
     484  ///\relates SimpleWriteMap
     485  template<typename M>
     486  inline SimpleWriteMap<M> simpleWriteMap(M &m) {
     487    return SimpleWriteMap<M>(m);
     488  }
     489
    436490  ///Sum of two maps
    437491
    438   ///This \c concepts::ReadMap "read only map" returns the sum of the two
     492  ///This \ref concepts::ReadMap "read only map" returns the sum of the two
    439493  ///given maps.
    440494  ///Its \c Key and \c Value are inherited from \c M1.
    441   ///The \c Key and \c Value of M2 must be convertible to those of \c M1.
     495  ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
    442496  template<typename M1, typename M2>
    443497  class AddMap : public MapBase<typename M1::Key, typename M1::Value> {
     
    459513
    460514  ///This function just returns an \c AddMap class.
    461   ///\todo How to call these type of functions?
     515  ///\todo Extend the documentation: how to call these type of functions?
    462516  ///
    463517  ///\relates AddMap
     
    469523  ///Shift a map with a constant.
    470524
    471   ///This \c concepts::ReadMap "read only map" returns the sum of the
     525  ///This \ref concepts::ReadMap "read only map" returns the sum of the
    472526  ///given map and a constant value.
    473527  ///Its \c Key and \c Value are inherited from \c M.
     
    505559  ///Shift a map with a constant (ReadWrite version).
    506560
    507   ///This \c concepts::ReadWriteMap "read-write map" returns the sum of the
     561  ///This \ref concepts::ReadWriteMap "read-write map" returns the sum of the
    508562  ///given map and a constant value. It makes also possible to write the map.
    509563  ///Its \c Key and \c Value are inherited from \c M.
     
    551605  ///Difference of two maps
    552606
    553   ///This \c concepts::ReadMap "read only map" returns the difference
     607  ///This \ref concepts::ReadMap "read only map" returns the difference
    554608  ///of the values of the two given maps.
    555609  ///Its \c Key and \c Value are inherited from \c M1.
     
    584638  ///Product of two maps
    585639
    586   ///This \c concepts::ReadMap "read only map" returns the product of the
     640  ///This \ref concepts::ReadMap "read only map" returns the product of the
    587641  ///values of the two given maps.
    588642  ///Its \c Key and \c Value are inherited from \c M1.
     
    614668  ///Scales a map with a constant.
    615669
    616   ///This \c concepts::ReadMap "read only map" returns the value of the
     670  ///This \ref concepts::ReadMap "read only map" returns the value of the
    617671  ///given map multiplied from the left side with a constant value.
    618672  ///Its \c Key and \c Value are inherited from \c M.
     
    650704  ///Scales a map with a constant (ReadWrite version).
    651705
    652   ///This \c concepts::ReadWriteMap "read-write map" returns the value of the
     706  ///This \ref concepts::ReadWriteMap "read-write map" returns the value of the
    653707  ///given map multiplied from the left side with a constant value. It can
    654708  ///also be used as write map if the \c / operator is defined between
     
    698752  ///Quotient of two maps
    699753
    700   ///This \c concepts::ReadMap "read only map" returns the quotient of the
     754  ///This \ref concepts::ReadMap "read only map" returns the quotient of the
    701755  ///values of the two given maps.
    702756  ///Its \c Key and \c Value are inherited from \c M1.
     
    728782  ///Composition of two maps
    729783
    730   ///This \c concepts::ReadMap "read only map" returns the composition of
     784  ///This \ref concepts::ReadMap "read only map" returns the composition of
    731785  ///two given maps.
    732786  ///That is to say, if \c m1 is of type \c M1 and \c m2 is of \c M2,
     
    779833  ///Combine of two maps using an STL (binary) functor.
    780834  ///
    781   ///This \c concepts::ReadMap "read only map" takes two maps and a
     835  ///This \ref concepts::ReadMap "read only map" takes two maps and a
    782836  ///binary functor and returns the composition of the two
    783837  ///given maps unsing the functor.
     
    852906  ///Negative value of a map
    853907
    854   ///This \c concepts::ReadMap "read only map" returns the negative
     908  ///This \ref concepts::ReadMap "read only map" returns the negative
    855909  ///value of the value returned by the given map.
    856910  ///Its \c Key and \c Value are inherited from \c M.
     
    874928  ///Negative value of a map (ReadWrite version)
    875929
    876   ///This \c concepts::ReadWriteMap "read-write map" returns the negative
     930  ///This \ref concepts::ReadWriteMap "read-write map" returns the negative
    877931  ///value of the value returned by the given map.
    878932  ///Its \c Key and \c Value are inherited from \c M.
     
    916970  ///Absolute value of a map
    917971
    918   ///This \c concepts::ReadMap "read only map" returns the absolute value
     972  ///This \ref concepts::ReadMap "read only map" returns the absolute value
    919973  ///of the value returned by the given map.
    920974  ///Its \c Key and \c Value are inherited from \c M.
     
    9501004  ///Converts an STL style functor to a map
    9511005
    952   ///This \c concepts::ReadMap "read only map" returns the value
     1006  ///This \ref concepts::ReadMap "read only map" returns the value
    9531007  ///of a given functor.
    9541008  ///
     
    9561010  ///\c Key and \c Value.
    9571011  ///In most cases they have to be given explicitly because a
    958   ///functor typically does not provide such typedefs.
     1012  ///functor typically does not provide \c argument_type and
     1013  ///\c result_type typedefs.
    9591014  ///
    9601015  ///Parameter \c F is the type of the used functor.
     
    9811036  ///This function just returns a \c FunctorMap class.
    9821037  ///
    983   ///It is specialized for adaptable function classes and
    984   ///C++ functions.
     1038  ///This function is specialized for adaptable binary function
     1039  ///classes and C++ functions.
     1040  ///
    9851041  ///\relates FunctorMap
    9861042  template<typename K, typename V, typename F> inline
     
    10051061
    10061062  ///This class Converts a map to an STL style (unary) functor.
    1007   ///that is it provides an <tt>operator()</tt> to read its values.
     1063  ///That is it provides an <tt>operator()</tt> to read its values.
    10081064  ///
    10091065  ///For the sake of convenience it also works as
    1010   ///a ususal \c concepts::ReadMap "readable map",
     1066  ///a ususal \ref concepts::ReadMap "readable map",
    10111067  ///i.e. <tt>operator[]</tt> and the \c Key and \c Value typedefs also exist.
    10121068  ///
     
    10401096  }
    10411097
    1042   ///Applies all map setting operations to two maps
    1043 
    1044   ///This map has two \c concepts::ReadMap "readable map"
     1098  ///Just readable version of \ref ForkWriteMap
     1099
     1100  ///This map has two \ref concepts::ReadMap "readable map"
    10451101  ///parameters and each read request will be passed just to the
    1046   ///first map. This class is the just readable map type of the ForkWriteMap.
     1102  ///first map. This class is the just readable map type of \c ForkWriteMap.
    10471103  ///
    10481104  ///The \c Key and \c Value are inherited from \c M1.
    1049   ///The \c Key and \c Value of M2 must be convertible from those of \c M1.
     1105  ///The \c Key and \c Value of \c M2 must be convertible from those of \c M1.
    10501106  ///
    10511107  ///\sa ForkWriteMap
     
    10701126  ///Applies all map setting operations to two maps
    10711127
    1072   ///This map has two \c concepts::WriteMap "writable map"
     1128  ///This map has two \ref concepts::WriteMap "writable map"
    10731129  ///parameters and each write request will be passed to both of them.
    1074   ///If \c M1 is also \c concepts::ReadMap "readable",
     1130  ///If \c M1 is also \ref concepts::ReadMap "readable",
    10751131  ///then the read operations will return the
    10761132  ///corresponding values of \c M1.
    10771133  ///
    10781134  ///The \c Key and \c Value are inherited from \c M1.
    1079   ///The \c Key and \c Value of M2 must be convertible from those of \c M1.
     1135  ///The \c Key and \c Value of \c M2 must be convertible from those of \c M1.
    10801136  ///
    10811137  ///\sa ForkMap
     
    11211177  ///Logical 'not' of a map
    11221178 
    1123   ///This bool \c concepts::ReadMap "read only map" returns the
     1179  ///This bool \ref concepts::ReadMap "read only map" returns the
    11241180  ///logical negation of the value returned by the given map.
    1125   ///Its \c Key is inherited from \c M, its Value is \c bool.
     1181  ///Its \c Key is inherited from \c M, its \c Value is \c bool.
    11261182  ///
    11271183  ///\sa NotWriteMap
     
    11421198  ///Logical 'not' of a map (ReadWrie version)
    11431199 
    1144   ///This bool \c concepts::ReadWriteMap "read-write map" returns the
     1200  ///This bool \ref concepts::ReadWriteMap "read-write map" returns the
    11451201  ///logical negation of the value returned by the given map. When it is set,
    11461202  ///the opposite value is set to the original map.
    1147   ///Its \c Key is inherited from \c M, its Value is \c bool.
     1203  ///Its \c Key is inherited from \c M, its \c Value is \c bool.
    11481204  ///
    11491205  ///\sa NotMap
     
    12101266  /// \brief Writable bool map for logging each \c true assigned element
    12111267  ///
    1212   /// Writable bool map for logging each \c true assigned element, i.e it
    1213   /// copies all the keys set to \c true to the given iterator.
     1268  /// A \ref concepts::ReadWriteMap "read-write" bool map for logging
     1269  /// each \c true assigned element, i.e it copies all the keys set
     1270  /// to \c true to the given iterator.
    12141271  ///
    12151272  /// \note The container of the iterator should contain space
    12161273  /// for each element.
    12171274  ///
    1218   /// The following example shows how you can write the edges found by the Prim
    1219   /// algorithm directly
    1220   /// to the standard output.
     1275  /// The following example shows how you can write the edges found by
     1276  /// the \ref Prim algorithm directly to the standard output.
    12211277  ///\code
    12221278  /// typedef IdMap<Graph, Edge> EdgeIdMap;
Note: See TracChangeset for help on using the changeset viewer.