lemon/adaptors.h
changeset 606 c5fd2d996909
parent 566 c786cd201266
child 626 d11bf7998905
     1.1 --- a/lemon/adaptors.h	Thu Mar 05 10:13:20 2009 +0000
     1.2 +++ b/lemon/adaptors.h	Sun Mar 29 23:08:20 2009 +0200
     1.3 @@ -2254,26 +2254,27 @@
     1.4      ///
     1.5      /// This map adaptor class adapts two arc maps of the underlying
     1.6      /// digraph to get an arc map of the undirected graph.
     1.7 -    /// Its value type is inherited from the first arc map type
     1.8 -    /// (\c %ForwardMap).
     1.9 -    template <typename ForwardMap, typename BackwardMap>
    1.10 +    /// Its value type is inherited from the first arc map type (\c FW).
    1.11 +    /// \tparam FW The type of the "foward" arc map.
    1.12 +    /// \tparam BK The type of the "backward" arc map.
    1.13 +    template <typename FW, typename BK>
    1.14      class CombinedArcMap {
    1.15      public:
    1.16  
    1.17        /// The key type of the map
    1.18        typedef typename Parent::Arc Key;
    1.19        /// The value type of the map
    1.20 -      typedef typename ForwardMap::Value Value;
    1.21 -
    1.22 -      typedef typename MapTraits<ForwardMap>::ReferenceMapTag ReferenceMapTag;
    1.23 -
    1.24 -      typedef typename MapTraits<ForwardMap>::ReturnValue ReturnValue;
    1.25 -      typedef typename MapTraits<ForwardMap>::ConstReturnValue ConstReturnValue;
    1.26 -      typedef typename MapTraits<ForwardMap>::ReturnValue Reference;
    1.27 -      typedef typename MapTraits<ForwardMap>::ConstReturnValue ConstReference;
    1.28 +      typedef typename FW::Value Value;
    1.29 +
    1.30 +      typedef typename MapTraits<FW>::ReferenceMapTag ReferenceMapTag;
    1.31 +
    1.32 +      typedef typename MapTraits<FW>::ReturnValue ReturnValue;
    1.33 +      typedef typename MapTraits<FW>::ConstReturnValue ConstReturnValue;
    1.34 +      typedef typename MapTraits<FW>::ReturnValue Reference;
    1.35 +      typedef typename MapTraits<FW>::ConstReturnValue ConstReference;
    1.36  
    1.37        /// Constructor
    1.38 -      CombinedArcMap(ForwardMap& forward, BackwardMap& backward)
    1.39 +      CombinedArcMap(FW& forward, BK& backward)
    1.40          : _forward(&forward), _backward(&backward) {}
    1.41  
    1.42        /// Sets the value associated with the given key.
    1.43 @@ -2305,39 +2306,36 @@
    1.44  
    1.45      protected:
    1.46  
    1.47 -      ForwardMap* _forward;
    1.48 -      BackwardMap* _backward;
    1.49 +      FW* _forward;
    1.50 +      BK* _backward;
    1.51  
    1.52      };
    1.53  
    1.54      /// \brief Returns a combined arc map
    1.55      ///
    1.56      /// This function just returns a combined arc map.
    1.57 -    template <typename ForwardMap, typename BackwardMap>
    1.58 -    static CombinedArcMap<ForwardMap, BackwardMap>
    1.59 -    combinedArcMap(ForwardMap& forward, BackwardMap& backward) {
    1.60 -      return CombinedArcMap<ForwardMap, BackwardMap>(forward, backward);
    1.61 +    template <typename FW, typename BK>
    1.62 +    static CombinedArcMap<FW, BK>
    1.63 +    combinedArcMap(FW& forward, BK& backward) {
    1.64 +      return CombinedArcMap<FW, BK>(forward, backward);
    1.65      }
    1.66  
    1.67 -    template <typename ForwardMap, typename BackwardMap>
    1.68 -    static CombinedArcMap<const ForwardMap, BackwardMap>
    1.69 -    combinedArcMap(const ForwardMap& forward, BackwardMap& backward) {
    1.70 -      return CombinedArcMap<const ForwardMap,
    1.71 -        BackwardMap>(forward, backward);
    1.72 +    template <typename FW, typename BK>
    1.73 +    static CombinedArcMap<const FW, BK>
    1.74 +    combinedArcMap(const FW& forward, BK& backward) {
    1.75 +      return CombinedArcMap<const FW, BK>(forward, backward);
    1.76      }
    1.77  
    1.78 -    template <typename ForwardMap, typename BackwardMap>
    1.79 -    static CombinedArcMap<ForwardMap, const BackwardMap>
    1.80 -    combinedArcMap(ForwardMap& forward, const BackwardMap& backward) {
    1.81 -      return CombinedArcMap<ForwardMap,
    1.82 -        const BackwardMap>(forward, backward);
    1.83 +    template <typename FW, typename BK>
    1.84 +    static CombinedArcMap<FW, const BK>
    1.85 +    combinedArcMap(FW& forward, const BK& backward) {
    1.86 +      return CombinedArcMap<FW, const BK>(forward, backward);
    1.87      }
    1.88  
    1.89 -    template <typename ForwardMap, typename BackwardMap>
    1.90 -    static CombinedArcMap<const ForwardMap, const BackwardMap>
    1.91 -    combinedArcMap(const ForwardMap& forward, const BackwardMap& backward) {
    1.92 -      return CombinedArcMap<const ForwardMap,
    1.93 -        const BackwardMap>(forward, backward);
    1.94 +    template <typename FW, typename BK>
    1.95 +    static CombinedArcMap<const FW, const BK>
    1.96 +    combinedArcMap(const FW& forward, const BK& backward) {
    1.97 +      return CombinedArcMap<const FW, const BK>(forward, backward);
    1.98      }
    1.99  
   1.100    };
   1.101 @@ -3406,25 +3404,26 @@
   1.102      ///
   1.103      /// This map adaptor class adapts two node maps of the original digraph
   1.104      /// to get a node map of the split digraph.
   1.105 -    /// Its value type is inherited from the first node map type
   1.106 -    /// (\c InNodeMap).
   1.107 -    template <typename InNodeMap, typename OutNodeMap>
   1.108 +    /// Its value type is inherited from the first node map type (\c IN).
   1.109 +    /// \tparam IN The type of the node map for the in-nodes. 
   1.110 +    /// \tparam OUT The type of the node map for the out-nodes.
   1.111 +    template <typename IN, typename OUT>
   1.112      class CombinedNodeMap {
   1.113      public:
   1.114  
   1.115        /// The key type of the map
   1.116        typedef Node Key;
   1.117        /// The value type of the map
   1.118 -      typedef typename InNodeMap::Value Value;
   1.119 -
   1.120 -      typedef typename MapTraits<InNodeMap>::ReferenceMapTag ReferenceMapTag;
   1.121 -      typedef typename MapTraits<InNodeMap>::ReturnValue ReturnValue;
   1.122 -      typedef typename MapTraits<InNodeMap>::ConstReturnValue ConstReturnValue;
   1.123 -      typedef typename MapTraits<InNodeMap>::ReturnValue Reference;
   1.124 -      typedef typename MapTraits<InNodeMap>::ConstReturnValue ConstReference;
   1.125 +      typedef typename IN::Value Value;
   1.126 +
   1.127 +      typedef typename MapTraits<IN>::ReferenceMapTag ReferenceMapTag;
   1.128 +      typedef typename MapTraits<IN>::ReturnValue ReturnValue;
   1.129 +      typedef typename MapTraits<IN>::ConstReturnValue ConstReturnValue;
   1.130 +      typedef typename MapTraits<IN>::ReturnValue Reference;
   1.131 +      typedef typename MapTraits<IN>::ConstReturnValue ConstReference;
   1.132  
   1.133        /// Constructor
   1.134 -      CombinedNodeMap(InNodeMap& in_map, OutNodeMap& out_map)
   1.135 +      CombinedNodeMap(IN& in_map, OUT& out_map)
   1.136          : _in_map(in_map), _out_map(out_map) {}
   1.137  
   1.138        /// Returns the value associated with the given key.
   1.139 @@ -3456,8 +3455,8 @@
   1.140  
   1.141      private:
   1.142  
   1.143 -      InNodeMap& _in_map;
   1.144 -      OutNodeMap& _out_map;
   1.145 +      IN& _in_map;
   1.146 +      OUT& _out_map;
   1.147  
   1.148      };
   1.149  
   1.150 @@ -3465,29 +3464,28 @@
   1.151      /// \brief Returns a combined node map
   1.152      ///
   1.153      /// This function just returns a combined node map.
   1.154 -    template <typename InNodeMap, typename OutNodeMap>
   1.155 -    static CombinedNodeMap<InNodeMap, OutNodeMap>
   1.156 -    combinedNodeMap(InNodeMap& in_map, OutNodeMap& out_map) {
   1.157 -      return CombinedNodeMap<InNodeMap, OutNodeMap>(in_map, out_map);
   1.158 +    template <typename IN, typename OUT>
   1.159 +    static CombinedNodeMap<IN, OUT>
   1.160 +    combinedNodeMap(IN& in_map, OUT& out_map) {
   1.161 +      return CombinedNodeMap<IN, OUT>(in_map, out_map);
   1.162      }
   1.163  
   1.164 -    template <typename InNodeMap, typename OutNodeMap>
   1.165 -    static CombinedNodeMap<const InNodeMap, OutNodeMap>
   1.166 -    combinedNodeMap(const InNodeMap& in_map, OutNodeMap& out_map) {
   1.167 -      return CombinedNodeMap<const InNodeMap, OutNodeMap>(in_map, out_map);
   1.168 +    template <typename IN, typename OUT>
   1.169 +    static CombinedNodeMap<const IN, OUT>
   1.170 +    combinedNodeMap(const IN& in_map, OUT& out_map) {
   1.171 +      return CombinedNodeMap<const IN, OUT>(in_map, out_map);
   1.172      }
   1.173  
   1.174 -    template <typename InNodeMap, typename OutNodeMap>
   1.175 -    static CombinedNodeMap<InNodeMap, const OutNodeMap>
   1.176 -    combinedNodeMap(InNodeMap& in_map, const OutNodeMap& out_map) {
   1.177 -      return CombinedNodeMap<InNodeMap, const OutNodeMap>(in_map, out_map);
   1.178 +    template <typename IN, typename OUT>
   1.179 +    static CombinedNodeMap<IN, const OUT>
   1.180 +    combinedNodeMap(IN& in_map, const OUT& out_map) {
   1.181 +      return CombinedNodeMap<IN, const OUT>(in_map, out_map);
   1.182      }
   1.183  
   1.184 -    template <typename InNodeMap, typename OutNodeMap>
   1.185 -    static CombinedNodeMap<const InNodeMap, const OutNodeMap>
   1.186 -    combinedNodeMap(const InNodeMap& in_map, const OutNodeMap& out_map) {
   1.187 -      return CombinedNodeMap<const InNodeMap,
   1.188 -        const OutNodeMap>(in_map, out_map);
   1.189 +    template <typename IN, typename OUT>
   1.190 +    static CombinedNodeMap<const IN, const OUT>
   1.191 +    combinedNodeMap(const IN& in_map, const OUT& out_map) {
   1.192 +      return CombinedNodeMap<const IN, const OUT>(in_map, out_map);
   1.193      }
   1.194  
   1.195      /// \brief Arc map combined from an arc map and a node map of the
   1.196 @@ -3495,25 +3493,26 @@
   1.197      ///
   1.198      /// This map adaptor class adapts an arc map and a node map of the
   1.199      /// original digraph to get an arc map of the split digraph.
   1.200 -    /// Its value type is inherited from the original arc map type
   1.201 -    /// (\c ArcMap).
   1.202 -    template <typename ArcMap, typename NodeMap>
   1.203 +    /// Its value type is inherited from the original arc map type (\c AM).
   1.204 +    /// \tparam AM The type of the arc map.
   1.205 +    /// \tparam NM the type of the node map.
   1.206 +    template <typename AM, typename NM>
   1.207      class CombinedArcMap {
   1.208      public:
   1.209  
   1.210        /// The key type of the map
   1.211        typedef Arc Key;
   1.212        /// The value type of the map
   1.213 -      typedef typename ArcMap::Value Value;
   1.214 -
   1.215 -      typedef typename MapTraits<ArcMap>::ReferenceMapTag ReferenceMapTag;
   1.216 -      typedef typename MapTraits<ArcMap>::ReturnValue ReturnValue;
   1.217 -      typedef typename MapTraits<ArcMap>::ConstReturnValue ConstReturnValue;
   1.218 -      typedef typename MapTraits<ArcMap>::ReturnValue Reference;
   1.219 -      typedef typename MapTraits<ArcMap>::ConstReturnValue ConstReference;
   1.220 +      typedef typename AM::Value Value;
   1.221 +
   1.222 +      typedef typename MapTraits<AM>::ReferenceMapTag ReferenceMapTag;
   1.223 +      typedef typename MapTraits<AM>::ReturnValue ReturnValue;
   1.224 +      typedef typename MapTraits<AM>::ConstReturnValue ConstReturnValue;
   1.225 +      typedef typename MapTraits<AM>::ReturnValue Reference;
   1.226 +      typedef typename MapTraits<AM>::ConstReturnValue ConstReference;
   1.227  
   1.228        /// Constructor
   1.229 -      CombinedArcMap(ArcMap& arc_map, NodeMap& node_map)
   1.230 +      CombinedArcMap(AM& arc_map, NM& node_map)
   1.231          : _arc_map(arc_map), _node_map(node_map) {}
   1.232  
   1.233        /// Returns the value associated with the given key.
   1.234 @@ -3544,8 +3543,10 @@
   1.235        }
   1.236  
   1.237      private:
   1.238 -      ArcMap& _arc_map;
   1.239 -      NodeMap& _node_map;
   1.240 +
   1.241 +      AM& _arc_map;
   1.242 +      NM& _node_map;
   1.243 +
   1.244      };
   1.245  
   1.246      /// \brief Returns a combined arc map