COIN-OR::LEMON - Graph Library

Changeset 1267:a93f94dbe3d3 in lemon-0.x for src/lemon/map_utils.h


Ignore:
Timestamp:
03/26/05 00:31:57 (19 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1694
Message:

First version of iterable maps.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/lemon/map_utils.h

    r1239 r1267  
    2626#include <vector>
    2727
     28#include <lemon/graph_utils.h>
     29
    2830namespace lemon {
    2931
    3032  /// \addtogroup mutils
    3133  /// @{
     34
     35
     36  template <typename Map, typename Enable = void>
     37  struct ReferenceMapTraits {
     38    typedef typename Map::Value Value;
     39    typedef typename Map::Value& Reference;
     40    typedef const typename Map::Value& ConstReference;
     41    typedef typename Map::Value* Pointer;
     42    typedef const typename Map::Value* ConstPointer;
     43  };
     44
     45  template <typename Map>
     46  struct ReferenceMapTraits<
     47    Map,
     48    typename enable_if<typename Map::FullTypeTag, void>::type
     49  > {
     50    typedef typename Map::Value Value;
     51    typedef typename Map::Reference Reference;
     52    typedef typename Map::ConstReference ConstReference;
     53    typedef typename Map::Pointer Pointer;
     54    typedef typename Map::ConstPointer ConstPointer;
     55  };
    3256
    3357  /// \brief General inversable map type.
     
    4064  /// \param _Map The map to extend with inversable functionality.
    4165  template <
    42     typename _Graph,
    43     typename _Map
     66    typename _Graph,
     67    typename _Item,
     68    typename _Value,
     69    typename _Map
     70    = typename ItemSetTraits<_Graph, _Item>::template Map<_Value>
    4471  >
    4572  class InversableMap : protected _Map {
    4673
    4774  public:
     75 
     76    typedef _Map Map;
    4877    typedef _Graph Graph;
    49 
    50     typedef _Map Map;
    51     /// The key type of InversableMap (Node, Edge, UndirEdge).
     78   /// The key type of InversableMap (Node, Edge, UndirEdge).
    5279    typedef typename _Map::Key Key;
    5380    /// The value type of the InversableMap.
    5481    typedef typename _Map::Value Value;
     82
    5583    typedef std::map<Value, Key> InverseMap;
    5684   
     
    6593    /// \brief The setter function of the map.
    6694    ///
    67     /// It sets the map and the inverse map to given key-value pair.
     95
    6896    void set(const Key& key, const Value& val) {
    6997      Value oldval = Map::operator[](key);
     
    141169    typename _Graph,   
    142170    typename _Item,
    143     typename _Map
     171    typename _Map = typename ItemSetTraits<_Graph, _Item>::template Map<int>
    144172  >
    145173  class DescriptorMap : protected _Map {
     
    238266    typedef int Value;
    239267    typedef _Item Item;
     268    typedef _Item Key;
    240269
    241270    /// \brief The class represents the inverse of the map.
Note: See TracChangeset for help on using the changeset viewer.