From b54de4269670aa601b5ed70382f02807d551ce43 Mon Sep 17 00:00:00 2001 From: "lperron@google.com" Date: Fri, 8 Apr 2011 15:19:28 +0000 Subject: [PATCH] fix example --- examples/network_routing.cc | 26 ++++++++++++++++++++++++++ graph/shortestpaths.cc | 2 -- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/examples/network_routing.cc b/examples/network_routing.cc index 1d6a076c35..2011713a3d 100644 --- a/examples/network_routing.cc +++ b/examples/network_routing.cc @@ -91,6 +91,27 @@ DEFINE_bool(focus_lns, true, "Focus LNS on highest cost arcs."); namespace operations_research { // ---------- Data and Data Generation ---------- + +namespace { +#if defined(_MSC_VER) + // The following class defines a hash function for arcs + class ArcHasher : public stdext::hash_compare > { + public: + size_t operator() (const pair& a) const { + uint32 x = a.first; + uint32 y = 0x9e3779b9UL; + uint32 z = a.second; + mix(x, y, z); + return z; + } + bool operator() (const pair& a1, const pair& a2) const { + return a1.first < a2.first || + (a1.first == a2.first && a1.second < a2.second); + } + }; +#endif +} // namespace + static const int64 kDisconnectedDistance = -1LL; // ----- Data ----- @@ -144,8 +165,13 @@ class NetworkRoutingData { int num_nodes_; int max_capacity_; int fixed_charge_cost_; +#if defined(_MSC_VER) + hash_map, int, ArcHasher> all_arcs_; + hash_map, int, ArcHasher> all_demands_; +#else hash_map, int> all_arcs_; hash_map, int> all_demands_; +#endif }; // ----- Data Generation ----- diff --git a/graph/shortestpaths.cc b/graph/shortestpaths.cc index 1c4494cbaa..fd58ac27d6 100644 --- a/graph/shortestpaths.cc +++ b/graph/shortestpaths.cc @@ -17,8 +17,6 @@ #include "base/callback.h" #include "base/commandlineflags.h" #include "base/integral_types.h" -#include "base/logging.h" -#include "base/macros.h" DEFINE_int32(shortestpaths_disconnected_distance, 200000, "Distance returned when two node are disconnected");