lemon/bits/traits.h
changeset 784 1a7fe3bef514
parent 440 88ed40ad0d4f
child 1019 4c89e925cfe2
     1.1 --- a/lemon/bits/traits.h	Fri Oct 16 10:21:37 2009 +0200
     1.2 +++ b/lemon/bits/traits.h	Thu Nov 05 15:50:01 2009 +0100
     1.3 @@ -2,7 +2,7 @@
     1.4   *
     1.5   * This file is a part of LEMON, a generic C++ optimization library.
     1.6   *
     1.7 - * Copyright (C) 2003-2008
     1.8 + * Copyright (C) 2003-2009
     1.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    1.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
    1.11   *
    1.12 @@ -29,117 +29,123 @@
    1.13  
    1.14    struct InvalidType {};
    1.15  
    1.16 -  template <typename _Graph, typename _Item>
    1.17 +  template <typename GR, typename _Item>
    1.18    class ItemSetTraits {};
    1.19  
    1.20  
    1.21 -  template <typename Graph, typename Enable = void>
    1.22 +  template <typename GR, typename Enable = void>
    1.23    struct NodeNotifierIndicator {
    1.24      typedef InvalidType Type;
    1.25    };
    1.26 -  template <typename Graph>
    1.27 +  template <typename GR>
    1.28    struct NodeNotifierIndicator<
    1.29 -    Graph,
    1.30 -    typename enable_if<typename Graph::NodeNotifier::Notifier, void>::type
    1.31 +    GR,
    1.32 +    typename enable_if<typename GR::NodeNotifier::Notifier, void>::type
    1.33    > {
    1.34 -    typedef typename Graph::NodeNotifier Type;
    1.35 +    typedef typename GR::NodeNotifier Type;
    1.36    };
    1.37  
    1.38 -  template <typename _Graph>
    1.39 -  class ItemSetTraits<_Graph, typename _Graph::Node> {
    1.40 +  template <typename GR>
    1.41 +  class ItemSetTraits<GR, typename GR::Node> {
    1.42    public:
    1.43  
    1.44 -    typedef _Graph Graph;
    1.45 +    typedef GR Graph;
    1.46 +    typedef GR Digraph;
    1.47  
    1.48 -    typedef typename Graph::Node Item;
    1.49 -    typedef typename Graph::NodeIt ItemIt;
    1.50 +    typedef typename GR::Node Item;
    1.51 +    typedef typename GR::NodeIt ItemIt;
    1.52  
    1.53 -    typedef typename NodeNotifierIndicator<Graph>::Type ItemNotifier;
    1.54 +    typedef typename NodeNotifierIndicator<GR>::Type ItemNotifier;
    1.55  
    1.56 -    template <typename _Value>
    1.57 -    class Map : public Graph::template NodeMap<_Value> {
    1.58 +    template <typename V>
    1.59 +    class Map : public GR::template NodeMap<V> {
    1.60 +      typedef typename GR::template NodeMap<V> Parent;
    1.61 +
    1.62      public:
    1.63 -      typedef typename Graph::template NodeMap<_Value> Parent;
    1.64 -      typedef typename Graph::template NodeMap<_Value> Type;
    1.65 +      typedef typename GR::template NodeMap<V> Type;
    1.66        typedef typename Parent::Value Value;
    1.67  
    1.68 -      Map(const Graph& _digraph) : Parent(_digraph) {}
    1.69 -      Map(const Graph& _digraph, const Value& _value)
    1.70 +      Map(const GR& _digraph) : Parent(_digraph) {}
    1.71 +      Map(const GR& _digraph, const Value& _value)
    1.72          : Parent(_digraph, _value) {}
    1.73  
    1.74       };
    1.75  
    1.76    };
    1.77  
    1.78 -  template <typename Graph, typename Enable = void>
    1.79 +  template <typename GR, typename Enable = void>
    1.80    struct ArcNotifierIndicator {
    1.81      typedef InvalidType Type;
    1.82    };
    1.83 -  template <typename Graph>
    1.84 +  template <typename GR>
    1.85    struct ArcNotifierIndicator<
    1.86 -    Graph,
    1.87 -    typename enable_if<typename Graph::ArcNotifier::Notifier, void>::type
    1.88 +    GR,
    1.89 +    typename enable_if<typename GR::ArcNotifier::Notifier, void>::type
    1.90    > {
    1.91 -    typedef typename Graph::ArcNotifier Type;
    1.92 +    typedef typename GR::ArcNotifier Type;
    1.93    };
    1.94  
    1.95 -  template <typename _Graph>
    1.96 -  class ItemSetTraits<_Graph, typename _Graph::Arc> {
    1.97 +  template <typename GR>
    1.98 +  class ItemSetTraits<GR, typename GR::Arc> {
    1.99    public:
   1.100  
   1.101 -    typedef _Graph Graph;
   1.102 +    typedef GR Graph;
   1.103 +    typedef GR Digraph;
   1.104  
   1.105 -    typedef typename Graph::Arc Item;
   1.106 -    typedef typename Graph::ArcIt ItemIt;
   1.107 +    typedef typename GR::Arc Item;
   1.108 +    typedef typename GR::ArcIt ItemIt;
   1.109  
   1.110 -    typedef typename ArcNotifierIndicator<Graph>::Type ItemNotifier;
   1.111 +    typedef typename ArcNotifierIndicator<GR>::Type ItemNotifier;
   1.112  
   1.113 -    template <typename _Value>
   1.114 -    class Map : public Graph::template ArcMap<_Value> {
   1.115 +    template <typename V>
   1.116 +    class Map : public GR::template ArcMap<V> {
   1.117 +      typedef typename GR::template ArcMap<V> Parent;
   1.118 +
   1.119      public:
   1.120 -      typedef typename Graph::template ArcMap<_Value> Parent;
   1.121 -      typedef typename Graph::template ArcMap<_Value> Type;
   1.122 +      typedef typename GR::template ArcMap<V> Type;
   1.123        typedef typename Parent::Value Value;
   1.124  
   1.125 -      Map(const Graph& _digraph) : Parent(_digraph) {}
   1.126 -      Map(const Graph& _digraph, const Value& _value)
   1.127 +      Map(const GR& _digraph) : Parent(_digraph) {}
   1.128 +      Map(const GR& _digraph, const Value& _value)
   1.129          : Parent(_digraph, _value) {}
   1.130      };
   1.131  
   1.132    };
   1.133  
   1.134 -  template <typename Graph, typename Enable = void>
   1.135 +  template <typename GR, typename Enable = void>
   1.136    struct EdgeNotifierIndicator {
   1.137      typedef InvalidType Type;
   1.138    };
   1.139 -  template <typename Graph>
   1.140 +  template <typename GR>
   1.141    struct EdgeNotifierIndicator<
   1.142 -    Graph,
   1.143 -    typename enable_if<typename Graph::EdgeNotifier::Notifier, void>::type
   1.144 +    GR,
   1.145 +    typename enable_if<typename GR::EdgeNotifier::Notifier, void>::type
   1.146    > {
   1.147 -    typedef typename Graph::EdgeNotifier Type;
   1.148 +    typedef typename GR::EdgeNotifier Type;
   1.149    };
   1.150  
   1.151 -  template <typename _Graph>
   1.152 -  class ItemSetTraits<_Graph, typename _Graph::Edge> {
   1.153 +  template <typename GR>
   1.154 +  class ItemSetTraits<GR, typename GR::Edge> {
   1.155    public:
   1.156  
   1.157 -    typedef _Graph Graph;
   1.158 +    typedef GR Graph;
   1.159 +    typedef GR Digraph;
   1.160  
   1.161 -    typedef typename Graph::Edge Item;
   1.162 -    typedef typename Graph::EdgeIt ItemIt;
   1.163 +    typedef typename GR::Edge Item;
   1.164 +    typedef typename GR::EdgeIt ItemIt;
   1.165  
   1.166 -    typedef typename EdgeNotifierIndicator<Graph>::Type ItemNotifier;
   1.167 +    typedef typename EdgeNotifierIndicator<GR>::Type ItemNotifier;
   1.168  
   1.169 -    template <typename _Value>
   1.170 -    class Map : public Graph::template EdgeMap<_Value> {
   1.171 +    template <typename V>
   1.172 +    class Map : public GR::template EdgeMap<V> {
   1.173 +      typedef typename GR::template EdgeMap<V> Parent;
   1.174 +
   1.175      public:
   1.176 -      typedef typename Graph::template EdgeMap<_Value> Parent;
   1.177 -      typedef typename Graph::template EdgeMap<_Value> Type;
   1.178 +      typedef typename GR::template EdgeMap<V> Type;
   1.179        typedef typename Parent::Value Value;
   1.180  
   1.181 -      Map(const Graph& _digraph) : Parent(_digraph) {}
   1.182 -      Map(const Graph& _digraph, const Value& _value)
   1.183 +      Map(const GR& _digraph) : Parent(_digraph) {}
   1.184 +      Map(const GR& _digraph, const Value& _value)
   1.185          : Parent(_digraph, _value) {}
   1.186      };
   1.187  
   1.188 @@ -204,67 +210,93 @@
   1.189  
   1.190    // Indicators for the tags
   1.191  
   1.192 -  template <typename Graph, typename Enable = void>
   1.193 +  template <typename GR, typename Enable = void>
   1.194    struct NodeNumTagIndicator {
   1.195      static const bool value = false;
   1.196    };
   1.197  
   1.198 -  template <typename Graph>
   1.199 +  template <typename GR>
   1.200    struct NodeNumTagIndicator<
   1.201 -    Graph,
   1.202 -    typename enable_if<typename Graph::NodeNumTag, void>::type
   1.203 +    GR,
   1.204 +    typename enable_if<typename GR::NodeNumTag, void>::type
   1.205    > {
   1.206      static const bool value = true;
   1.207    };
   1.208  
   1.209 -  template <typename Graph, typename Enable = void>
   1.210 +  template <typename GR, typename Enable = void>
   1.211 +  struct ArcNumTagIndicator {
   1.212 +    static const bool value = false;
   1.213 +  };
   1.214 +
   1.215 +  template <typename GR>
   1.216 +  struct ArcNumTagIndicator<
   1.217 +    GR,
   1.218 +    typename enable_if<typename GR::ArcNumTag, void>::type
   1.219 +  > {
   1.220 +    static const bool value = true;
   1.221 +  };
   1.222 +
   1.223 +  template <typename GR, typename Enable = void>
   1.224    struct EdgeNumTagIndicator {
   1.225      static const bool value = false;
   1.226    };
   1.227  
   1.228 -  template <typename Graph>
   1.229 +  template <typename GR>
   1.230    struct EdgeNumTagIndicator<
   1.231 -    Graph,
   1.232 -    typename enable_if<typename Graph::EdgeNumTag, void>::type
   1.233 +    GR,
   1.234 +    typename enable_if<typename GR::EdgeNumTag, void>::type
   1.235    > {
   1.236      static const bool value = true;
   1.237    };
   1.238  
   1.239 -  template <typename Graph, typename Enable = void>
   1.240 +  template <typename GR, typename Enable = void>
   1.241 +  struct FindArcTagIndicator {
   1.242 +    static const bool value = false;
   1.243 +  };
   1.244 +
   1.245 +  template <typename GR>
   1.246 +  struct FindArcTagIndicator<
   1.247 +    GR,
   1.248 +    typename enable_if<typename GR::FindArcTag, void>::type
   1.249 +  > {
   1.250 +    static const bool value = true;
   1.251 +  };
   1.252 +
   1.253 +  template <typename GR, typename Enable = void>
   1.254    struct FindEdgeTagIndicator {
   1.255      static const bool value = false;
   1.256    };
   1.257  
   1.258 -  template <typename Graph>
   1.259 +  template <typename GR>
   1.260    struct FindEdgeTagIndicator<
   1.261 -    Graph,
   1.262 -    typename enable_if<typename Graph::FindEdgeTag, void>::type
   1.263 +    GR,
   1.264 +    typename enable_if<typename GR::FindEdgeTag, void>::type
   1.265    > {
   1.266      static const bool value = true;
   1.267    };
   1.268  
   1.269 -  template <typename Graph, typename Enable = void>
   1.270 +  template <typename GR, typename Enable = void>
   1.271    struct UndirectedTagIndicator {
   1.272      static const bool value = false;
   1.273    };
   1.274  
   1.275 -  template <typename Graph>
   1.276 +  template <typename GR>
   1.277    struct UndirectedTagIndicator<
   1.278 -    Graph,
   1.279 -    typename enable_if<typename Graph::UndirectedTag, void>::type
   1.280 +    GR,
   1.281 +    typename enable_if<typename GR::UndirectedTag, void>::type
   1.282    > {
   1.283      static const bool value = true;
   1.284    };
   1.285  
   1.286 -  template <typename Graph, typename Enable = void>
   1.287 +  template <typename GR, typename Enable = void>
   1.288    struct BuildTagIndicator {
   1.289      static const bool value = false;
   1.290    };
   1.291  
   1.292 -  template <typename Graph>
   1.293 +  template <typename GR>
   1.294    struct BuildTagIndicator<
   1.295 -    Graph,
   1.296 -    typename enable_if<typename Graph::BuildTag, void>::type
   1.297 +    GR,
   1.298 +    typename enable_if<typename GR::BuildTag, void>::type
   1.299    > {
   1.300      static const bool value = true;
   1.301    };