# HG changeset patch
# User Alpar Juttner <alpar@cs.elte.hu>
# Date 1235163071 0
# Node ID d3524090d5e23154ac33c51f2118002a803aa2f5
# Parent  65f80c81d41c841f951379c8bf46939c544fa25b# Parent  b1ef32ab39f33df3e5a5da7049a608a41aaab09b
Merge bugfixes #211, #212, #215, #229 and #230

diff -r 65f80c81d41c -r d3524090d5e2 .hgignore
--- a/.hgignore	Mon Feb 16 18:11:10 2009 +0000
+++ b/.hgignore	Fri Feb 20 20:51:11 2009 +0000
@@ -22,6 +22,7 @@
 lemon/libemon.la
 lemon/stamp-h2
 doc/Doxyfile
+cmake/cmake.version
 .dirstamp
 .libs/*
 .deps/*
diff -r 65f80c81d41c -r d3524090d5e2 CMakeLists.txt
--- a/CMakeLists.txt	Mon Feb 16 18:11:10 2009 +0000
+++ b/CMakeLists.txt	Fri Feb 20 20:51:11 2009 +0000
@@ -23,6 +23,9 @@
 INCLUDE(FindDoxygen)
 INCLUDE(FindGhostscript)
 
+INCLUDE(CheckTypeSize)
+CHECK_TYPE_SIZE("long long" LONG_LONG)
+
 ENABLE_TESTING()
 
 ADD_SUBDIRECTORY(lemon)
diff -r 65f80c81d41c -r d3524090d5e2 configure.ac
--- a/configure.ac	Mon Feb 16 18:11:10 2009 +0000
+++ b/configure.ac	Fri Feb 20 20:51:11 2009 +0000
@@ -24,6 +24,12 @@
 dnl Do compilation tests using the C++ compiler.
 AC_LANG([C++])
 
+dnl Check the existence of long long type.
+AC_CHECK_TYPE(long long, [long_long_found=yes], [long_long_found=no])
+if test x"$long_long_found" = x"yes"; then
+  AC_DEFINE([HAVE_LONG_LONG], [1], [Define to 1 if you have long long.])
+fi
+
 dnl Checks for programs.
 AC_PROG_CXX
 AC_PROG_CXXCPP
@@ -116,6 +122,8 @@
 echo C++ compiler.................. : $CXX
 echo C++ compiles flags............ : $CXXFLAGS
 echo
+echo Compiler supports long long... : $long_long_found
+echo
 #echo GLPK support.................. : $lx_glpk_found
 #echo CPLEX support................. : $lx_cplex_found
 #echo SOPLEX support................ : $lx_soplex_found
diff -r 65f80c81d41c -r d3524090d5e2 lemon/bits/default_map.h
--- a/lemon/bits/default_map.h	Mon Feb 16 18:11:10 2009 +0000
+++ b/lemon/bits/default_map.h	Fri Feb 20 20:51:11 2009 +0000
@@ -96,7 +96,7 @@
   };
 
 
-#if defined __GNUC__ && !defined __STRICT_ANSI__
+#if defined HAVE_LONG_LONG
 
   // long long
   template <typename _Graph, typename _Item>
diff -r 65f80c81d41c -r d3524090d5e2 lemon/bits/windows.cc
--- a/lemon/bits/windows.cc	Mon Feb 16 18:11:10 2009 +0000
+++ b/lemon/bits/windows.cc	Fri Feb 20 20:51:11 2009 +0000
@@ -28,7 +28,15 @@
 #ifndef NOMINMAX
 #define NOMINMAX
 #endif
+#ifdef UNICODE
+#undef UNICODE
+#endif
 #include <windows.h>
+#ifdef LOCALE_INVARIANT
+#define MY_LOCALE LOCALE_INVARIANT
+#else
+#define MY_LOCALE LOCALE_NEUTRAL
+#endif
 #else
 #include <unistd.h>
 #include <ctime>
@@ -87,27 +95,15 @@
 #ifdef WIN32
       SYSTEMTIME time;
       GetSystemTime(&time);
-#if defined(_MSC_VER) && (_MSC_VER < 1500)
-      LPWSTR buf1, buf2, buf3;
-      if (GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
-                        L"ddd MMM dd", buf1, 11) &&
-          GetTimeFormat(LOCALE_USER_DEFAULT, 0, &time,
-                        L"HH':'mm':'ss", buf2, 9) &&
-          GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
-                        L"yyyy", buf3, 5)) {
+      char buf1[11], buf2[9], buf3[5];
+	  if (GetDateFormat(MY_LOCALE, 0, &time,
+                        ("ddd MMM dd"), buf1, 11) &&
+          GetTimeFormat(MY_LOCALE, 0, &time,
+                        ("HH':'mm':'ss"), buf2, 9) &&
+          GetDateFormat(MY_LOCALE, 0, &time,
+                        ("yyyy"), buf3, 5)) {
         os << buf1 << ' ' << buf2 << ' ' << buf3;
       }
-#else
-      char buf1[11], buf2[9], buf3[5];
-      if (GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
-                        "ddd MMM dd", buf1, 11) &&
-          GetTimeFormat(LOCALE_USER_DEFAULT, 0, &time,
-                        "HH':'mm':'ss", buf2, 9) &&
-          GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
-                        "yyyy", buf3, 5)) {
-        os << buf1 << ' ' << buf2 << ' ' << buf3;
-      }
-#endif
       else os << "unknown";
 #else
       timeval tv;
diff -r 65f80c81d41c -r d3524090d5e2 lemon/config.h.cmake
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lemon/config.h.cmake	Fri Feb 20 20:51:11 2009 +0000
@@ -0,0 +1,1 @@
+#cmakedefine HAVE_LONG_LONG 1
\ No newline at end of file
diff -r 65f80c81d41c -r d3524090d5e2 lemon/config.h.in
--- a/lemon/config.h.in	Mon Feb 16 18:11:10 2009 +0000
+++ b/lemon/config.h.in	Fri Feb 20 20:51:11 2009 +0000
@@ -3,3 +3,6 @@
 
 /* Define to 1 if you have GLPK. */
 #undef HAVE_GLPK
+
+/* Define to 1 if you have long long */
+#undef HAVE_LONG_LONG
diff -r 65f80c81d41c -r d3524090d5e2 lemon/lgf_reader.h
--- a/lemon/lgf_reader.h	Mon Feb 16 18:11:10 2009 +0000
+++ b/lemon/lgf_reader.h	Fri Feb 20 20:51:11 2009 +0000
@@ -390,37 +390,13 @@
   template <typename Digraph>
   class DigraphReader;
 
-  /// \brief Return a \ref DigraphReader class
-  ///
-  /// This function just returns a \ref DigraphReader class.
-  /// \relates DigraphReader
   template <typename Digraph>
-  DigraphReader<Digraph> digraphReader(Digraph& digraph,
-                                       std::istream& is = std::cin) {
-    DigraphReader<Digraph> tmp(digraph, is);
-    return tmp;
-  }
-
-  /// \brief Return a \ref DigraphReader class
-  ///
-  /// This function just returns a \ref DigraphReader class.
-  /// \relates DigraphReader
+  DigraphReader<Digraph> digraphReader(Digraph& digraph, 
+                                       std::istream& is = std::cin);
   template <typename Digraph>
-  DigraphReader<Digraph> digraphReader(Digraph& digraph,
-                                       const std::string& fn) {
-    DigraphReader<Digraph> tmp(digraph, fn);
-    return tmp;
-  }
-
-  /// \brief Return a \ref DigraphReader class
-  ///
-  /// This function just returns a \ref DigraphReader class.
-  /// \relates DigraphReader
+  DigraphReader<Digraph> digraphReader(Digraph& digraph, const std::string& fn);
   template <typename Digraph>
-  DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) {
-    DigraphReader<Digraph> tmp(digraph, fn);
-    return tmp;
-  }
+  DigraphReader<Digraph> digraphReader(Digraph& digraph, const char *fn);
 
   /// \ingroup lemon_io
   ///
@@ -584,12 +560,13 @@
 
   private:
 
-    friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
-                                                  std::istream& is);
-    friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
-                                                  const std::string& fn);
-    friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
-                                                  const char *fn);
+    template <typename DGR>
+    friend DigraphReader<DGR> digraphReader(DGR& digraph, std::istream& is);
+    template <typename DGR>
+    friend DigraphReader<DGR> digraphReader(DGR& digraph, 
+                                            const std::string& fn);
+    template <typename DGR>
+    friend DigraphReader<DGR> digraphReader(DGR& digraph, const char *fn);
 
     DigraphReader(DigraphReader& other)
       : _is(other._is), local_is(other.local_is), _digraph(other._digraph),
@@ -1212,38 +1189,47 @@
 
   };
 
+  /// \brief Return a \ref DigraphReader class
+  ///
+  /// This function just returns a \ref DigraphReader class.
+  /// \relates DigraphReader
+  template <typename Digraph>
+  DigraphReader<Digraph> digraphReader(Digraph& digraph, std::istream& is) {
+    DigraphReader<Digraph> tmp(digraph, is);
+    return tmp;
+  }
+
+  /// \brief Return a \ref DigraphReader class
+  ///
+  /// This function just returns a \ref DigraphReader class.
+  /// \relates DigraphReader
+  template <typename Digraph>
+  DigraphReader<Digraph> digraphReader(Digraph& digraph,
+                                       const std::string& fn) {
+    DigraphReader<Digraph> tmp(digraph, fn);
+    return tmp;
+  }
+
+  /// \brief Return a \ref DigraphReader class
+  ///
+  /// This function just returns a \ref DigraphReader class.
+  /// \relates DigraphReader
+  template <typename Digraph>
+  DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) {
+    DigraphReader<Digraph> tmp(digraph, fn);
+    return tmp;
+  }
+
   template <typename Graph>
   class GraphReader;
-
-  /// \brief Return a \ref GraphReader class
-  ///
-  /// This function just returns a \ref GraphReader class.
-  /// \relates GraphReader
+ 
   template <typename Graph>
-  GraphReader<Graph> graphReader(Graph& graph, std::istream& is = std::cin) {
-    GraphReader<Graph> tmp(graph, is);
-    return tmp;
-  }
-
-  /// \brief Return a \ref GraphReader class
-  ///
-  /// This function just returns a \ref GraphReader class.
-  /// \relates GraphReader
+  GraphReader<Graph> graphReader(Graph& graph, 
+                                 std::istream& is = std::cin);
   template <typename Graph>
-  GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) {
-    GraphReader<Graph> tmp(graph, fn);
-    return tmp;
-  }
-
-  /// \brief Return a \ref GraphReader class
-  ///
-  /// This function just returns a \ref GraphReader class.
-  /// \relates GraphReader
+  GraphReader<Graph> graphReader(Graph& graph, const std::string& fn);
   template <typename Graph>
-  GraphReader<Graph> graphReader(Graph& graph, const char* fn) {
-    GraphReader<Graph> tmp(graph, fn);
-    return tmp;
-  }
+  GraphReader<Graph> graphReader(Graph& graph, const char *fn);
 
   /// \ingroup lemon_io
   ///
@@ -1370,10 +1356,12 @@
     }
 
   private:
-    friend GraphReader<Graph> graphReader<>(Graph& graph, std::istream& is);
-    friend GraphReader<Graph> graphReader<>(Graph& graph,
-                                            const std::string& fn);
-    friend GraphReader<Graph> graphReader<>(Graph& graph, const char *fn);
+    template <typename GR>
+    friend GraphReader<GR> graphReader(GR& graph, std::istream& is);
+    template <typename GR>
+    friend GraphReader<GR> graphReader(GR& graph, const std::string& fn); 
+    template <typename GR>
+    friend GraphReader<GR> graphReader(GR& graph, const char *fn);
 
     GraphReader(GraphReader& other)
       : _is(other._is), local_is(other.local_is), _graph(other._graph),
@@ -2044,6 +2032,36 @@
 
   };
 
+  /// \brief Return a \ref GraphReader class
+  ///
+  /// This function just returns a \ref GraphReader class.
+  /// \relates GraphReader
+  template <typename Graph>
+  GraphReader<Graph> graphReader(Graph& graph, std::istream& is) {
+    GraphReader<Graph> tmp(graph, is);
+    return tmp;
+  }
+
+  /// \brief Return a \ref GraphReader class
+  ///
+  /// This function just returns a \ref GraphReader class.
+  /// \relates GraphReader
+  template <typename Graph>
+  GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) {
+    GraphReader<Graph> tmp(graph, fn);
+    return tmp;
+  }
+
+  /// \brief Return a \ref GraphReader class
+  ///
+  /// This function just returns a \ref GraphReader class.
+  /// \relates GraphReader
+  template <typename Graph>
+  GraphReader<Graph> graphReader(Graph& graph, const char* fn) {
+    GraphReader<Graph> tmp(graph, fn);
+    return tmp;
+  }
+
   class SectionReader;
 
   SectionReader sectionReader(std::istream& is);
diff -r 65f80c81d41c -r d3524090d5e2 lemon/lgf_writer.h
--- a/lemon/lgf_writer.h	Mon Feb 16 18:11:10 2009 +0000
+++ b/lemon/lgf_writer.h	Fri Feb 20 20:51:11 2009 +0000
@@ -350,38 +350,17 @@
   template <typename Digraph>
   class DigraphWriter;
 
-  /// \brief Return a \ref DigraphWriter class
-  ///
-  /// This function just returns a \ref DigraphWriter class.
-  /// \relates DigraphWriter
   template <typename Digraph>
   DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
-                                       std::ostream& os = std::cout) {
-    DigraphWriter<Digraph> tmp(digraph, os);
-    return tmp;
-  }
-
-  /// \brief Return a \ref DigraphWriter class
-  ///
-  /// This function just returns a \ref DigraphWriter class.
-  /// \relates DigraphWriter
+                                       std::ostream& os = std::cout);
   template <typename Digraph>
   DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
-                                       const std::string& fn) {
-    DigraphWriter<Digraph> tmp(digraph, fn);
-    return tmp;
-  }
+                                       const std::string& fn);
 
-  /// \brief Return a \ref DigraphWriter class
-  ///
-  /// This function just returns a \ref DigraphWriter class.
-  /// \relates DigraphWriter
   template <typename Digraph>
   DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
-                                       const char* fn) {
-    DigraphWriter<Digraph> tmp(digraph, fn);
-    return tmp;
-  }
+                                       const char* fn);
+
 
   /// \ingroup lemon_io
   ///
@@ -526,12 +505,15 @@
 
   private:
 
-    friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
-                                                  std::ostream& os);
-    friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
-                                                  const std::string& fn);
-    friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
-                                                  const char *fn);
+    template <typename DGR>
+    friend DigraphWriter<DGR> digraphWriter(const DGR& digraph, 
+                                            std::ostream& os);
+    template <typename DGR>
+    friend DigraphWriter<DGR> digraphWriter(const DGR& digraph,
+                                            const std::string& fn);
+    template <typename DGR>
+    friend DigraphWriter<DGR> digraphWriter(const DGR& digraph,
+                                            const char *fn);
 
     DigraphWriter(DigraphWriter& other)
       : _os(other._os), local_os(other.local_os), _digraph(other._digraph),
@@ -933,39 +915,49 @@
     /// @}
   };
 
+  /// \brief Return a \ref DigraphWriter class
+  ///
+  /// This function just returns a \ref DigraphWriter class.
+  /// \relates DigraphWriter
+  template <typename Digraph>
+  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
+                                       std::ostream& os) {
+    DigraphWriter<Digraph> tmp(digraph, os);
+    return tmp;
+  }
+
+  /// \brief Return a \ref DigraphWriter class
+  ///
+  /// This function just returns a \ref DigraphWriter class.
+  /// \relates DigraphWriter
+  template <typename Digraph>
+  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
+                                       const std::string& fn) {
+    DigraphWriter<Digraph> tmp(digraph, fn);
+    return tmp;
+  }
+
+  /// \brief Return a \ref DigraphWriter class
+  ///
+  /// This function just returns a \ref DigraphWriter class.
+  /// \relates DigraphWriter
+  template <typename Digraph>
+  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
+                                       const char* fn) {
+    DigraphWriter<Digraph> tmp(digraph, fn);
+    return tmp;
+  }
+
   template <typename Graph>
   class GraphWriter;
 
-  /// \brief Return a \ref GraphWriter class
-  ///
-  /// This function just returns a \ref GraphWriter class.
-  /// \relates GraphWriter
   template <typename Graph>
   GraphWriter<Graph> graphWriter(const Graph& graph,
-                                 std::ostream& os = std::cout) {
-    GraphWriter<Graph> tmp(graph, os);
-    return tmp;
-  }
-
-  /// \brief Return a \ref GraphWriter class
-  ///
-  /// This function just returns a \ref GraphWriter class.
-  /// \relates GraphWriter
+                                 std::ostream& os = std::cout);
   template <typename Graph>
-  GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) {
-    GraphWriter<Graph> tmp(graph, fn);
-    return tmp;
-  }
-
-  /// \brief Return a \ref GraphWriter class
-  ///
-  /// This function just returns a \ref GraphWriter class.
-  /// \relates GraphWriter
+  GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn);
   template <typename Graph>
-  GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) {
-    GraphWriter<Graph> tmp(graph, fn);
-    return tmp;
-  }
+  GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn);
 
   /// \ingroup lemon_io
   ///
@@ -1081,13 +1073,16 @@
 
   private:
 
-    friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
-                                            std::ostream& os);
-    friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
-                                            const std::string& fn);
-    friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
-                                            const char *fn);
-
+    template <typename GR>
+    friend GraphWriter<GR> graphWriter(const GR& graph,
+                                       std::ostream& os);
+    template <typename GR>
+    friend GraphWriter<GR> graphWriter(const GR& graph,
+                                       const std::string& fn);
+    template <typename GR>
+    friend GraphWriter<GR> graphWriter(const GR& graph,
+                                       const char *fn);
+    
     GraphWriter(GraphWriter& other)
       : _os(other._os), local_os(other.local_os), _graph(other._graph),
         _skip_nodes(other._skip_nodes), _skip_edges(other._skip_edges) {
@@ -1534,6 +1529,37 @@
     /// @}
   };
 
+  /// \brief Return a \ref GraphWriter class
+  ///
+  /// This function just returns a \ref GraphWriter class.
+  /// \relates GraphWriter
+  template <typename Graph>
+  GraphWriter<Graph> graphWriter(const Graph& graph,
+                                 std::ostream& os) {
+    GraphWriter<Graph> tmp(graph, os);
+    return tmp;
+  }
+
+  /// \brief Return a \ref GraphWriter class
+  ///
+  /// This function just returns a \ref GraphWriter class.
+  /// \relates GraphWriter
+  template <typename Graph>
+  GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) {
+    GraphWriter<Graph> tmp(graph, fn);
+    return tmp;
+  }
+
+  /// \brief Return a \ref GraphWriter class
+  ///
+  /// This function just returns a \ref GraphWriter class.
+  /// \relates GraphWriter
+  template <typename Graph>
+  GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) {
+    GraphWriter<Graph> tmp(graph, fn);
+    return tmp;
+  }
+
   class SectionWriter;
 
   SectionWriter sectionWriter(std::istream& is);
diff -r 65f80c81d41c -r d3524090d5e2 lemon/path.h
--- a/lemon/path.h	Mon Feb 16 18:11:10 2009 +0000
+++ b/lemon/path.h	Fri Feb 20 20:51:11 2009 +0000
@@ -929,9 +929,8 @@
     };
 
     template <typename Target, typename Source,
-              bool buildEnable = BuildTagIndicator<Target>::value,
-              bool revEnable = RevPathTagIndicator<Source>::value>
-    struct PathCopySelector {
+              bool buildEnable = BuildTagIndicator<Target>::value>
+    struct PathCopySelectorForward {
       static void copy(Target& target, const Source& source) {
         target.clear();
         for (typename Source::ArcIt it(source); it != INVALID; ++it) {
@@ -941,7 +940,16 @@
     };
 
     template <typename Target, typename Source>
-    struct PathCopySelector<Target, Source, false, true> {
+    struct PathCopySelectorForward<Target, Source, true> {
+      static void copy(Target& target, const Source& source) {
+        target.clear();
+        target.build(source);
+      }
+    };
+
+    template <typename Target, typename Source,
+              bool buildEnable = BuildTagIndicator<Target>::value>
+    struct PathCopySelectorBackward {
       static void copy(Target& target, const Source& source) {
         target.clear();
         for (typename Source::RevArcIt it(source); it != INVALID; ++it) {
@@ -951,21 +959,29 @@
     };
 
     template <typename Target, typename Source>
-    struct PathCopySelector<Target, Source, true, false> {
-      static void copy(Target& target, const Source& source) {
-        target.clear();
-        target.build(source);
-      }
-    };
-
-    template <typename Target, typename Source>
-    struct PathCopySelector<Target, Source, true, true> {
+    struct PathCopySelectorBackward<Target, Source, true> {
       static void copy(Target& target, const Source& source) {
         target.clear();
         target.buildRev(source);
       }
     };
 
+    
+    template <typename Target, typename Source,
+              bool revEnable = RevPathTagIndicator<Source>::value>
+    struct PathCopySelector {
+      static void copy(Target& target, const Source& source) {
+        PathCopySelectorForward<Target, Source>::copy(target, source);
+      }      
+    };
+
+    template <typename Target, typename Source>
+    struct PathCopySelector<Target, Source, true> {
+      static void copy(Target& target, const Source& source) {
+        PathCopySelectorBackward<Target, Source>::copy(target, source);
+      }      
+    };
+
   }
 
 
diff -r 65f80c81d41c -r d3524090d5e2 lemon/random.h
--- a/lemon/random.h	Mon Feb 16 18:11:10 2009 +0000
+++ b/lemon/random.h	Fri Feb 20 20:51:11 2009 +0000
@@ -344,56 +344,46 @@
       }
     };
 
-    template <typename Result, int exp, bool pos = (exp >= 0)>
+    template <typename Result, int exp>
     struct ShiftMultiplier {
       static const Result multiplier() {
         Result res = ShiftMultiplier<Result, exp / 2>::multiplier();
         res *= res;
-        if ((exp & 1) == 1) res *= static_cast<Result>(2.0);
-        return res;
-      }
-    };
-
-    template <typename Result, int exp>
-    struct ShiftMultiplier<Result, exp, false> {
-      static const Result multiplier() {
-        Result res = ShiftMultiplier<Result, exp / 2>::multiplier();
-        res *= res;
         if ((exp & 1) == 1) res *= static_cast<Result>(0.5);
         return res;
       }
     };
 
     template <typename Result>
-    struct ShiftMultiplier<Result, 0, true> {
+    struct ShiftMultiplier<Result, 0> {
       static const Result multiplier() {
         return static_cast<Result>(1.0);
       }
     };
 
     template <typename Result>
-    struct ShiftMultiplier<Result, -20, true> {
+    struct ShiftMultiplier<Result, 20> {
       static const Result multiplier() {
         return static_cast<Result>(1.0/1048576.0);
       }
     };
 
     template <typename Result>
-    struct ShiftMultiplier<Result, -32, true> {
+    struct ShiftMultiplier<Result, 32> {
       static const Result multiplier() {
-        return static_cast<Result>(1.0/424967296.0);
+        return static_cast<Result>(1.0/4294967296.0);
       }
     };
 
     template <typename Result>
-    struct ShiftMultiplier<Result, -53, true> {
+    struct ShiftMultiplier<Result, 53> {
       static const Result multiplier() {
         return static_cast<Result>(1.0/9007199254740992.0);
       }
     };
 
     template <typename Result>
-    struct ShiftMultiplier<Result, -64, true> {
+    struct ShiftMultiplier<Result, 64> {
       static const Result multiplier() {
         return static_cast<Result>(1.0/18446744073709551616.0);
       }
@@ -413,7 +403,7 @@
       static const int bits = std::numeric_limits<Word>::digits;
 
       static Result convert(RandomCore<Word>& rnd) {
-        return Shifting<Result, - shift - rest>::
+        return Shifting<Result, shift + rest>::
           shift(static_cast<Result>(rnd() >> (bits - rest)));
       }
     };
@@ -423,7 +413,7 @@
       static const int bits = std::numeric_limits<Word>::digits;
 
       static Result convert(RandomCore<Word>& rnd) {
-        return Shifting<Result, - shift - bits>::
+        return Shifting<Result, shift + bits>::
           shift(static_cast<Result>(rnd())) +
           RealConversion<Result, Word, rest-bits, shift + bits>::
           convert(rnd);
diff -r 65f80c81d41c -r d3524090d5e2 lemon/tolerance.h
--- a/lemon/tolerance.h	Mon Feb 16 18:11:10 2009 +0000
+++ b/lemon/tolerance.h	Fri Feb 20 20:51:11 2009 +0000
@@ -38,17 +38,14 @@
   ///handle the comparison of numbers that are obtained
   ///as a result of a probably inexact computation.
   ///
-  ///This is an abstract class, it should be specialized for all
-  ///numerical data types. These specialized classes like
+  ///The general implementation is suitable only if the data type is exact,
+  ///like the integer types, otherwise a specialized version must be
+  ///implemented. These specialized classes like
   ///Tolerance<double> may offer additional tuning parameters.
   ///
   ///\sa Tolerance<float>
   ///\sa Tolerance<double>
   ///\sa Tolerance<long double>
-  ///\sa Tolerance<int>
-  ///\sa Tolerance<long long int>
-  ///\sa Tolerance<unsigned int>
-  ///\sa Tolerance<unsigned long long int>
 
   template<class T>
   class Tolerance
@@ -64,20 +61,20 @@
     ///@{
 
     ///Returns \c true if \c a is \e surely strictly less than \c b
-    static bool less(Value a,Value b) {return false;}
+    static bool less(Value a,Value b) {return a<b;}
     ///Returns \c true if \c a is \e surely different from \c b
-    static bool different(Value a,Value b) {return false;}
+    static bool different(Value a,Value b) {return a!=b;}
     ///Returns \c true if \c a is \e surely positive
-    static bool positive(Value a) {return false;}
+    static bool positive(Value a) {return static_cast<Value>(0) < a;}
     ///Returns \c true if \c a is \e surely negative
-    static bool negative(Value a) {return false;}
+    static bool negative(Value a) {return a < static_cast<Value>(0);}
     ///Returns \c true if \c a is \e surely non-zero
-    static bool nonZero(Value a) {return false;}
+    static bool nonZero(Value a) {return a != static_cast<Value>(0);}
 
     ///@}
 
     ///Returns the zero value.
-    static Value zero() {return T();}
+    static Value zero() {return static_cast<Value>(0);}
 
     //   static bool finite(Value a) {}
     //   static Value big() {}
@@ -238,213 +235,6 @@
     static Value zero() {return 0;}
   };
 
-  ///Integer specialization of Tolerance.
-
-  ///Integer specialization of Tolerance.
-  ///\sa Tolerance
-  template<>
-  class Tolerance<int>
-  {
-  public:
-    ///\e
-    typedef int Value;
-
-    ///\name Comparisons
-    ///See \ref lemon::Tolerance "Tolerance" for more details.
-
-    ///@{
-
-    ///Returns \c true if \c a is \e surely strictly less than \c b
-    static bool less(Value a,Value b) { return a<b;}
-    ///Returns \c true if \c a is \e surely different from \c b
-    static bool different(Value a,Value b) { return a!=b; }
-    ///Returns \c true if \c a is \e surely positive
-    static bool positive(Value a) { return 0<a; }
-    ///Returns \c true if \c a is \e surely negative
-    static bool negative(Value a) { return 0>a; }
-    ///Returns \c true if \c a is \e surely non-zero
-    static bool nonZero(Value a) { return a!=0; }
-
-    ///@}
-
-    ///Returns zero
-    static Value zero() {return 0;}
-  };
-
-  ///Unsigned integer specialization of Tolerance.
-
-  ///Unsigned integer specialization of Tolerance.
-  ///\sa Tolerance
-  template<>
-  class Tolerance<unsigned int>
-  {
-  public:
-    ///\e
-    typedef unsigned int Value;
-
-    ///\name Comparisons
-    ///See \ref lemon::Tolerance "Tolerance" for more details.
-
-    ///@{
-
-    ///Returns \c true if \c a is \e surely strictly less than \c b
-    static bool less(Value a,Value b) { return a<b;}
-    ///Returns \c true if \c a is \e surely different from \c b
-    static bool different(Value a,Value b) { return a!=b; }
-    ///Returns \c true if \c a is \e surely positive
-    static bool positive(Value a) { return 0<a; }
-    ///Returns \c true if \c a is \e surely negative
-    static bool negative(Value) { return false; }
-    ///Returns \c true if \c a is \e surely non-zero
-    static bool nonZero(Value a) { return a!=0; }
-
-    ///@}
-
-    ///Returns zero
-    static Value zero() {return 0;}
-  };
-
-
-  ///Long integer specialization of Tolerance.
-
-  ///Long integer specialization of Tolerance.
-  ///\sa Tolerance
-  template<>
-  class Tolerance<long int>
-  {
-  public:
-    ///\e
-    typedef long int Value;
-
-    ///\name Comparisons
-    ///See \ref lemon::Tolerance "Tolerance" for more details.
-
-    ///@{
-
-    ///Returns \c true if \c a is \e surely strictly less than \c b
-    static bool less(Value a,Value b) { return a<b;}
-    ///Returns \c true if \c a is \e surely different from \c b
-    static bool different(Value a,Value b) { return a!=b; }
-    ///Returns \c true if \c a is \e surely positive
-    static bool positive(Value a) { return 0<a; }
-    ///Returns \c true if \c a is \e surely negative
-    static bool negative(Value a) { return 0>a; }
-    ///Returns \c true if \c a is \e surely non-zero
-    static bool nonZero(Value a) { return a!=0;}
-
-    ///@}
-
-    ///Returns zero
-    static Value zero() {return 0;}
-  };
-
-  ///Unsigned long integer specialization of Tolerance.
-
-  ///Unsigned long integer specialization of Tolerance.
-  ///\sa Tolerance
-  template<>
-  class Tolerance<unsigned long int>
-  {
-  public:
-    ///\e
-    typedef unsigned long int Value;
-
-    ///\name Comparisons
-    ///See \ref lemon::Tolerance "Tolerance" for more details.
-
-    ///@{
-
-    ///Returns \c true if \c a is \e surely strictly less than \c b
-    static bool less(Value a,Value b) { return a<b;}
-    ///Returns \c true if \c a is \e surely different from \c b
-    static bool different(Value a,Value b) { return a!=b; }
-    ///Returns \c true if \c a is \e surely positive
-    static bool positive(Value a) { return 0<a; }
-    ///Returns \c true if \c a is \e surely negative
-    static bool negative(Value) { return false; }
-    ///Returns \c true if \c a is \e surely non-zero
-    static bool nonZero(Value a) { return a!=0;}
-
-    ///@}
-
-    ///Returns zero
-    static Value zero() {return 0;}
-  };
-
-#if defined __GNUC__ && !defined __STRICT_ANSI__
-
-  ///Long long integer specialization of Tolerance.
-
-  ///Long long integer specialization of Tolerance.
-  ///\warning This class (more exactly, type <tt>long long</tt>)
-  ///is not ansi compatible.
-  ///\sa Tolerance
-  template<>
-  class Tolerance<long long int>
-  {
-  public:
-    ///\e
-    typedef long long int Value;
-
-    ///\name Comparisons
-    ///See \ref lemon::Tolerance "Tolerance" for more details.
-
-    ///@{
-
-    ///Returns \c true if \c a is \e surely strictly less than \c b
-    static bool less(Value a,Value b) { return a<b;}
-    ///Returns \c true if \c a is \e surely different from \c b
-    static bool different(Value a,Value b) { return a!=b; }
-    ///Returns \c true if \c a is \e surely positive
-    static bool positive(Value a) { return 0<a; }
-    ///Returns \c true if \c a is \e surely negative
-    static bool negative(Value a) { return 0>a; }
-    ///Returns \c true if \c a is \e surely non-zero
-    static bool nonZero(Value a) { return a!=0;}
-
-    ///@}
-
-    ///Returns zero
-    static Value zero() {return 0;}
-  };
-
-  ///Unsigned long long integer specialization of Tolerance.
-
-  ///Unsigned long long integer specialization of Tolerance.
-  ///\warning This class (more exactly, type <tt>unsigned long long</tt>)
-  ///is not ansi compatible.
-  ///\sa Tolerance
-  template<>
-  class Tolerance<unsigned long long int>
-  {
-  public:
-    ///\e
-    typedef unsigned long long int Value;
-
-    ///\name Comparisons
-    ///See \ref lemon::Tolerance "Tolerance" for more details.
-
-    ///@{
-
-    ///Returns \c true if \c a is \e surely strictly less than \c b
-    static bool less(Value a,Value b) { return a<b;}
-    ///Returns \c true if \c a is \e surely different from \c b
-    static bool different(Value a,Value b) { return a!=b; }
-    ///Returns \c true if \c a is \e surely positive
-    static bool positive(Value a) { return 0<a; }
-    ///Returns \c true if \c a is \e surely negative
-    static bool negative(Value) { return false; }
-    ///Returns \c true if \c a is \e surely non-zero
-    static bool nonZero(Value a) { return a!=0;}
-
-    ///@}
-
-    ///Returns zero
-    static Value zero() {return 0;}
-  };
-
-#endif
-
   /// @}
 
 } //namespace lemon