COIN-OR::LEMON - Graph Library

Changeset 1705:3f63d9db307b in lemon-0.x for lemon/maps.h


Ignore:
Timestamp:
10/05/05 15:18:51 (14 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2232
Message:

Removing smart references

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/maps.h

    r1695 r1705  
    3939  /// Base class of maps.
    4040  /// It provides the necessary <tt>typedef</tt>s required by the map concept.
    41   template<typename K, typename T, typename _NeedCopy = False>
     41  template<typename K, typename T>
    4242  class MapBase {
    4343  public:
    44     /// \e
    45     typedef _NeedCopy NeedCopy;
    4644    ///\e
    4745    typedef K Key;
     
    5553  /// or if you have to provide a writable map, but
    5654  /// data written to it will sent to <tt>/dev/null</tt>...
    57   template<typename K, typename T, typename NC = False>
    58   class NullMap : public MapBase<K, T, NC> {
    59   public:
    60     typedef MapBase<K, T, NC> Parent;
     55  template<typename K, typename T>
     56  class NullMap : public MapBase<K, T> {
     57  public:
     58    typedef MapBase<K, T> Parent;
    6159    typedef typename Parent::Key Key;
    6260    typedef typename Parent::Value Value;
     
    6967
    7068  template <typename K, typename V>
    71   NullMap<K, V, True> nullMap() {
    72     return NullMap<K, V, True>();
     69  NullMap<K, V> nullMap() {
     70    return NullMap<K, V>();
    7371  }
    7472
     
    7977  /// In other aspects it is equivalent to the \ref NullMap.
    8078  /// \todo set could be used to set the value.
    81   template<typename K, typename T, typename NC = False>
    82   class ConstMap : public MapBase<K, T, NC> {
     79  template<typename K, typename T>
     80  class ConstMap : public MapBase<K, T> {
    8381  private:
    8482    T v;
    8583  public:
    8684
    87     typedef MapBase<K, T, NC> Parent;
     85    typedef MapBase<K, T> Parent;
    8886    typedef typename Parent::Key Key;
    8987    typedef typename Parent::Value Value;
     
    117115  ///\relates ConstMap
    118116  template<typename K, typename V>
    119   inline ConstMap<K, V, True> constMap(const V &v) {
    120     return ConstMap<K, V, True>(v);
     117  inline ConstMap<K, V> constMap(const V &v) {
     118    return ConstMap<K, V>(v);
    121119  }
    122120
     
    127125
    128126  //\todo to document later
    129   template<typename K, typename V, V v, typename NC>
    130   class ConstMap<K, Const<V, v>, NC > : public MapBase<K, V, NC> {
    131   public:
    132     typedef MapBase<K, V, False> Parent;
     127  template<typename K, typename V, V v>
     128  class ConstMap<K, Const<V, v> > : public MapBase<K, V> {
     129  public:
     130    typedef MapBase<K, V> Parent;
    133131    typedef typename Parent::Key Key;
    134132    typedef typename Parent::Value Value;
     
    144142  ///\relates ConstMap
    145143  template<typename K, typename V, V v>
    146   inline ConstMap<K, Const<V, v>, True> constMap() {
    147     return ConstMap<K, Const<V, v>, True>();
     144  inline ConstMap<K, Const<V, v> > constMap() {
     145    return ConstMap<K, Const<V, v> >();
    148146  }
    149147
     
    226224  /// This mapping gives back the given key as value without any
    227225  /// modification.
    228   template <typename T, typename NC = False>
    229   class IdentityMap : public MapBase<T, T, NC> {
    230   public:
    231     typedef MapBase<T, T, NC> Parent;
     226  template <typename T>
     227  class IdentityMap : public MapBase<T, T> {
     228  public:
     229    typedef MapBase<T, T> Parent;
    232230    typedef typename Parent::Key Key;
    233231    typedef typename Parent::Value Value;
     
    243241  ///\relates IdentityMap
    244242  template<typename T>
    245   inline IdentityMap<T, True> identityMap() {
    246     return IdentityMap<T, True>();
     243  inline IdentityMap<T> identityMap() {
     244    return IdentityMap<T>();
    247245  }
    248246 
     
    253251  ///converts the \c Value of a maps to type \c T.
    254252  ///Its \c Key is inherited from \c M.
    255   template <typename M, typename T, typename NC = False>
    256   class ConvertMap : public MapBase<typename M::Key, T, NC> {
    257     typename SmartConstReference<M>::Type m;
    258   public:
    259     typedef MapBase<typename M::Key, T, NC> Parent;
     253  template <typename M, typename T>
     254  class ConvertMap : public MapBase<typename M::Key, T> {
     255    const M& m;
     256  public:
     257    typedef MapBase<typename M::Key, T> Parent;
    260258    typedef typename Parent::Key Key;
    261259    typedef typename Parent::Value Value;
     
    281279  ///\todo The order of the template parameters are changed.
    282280  template<typename T, typename M>
    283   inline ConvertMap<M, T, True> convertMap(const M &m) {
    284     return ConvertMap<M, T, True>(m);
     281  inline ConvertMap<M, T> convertMap(const M &m) {
     282    return ConvertMap<M, T>(m);
    285283  }
    286284
     
    291289  ///The \c Key and \c Value of M2 must be convertible to those of \c M1.
    292290
    293   template<typename M1, typename M2, typename NC = False>
    294   class AddMap : public MapBase<typename M1::Key, typename M1::Value, NC> {
    295     typename SmartConstReference<M1>::Type m1;
    296     typename SmartConstReference<M2>::Type m2;
    297 
    298   public:
    299     typedef MapBase<typename M1::Key, typename M1::Value, NC> Parent;
     291  template<typename M1, typename M2>
     292  class AddMap : public MapBase<typename M1::Key, typename M1::Value> {
     293    const M1& m1;
     294    const M2& m2;
     295
     296  public:
     297    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
    300298    typedef typename Parent::Key Key;
    301299    typedef typename Parent::Value Value;
     
    314312  ///\todo Wrong scope in Doxygen when \c \\relates is used
    315313  template<typename M1, typename M2>
    316   inline AddMap<M1, M2, True> addMap(const M1 &m1,const M2 &m2) {
    317     return AddMap<M1, M2, True>(m1,m2);
     314  inline AddMap<M1, M2> addMap(const M1 &m1,const M2 &m2) {
     315    return AddMap<M1, M2>(m1,m2);
    318316  }
    319317
     
    333331  ///  AddMap<X, ConstMap<X::Key, X::Value> > sh(x,v);
    334332  ///\endcode
    335   template<typename M, typename C = typename M::Value, typename NC = False>
    336   class ShiftMap : public MapBase<typename M::Key, typename M::Value, NC> {
    337     typename SmartConstReference<M>::Type m;
     333  template<typename M, typename C = typename M::Value>
     334  class ShiftMap : public MapBase<typename M::Key, typename M::Value> {
     335    const M& m;
    338336    C v;
    339337  public:
    340     typedef MapBase<typename M::Key, typename M::Value, NC> Parent;
     338    typedef MapBase<typename M::Key, typename M::Value> Parent;
    341339    typedef typename Parent::Key Key;
    342340    typedef typename Parent::Value Value;
     
    357355  ///\todo A better name is required.
    358356  template<typename M, typename C>
    359   inline ShiftMap<M, C, True> shiftMap(const M &m,const C &v) {
    360     return ShiftMap<M, C, True>(m,v);
     357  inline ShiftMap<M, C> shiftMap(const M &m,const C &v) {
     358    return ShiftMap<M, C>(m,v);
    361359  }
    362360
     
    368366  ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
    369367
    370   template<typename M1, typename M2, typename NC = False>
    371   class SubMap : public MapBase<typename M1::Key, typename M1::Value, NC> {
    372     typename SmartConstReference<M1>::Type m1;
    373     typename SmartConstReference<M2>::Type m2;
    374   public:
    375     typedef MapBase<typename M1::Key, typename M1::Value, NC> Parent;
     368  template<typename M1, typename M2>
     369  class SubMap : public MapBase<typename M1::Key, typename M1::Value> {
     370    const M1& m1;
     371    const M2& m2;
     372  public:
     373    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
    376374    typedef typename Parent::Key Key;
    377375    typedef typename Parent::Value Value;
     
    388386  ///\relates SubMap
    389387  template<typename M1, typename M2>
    390   inline SubMap<M1, M2, True> subMap(const M1 &m1, const M2 &m2) {
    391     return SubMap<M1, M2, True>(m1, m2);
     388  inline SubMap<M1, M2> subMap(const M1 &m1, const M2 &m2) {
     389    return SubMap<M1, M2>(m1, m2);
    392390  }
    393391
     
    400398  ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
    401399
    402   template<typename M1, typename M2, typename NC = False>
    403   class MulMap : public MapBase<typename M1::Key, typename M1::Value, NC> {
    404     typename SmartConstReference<M1>::Type m1;
    405     typename SmartConstReference<M2>::Type m2;
    406   public:
    407     typedef MapBase<typename M1::Key, typename M1::Value, NC> Parent;
     400  template<typename M1, typename M2>
     401  class MulMap : public MapBase<typename M1::Key, typename M1::Value> {
     402    const M1& m1;
     403    const M2& m2;
     404  public:
     405    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
    408406    typedef typename Parent::Key Key;
    409407    typedef typename Parent::Value Value;
     
    419417  ///\relates MulMap
    420418  template<typename M1, typename M2>
    421   inline MulMap<M1, M2, True> mulMap(const M1 &m1,const M2 &m2) {
    422     return MulMap<M1, M2, True>(m1,m2);
     419  inline MulMap<M1, M2> mulMap(const M1 &m1,const M2 &m2) {
     420    return MulMap<M1, M2>(m1,m2);
    423421  }
    424422 
     
    438436  ///  MulMap<X, ConstMap<X::Key, X::Value> > sc(x,v);
    439437  ///\endcode
    440   template<typename M, typename C = typename M::Value, typename NC = False>
    441   class ScaleMap : public MapBase<typename M::Key, typename M::Value, NC> {
    442     typename SmartConstReference<M>::Type m;
     438  template<typename M, typename C = typename M::Value>
     439  class ScaleMap : public MapBase<typename M::Key, typename M::Value> {
     440    const M& m;
    443441    C v;
    444442  public:
    445     typedef MapBase<typename M::Key, typename M::Value, NC> Parent;
     443    typedef MapBase<typename M::Key, typename M::Value> Parent;
    446444    typedef typename Parent::Key Key;
    447445    typedef typename Parent::Value Value;
     
    462460  ///\todo A better name is required.
    463461  template<typename M, typename C>
    464   inline ScaleMap<M, C, True> scaleMap(const M &m,const C &v) {
    465     return ScaleMap<M, C, True>(m,v);
     462  inline ScaleMap<M, C> scaleMap(const M &m,const C &v) {
     463    return ScaleMap<M, C>(m,v);
    466464  }
    467465
     
    473471  ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
    474472
    475   template<typename M1, typename M2, typename NC = False>
    476   class DivMap : public MapBase<typename M1::Key, typename M1::Value, NC> {
    477     typename SmartConstReference<M1>::Type m1;
    478     typename SmartConstReference<M2>::Type m2;
    479   public:
    480     typedef MapBase<typename M1::Key, typename M1::Value, NC> Parent;
     473  template<typename M1, typename M2>
     474  class DivMap : public MapBase<typename M1::Key, typename M1::Value> {
     475    const M1& m1;
     476    const M2& m2;
     477  public:
     478    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
    481479    typedef typename Parent::Key Key;
    482480    typedef typename Parent::Value Value;
     
    492490  ///\relates DivMap
    493491  template<typename M1, typename M2>
    494   inline DivMap<M1, M2, True> divMap(const M1 &m1,const M2 &m2) {
    495     return DivMap<M1, M2, True>(m1,m2);
     492  inline DivMap<M1, M2> divMap(const M1 &m1,const M2 &m2) {
     493    return DivMap<M1, M2>(m1,m2);
    496494  }
    497495 
     
    513511  ///\todo Check the requirements.
    514512
    515   template <typename M1, typename M2, typename NC = False>
    516   class ComposeMap : public MapBase<typename M2::Key, typename M1::Value, NC> {
    517     typename SmartConstReference<M1>::Type m1;
    518     typename SmartConstReference<M2>::Type m2;
    519   public:
    520     typedef MapBase<typename M2::Key, typename M1::Value, NC> Parent;
     513  template <typename M1, typename M2>
     514  class ComposeMap : public MapBase<typename M2::Key, typename M1::Value> {
     515    const M1& m1;
     516    const M2& m2;
     517  public:
     518    typedef MapBase<typename M2::Key, typename M1::Value> Parent;
    521519    typedef typename Parent::Key Key;
    522520    typedef typename Parent::Value Value;
     
    532530  ///\relates ComposeMap
    533531  template <typename M1, typename M2>
    534   inline ComposeMap<M1, M2, True> composeMap(const M1 &m1,const M2 &m2) {
    535     return ComposeMap<M1, M2, True>(m1,m2);
     532  inline ComposeMap<M1, M2> composeMap(const M1 &m1,const M2 &m2) {
     533    return ComposeMap<M1, M2>(m1,m2);
    536534  }
    537535 
     
    562560           typename V = typename F::result_type,
    563561           typename NC = False>
    564   class CombineMap : public MapBase<typename M1::Key, V, NC> {
    565     typename SmartConstReference<M1>::Type m1;
    566     typename SmartConstReference<M2>::Type m2;
     562  class CombineMap : public MapBase<typename M1::Key, V> {
     563    const M1& m1;
     564    const M2& m2;
    567565    F f;
    568566  public:
    569     typedef MapBase<typename M1::Key, V, NC> Parent;
     567    typedef MapBase<typename M1::Key, V> Parent;
    570568    typedef typename Parent::Key Key;
    571569    typedef typename Parent::Value Value;
     
    594592  ///\relates CombineMap
    595593  template<typename M1, typename M2, typename F, typename V>
    596   inline CombineMap<M1, M2, F, V, True>
     594  inline CombineMap<M1, M2, F, V>
    597595  combineMap(const M1& m1,const M2& m2, const F& f) {
    598     return CombineMap<M1, M2, F, V, True>(m1,m2,f);
     596    return CombineMap<M1, M2, F, V>(m1,m2,f);
    599597  }
    600598
    601599  template<typename M1, typename M2, typename F>
    602   inline CombineMap<M1, M2, F, typename F::result_type, True>
     600  inline CombineMap<M1, M2, F, typename F::result_type>
    603601  combineMap(const M1& m1, const M2& m2, const F& f) {
    604602    return combineMap<M1, M2, F, typename F::result_type>(m1,m2,f);
     
    606604
    607605  template<typename M1, typename M2, typename K1, typename K2, typename V>
    608   inline CombineMap<M1, M2, V (*)(K1, K2), V, True>
     606  inline CombineMap<M1, M2, V (*)(K1, K2), V>
    609607  combineMap(const M1 &m1, const M2 &m2, V (*f)(K1, K2)) {
    610608    return combineMap<M1, M2, V (*)(K1, K2), V>(m1,m2,f);
     
    619617  ///The unary \c - operator must be defined for \c Value, of course.
    620618
    621   template<typename M, typename NC = False>
    622   class NegMap : public MapBase<typename M::Key, typename M::Value, NC> {
    623     typename SmartConstReference<M>::Type m;
    624   public:
    625     typedef MapBase<typename M::Key, typename M::Value, NC> Parent;
     619  template<typename M>
     620  class NegMap : public MapBase<typename M::Key, typename M::Value> {
     621    const M& m;
     622  public:
     623    typedef MapBase<typename M::Key, typename M::Value> Parent;
    626624    typedef typename Parent::Key Key;
    627625    typedef typename Parent::Value Value;
     
    637635  ///\relates NegMap
    638636  template <typename M>
    639   inline NegMap<M, True> negMap(const M &m) {
    640     return NegMap<M, True>(m);
     637  inline NegMap<M> negMap(const M &m) {
     638    return NegMap<M>(m);
    641639  }
    642640
     
    665663 
    666664
    667   template<typename M, typename NC = False>
    668   class AbsMap : public MapBase<typename M::Key, typename M::Value, NC> {
    669     typename SmartConstReference<M>::Type m;
    670   public:
    671     typedef MapBase<typename M::Key, typename M::Value, NC> Parent;
     665  template<typename M>
     666  class AbsMap : public MapBase<typename M::Key, typename M::Value> {
     667    const M& m;
     668  public:
     669    typedef MapBase<typename M::Key, typename M::Value> Parent;
    672670    typedef typename Parent::Key Key;
    673671    typedef typename Parent::Value Value;
     
    687685  ///\relates AbsMap
    688686  template<typename M>
    689   inline AbsMap<M, True> absMap(const M &m) {
    690     return AbsMap<M, True>(m);
     687  inline AbsMap<M> absMap(const M &m) {
     688    return AbsMap<M>(m);
    691689  }
    692690
     
    708706           typename V = typename F::result_type,
    709707           typename NC = False>
    710   class FunctorMap : public MapBase<K, V, NC> {
     708  class FunctorMap : public MapBase<K, V> {
    711709    F f;
    712710  public:
    713     typedef MapBase<K, V, NC> Parent;
     711    typedef MapBase<K, V> Parent;
    714712    typedef typename Parent::Key Key;
    715713    typedef typename Parent::Value Value;
     
    728726  ///\relates FunctorMap
    729727  template<typename K, typename V, typename F> inline
    730   FunctorMap<F, K, V, True> functorMap(const F &f) {
    731     return FunctorMap<F, K, V, True>(f);
     728  FunctorMap<F, K, V> functorMap(const F &f) {
     729    return FunctorMap<F, K, V>(f);
    732730  }
    733731
    734732  template <typename F> inline
    735   FunctorMap<F, typename F::argument_type, typename F::result_type, True>
     733  FunctorMap<F, typename F::argument_type, typename F::result_type>
    736734  functorMap(const F &f) {
    737735    return FunctorMap<F, typename F::argument_type,
    738       typename F::result_type, True>(f);
     736      typename F::result_type>(f);
    739737  }
    740738
    741739  template <typename K, typename V> inline
    742   FunctorMap<V (*)(K), K, V, True> functorMap(V (*f)(K)) {
    743     return FunctorMap<V (*)(K), K, V, True>(f);
     740  FunctorMap<V (*)(K), K, V> functorMap(V (*f)(K)) {
     741    return FunctorMap<V (*)(K), K, V>(f);
    744742  }
    745743
     
    754752  ///i.e. <tt>operator[]</tt> and the \c Key and \c Value typedefs also exist.
    755753
    756   template <typename M, typename NC = False>
    757   class MapFunctor : public MapBase<typename M::Key, typename M::Value, NC> {
    758     typename SmartConstReference<M>::Type m;
    759   public:
    760     typedef MapBase<typename M::Key, typename M::Value, NC> Parent;
     754  template <typename M>
     755  class MapFunctor : public MapBase<typename M::Key, typename M::Value> {
     756    const M& m;
     757  public:
     758    typedef MapBase<typename M::Key, typename M::Value> Parent;
    761759    typedef typename Parent::Key Key;
    762760    typedef typename Parent::Value Value;
     
    780778  ///\relates MapFunctor
    781779  template<typename M>
    782   inline MapFunctor<M, True> mapFunctor(const M &m) {
    783     return MapFunctor<M, True>(m);
     780  inline MapFunctor<M> mapFunctor(const M &m) {
     781    return MapFunctor<M>(m);
    784782  }
    785783
     
    796794  ///The \c Key and \c Value of M2 must be convertible from those of \c M1.
    797795
    798   template<typename  M1, typename M2, typename NC = False>
    799   class ForkMap : public MapBase<typename M1::Key, typename M1::Value, NC> {
    800     typename SmartConstReference<M1>::Type m1;
    801     typename SmartConstReference<M2>::Type m2;
    802   public:
    803     typedef MapBase<typename M1::Key, typename M1::Value, NC> Parent;
     796  template<typename  M1, typename M2>
     797  class ForkMap : public MapBase<typename M1::Key, typename M1::Value> {
     798    const M1& m1;
     799    const M2& m2;
     800  public:
     801    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
    804802    typedef typename Parent::Key Key;
    805803    typedef typename Parent::Value Value;
     
    819817  ///\todo Wrong scope in Doxygen when \c \\relates is used
    820818  template <typename M1, typename M2>
    821   inline ForkMap<M1, M2, True> forkMap(const M1 &m1,const M2 &m2) {
    822     return ForkMap<M1, M2, True>(m1,m2);
     819  inline ForkMap<M1, M2> forkMap(const M1 &m1,const M2 &m2) {
     820    return ForkMap<M1, M2>(m1,m2);
    823821  }
    824822
     
    835833  ///its Value is <tt>bool</tt>.
    836834
    837   template <typename M, typename NC = False>
    838   class NotMap : public MapBase<typename M::Key, bool, NC> {
    839     typename SmartConstReference<M>::Type m;
    840   public:
    841     typedef MapBase<typename M::Key, bool, NC> Parent;
     835  template <typename M>
     836  class NotMap : public MapBase<typename M::Key, bool> {
     837    const M& m;
     838  public:
     839    typedef MapBase<typename M::Key, bool> Parent;
    842840    typedef typename Parent::Key Key;
    843841    typedef typename Parent::Value Value;
     
    853851  ///\relates NotMap
    854852  template <typename M>
    855   inline NotMap<M, True> notMap(const M &m) {
    856     return NotMap<M, True>(m);
     853  inline NotMap<M> notMap(const M &m) {
     854    return NotMap<M>(m);
    857855  }
    858856
Note: See TracChangeset for help on using the changeset viewer.