COIN-OR::LEMON - Graph Library

Changeset 2564:3250756f5add in lemon-0.x for lemon/concepts/maps.h


Ignore:
Timestamp:
02/05/08 13:41:05 (16 years ago)
Author:
Peter Kovacs
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3445
Message:

Several doc improvements and fixes in maps.h and concepts/maps.h.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/concepts/maps.h

    r2553 r2564  
    3535
    3636    /// Readable map concept
     37
     38    /// Readable map concept.
     39    ///
    3740    template<typename K, typename T>
    3841    class ReadMap
    3942    {
    4043    public:
    41       /// Map's key type.
    42       typedef K Key;   
    43       /// Map's value type. (The type of objects associated with the keys).
    44       typedef T Value;
    45 
    46       // \bug Value don't need to be default constructible.
     44      /// The key type of the map.
     45      typedef K Key;   
     46      /// The value type of the map. (The type of objects associated with the keys).
     47      typedef T Value;
     48
    4749      /// Returns the value associated with a key.
     50
     51      /// Returns the value associated with a key.
     52      /// \bug Value shouldn't need to be default constructible.
     53      ///
    4854      Value operator[](const Key &) const {return Value();}
    4955
     
    7076
    7177    /// Writable map concept
     78   
     79    /// Writable map concept.
     80    ///
    7281    template<typename K, typename T>
    7382    class WriteMap
    7483    {
    7584    public:
    76       /// Map's key type.
    77       typedef K Key;   
    78       /// Map's value type. (The type of objects associated with the keys).
     85      /// The key type of the map.
     86      typedef K Key;   
     87      /// The value type of the map. (The type of objects associated with the keys).
    7988      typedef T Value;
    8089
     
    106115    };
    107116
    108     ///Read/Writable map concept
     117    /// Read/writable map concept
     118   
     119    /// Read/writable map concept.
     120    ///
    109121    template<typename K, typename T>
    110122    class ReadWriteMap : public ReadMap<K,T>,
    111                             public WriteMap<K,T>
    112     {
    113     public:
    114       /// Map's key type.
    115       typedef K Key;   
    116       /// Map's value type. (The type of objects associated with the keys).
     123                         public WriteMap<K,T>
     124    {
     125    public:
     126      /// The key type of the map.
     127      typedef K Key;   
     128      /// The value type of the map. (The type of objects associated with the keys).
    117129      typedef T Value;
    118130
     
    133145 
    134146    ///Dereferable map concept
     147   
     148    /// Dereferable map concept.
     149    ///
     150    /// \todo Rethink this concept.
    135151    template<typename K, typename T, typename R, typename CR>
    136152    class ReferenceMap : public ReadWriteMap<K,T>
     
    139155      /// Tag for reference maps.
    140156      typedef True ReferenceMapTag;
    141       /// Map's key type.
    142       typedef K Key;   
    143       /// Map's value type. (The type of objects associated with the keys).
    144       typedef T Value;
    145       /// Map's reference type.
     157      /// The key type of the map.
     158      typedef K Key;   
     159      /// The value type of the map. (The type of objects associated with the keys).
     160      typedef T Value;
     161      /// The reference type of the map.
    146162      typedef R Reference;
    147       /// Map's const reference type.
     163      /// The const reference type of the map.
    148164      typedef CR ConstReference;
    149165
     
    152168    public:
    153169
    154       ///Returns a reference to the value associated to a key.
     170      ///Returns a reference to the value associated with a key.
    155171      Reference operator[](const Key &) { return tmp; }
    156       ///Returns a const reference to the value associated to a key.
    157       ConstReference operator[](const Key &) const
    158       { return tmp; }
     172      ///Returns a const reference to the value associated with a key.
     173      ConstReference operator[](const Key &) const { return tmp; }
    159174      /// Sets the value associated with a key.
    160175      void set(const Key &k,const Value &t) { operator[](k)=t; }
    161176
    162       // \todo rethink this concept
    163177      template<typename _ReferenceMap>
    164       struct ReferenceMapConcept {
    165 
    166         void constraints() {
    167           checkConcept<ReadWriteMap, _ReferenceMap >();
     178      struct Constraints {
     179
     180        void constraints() {
     181          checkConcept<ReadWriteMap<K, T>, _ReferenceMap >();
    168182          m[key] = val;
    169183          val  = m[key];
     
    178192        typename _ReferenceMap::Key& own_key;
    179193        typename _ReferenceMap::Value& own_val;
    180         typename _ReferenceMap::Reference& own_ref;
     194        typename _ReferenceMap::Reference own_ref;
    181195        Key& key;
    182196        Value& val;
    183         Reference& ref;
     197        Reference ref;
    184198        _ReferenceMap& m;
    185199      };
     
    189203
    190204  } //namespace concepts
     205
    191206} //namespace lemon
     207
    192208#endif // LEMON_CONCEPT_MAPS_H
Note: See TracChangeset for help on using the changeset viewer.