diff --git a/lemon/lgf_reader.h b/lemon/lgf_reader.h --- a/lemon/lgf_reader.h +++ b/lemon/lgf_reader.h @@ -390,37 +390,13 @@ template class DigraphReader; - /// \brief Return a \ref DigraphReader class - /// - /// This function just returns a \ref DigraphReader class. - /// \relates DigraphReader template - DigraphReader digraphReader(Digraph& digraph, - std::istream& is = std::cin) { - DigraphReader tmp(digraph, is); - return tmp; - } - - /// \brief Return a \ref DigraphReader class - /// - /// This function just returns a \ref DigraphReader class. - /// \relates DigraphReader + DigraphReader digraphReader(Digraph& digraph, + std::istream& is = std::cin); template - DigraphReader digraphReader(Digraph& digraph, - const std::string& fn) { - DigraphReader tmp(digraph, fn); - return tmp; - } - - /// \brief Return a \ref DigraphReader class - /// - /// This function just returns a \ref DigraphReader class. - /// \relates DigraphReader + DigraphReader digraphReader(Digraph& digraph, const std::string& fn); template - DigraphReader digraphReader(Digraph& digraph, const char* fn) { - DigraphReader tmp(digraph, fn); - return tmp; - } + DigraphReader digraphReader(Digraph& digraph, const char *fn); /// \ingroup lemon_io /// @@ -584,12 +560,13 @@ private: - friend DigraphReader digraphReader<>(Digraph& digraph, - std::istream& is); - friend DigraphReader digraphReader<>(Digraph& digraph, - const std::string& fn); - friend DigraphReader digraphReader<>(Digraph& digraph, - const char *fn); + template + friend DigraphReader digraphReader(DGR& digraph, std::istream& is); + template + friend DigraphReader digraphReader(DGR& digraph, + const std::string& fn); + template + friend DigraphReader digraphReader(DGR& digraph, const char *fn); DigraphReader(DigraphReader& other) : _is(other._is), local_is(other.local_is), _digraph(other._digraph), @@ -1210,38 +1187,47 @@ }; + /// \brief Return a \ref DigraphReader class + /// + /// This function just returns a \ref DigraphReader class. + /// \relates DigraphReader + template + DigraphReader digraphReader(Digraph& digraph, std::istream& is) { + DigraphReader tmp(digraph, is); + return tmp; + } + + /// \brief Return a \ref DigraphReader class + /// + /// This function just returns a \ref DigraphReader class. + /// \relates DigraphReader + template + DigraphReader digraphReader(Digraph& digraph, + const std::string& fn) { + DigraphReader tmp(digraph, fn); + return tmp; + } + + /// \brief Return a \ref DigraphReader class + /// + /// This function just returns a \ref DigraphReader class. + /// \relates DigraphReader + template + DigraphReader digraphReader(Digraph& digraph, const char* fn) { + DigraphReader tmp(digraph, fn); + return tmp; + } + template class GraphReader; - - /// \brief Return a \ref GraphReader class - /// - /// This function just returns a \ref GraphReader class. - /// \relates GraphReader + template - GraphReader graphReader(Graph& graph, std::istream& is = std::cin) { - GraphReader tmp(graph, is); - return tmp; - } - - /// \brief Return a \ref GraphReader class - /// - /// This function just returns a \ref GraphReader class. - /// \relates GraphReader + GraphReader graphReader(Graph& graph, + std::istream& is = std::cin); template - GraphReader graphReader(Graph& graph, const std::string& fn) { - GraphReader tmp(graph, fn); - return tmp; - } - - /// \brief Return a \ref GraphReader class - /// - /// This function just returns a \ref GraphReader class. - /// \relates GraphReader + GraphReader graphReader(Graph& graph, const std::string& fn); template - GraphReader graphReader(Graph& graph, const char* fn) { - GraphReader tmp(graph, fn); - return tmp; - } + GraphReader graphReader(Graph& graph, const char *fn); /// \ingroup lemon_io /// @@ -1368,10 +1354,12 @@ } private: - friend GraphReader graphReader<>(Graph& graph, std::istream& is); - friend GraphReader graphReader<>(Graph& graph, - const std::string& fn); - friend GraphReader graphReader<>(Graph& graph, const char *fn); + template + friend GraphReader graphReader(GR& graph, std::istream& is); + template + friend GraphReader graphReader(GR& graph, const std::string& fn); + template + friend GraphReader graphReader(GR& graph, const char *fn); GraphReader(GraphReader& other) : _is(other._is), local_is(other.local_is), _graph(other._graph), @@ -2040,6 +2028,36 @@ }; + /// \brief Return a \ref GraphReader class + /// + /// This function just returns a \ref GraphReader class. + /// \relates GraphReader + template + GraphReader graphReader(Graph& graph, std::istream& is) { + GraphReader tmp(graph, is); + return tmp; + } + + /// \brief Return a \ref GraphReader class + /// + /// This function just returns a \ref GraphReader class. + /// \relates GraphReader + template + GraphReader graphReader(Graph& graph, const std::string& fn) { + GraphReader tmp(graph, fn); + return tmp; + } + + /// \brief Return a \ref GraphReader class + /// + /// This function just returns a \ref GraphReader class. + /// \relates GraphReader + template + GraphReader graphReader(Graph& graph, const char* fn) { + GraphReader tmp(graph, fn); + return tmp; + } + class SectionReader; SectionReader sectionReader(std::istream& is); diff --git a/lemon/lgf_writer.h b/lemon/lgf_writer.h --- a/lemon/lgf_writer.h +++ b/lemon/lgf_writer.h @@ -350,38 +350,17 @@ template class DigraphWriter; - /// \brief Return a \ref DigraphWriter class - /// - /// This function just returns a \ref DigraphWriter class. - /// \relates DigraphWriter template DigraphWriter digraphWriter(const Digraph& digraph, - std::ostream& os = std::cout) { - DigraphWriter 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 DigraphWriter digraphWriter(const Digraph& digraph, - const std::string& fn) { - DigraphWriter 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 DigraphWriter digraphWriter(const Digraph& digraph, - const char* fn) { - DigraphWriter tmp(digraph, fn); - return tmp; - } + const char* fn); + /// \ingroup lemon_io /// @@ -526,12 +505,15 @@ private: - friend DigraphWriter digraphWriter<>(const Digraph& digraph, - std::ostream& os); - friend DigraphWriter digraphWriter<>(const Digraph& digraph, - const std::string& fn); - friend DigraphWriter digraphWriter<>(const Digraph& digraph, - const char *fn); + template + friend DigraphWriter digraphWriter(const DGR& digraph, + std::ostream& os); + template + friend DigraphWriter digraphWriter(const DGR& digraph, + const std::string& fn); + template + friend DigraphWriter 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 + DigraphWriter digraphWriter(const Digraph& digraph, + std::ostream& os) { + DigraphWriter tmp(digraph, os); + return tmp; + } + + /// \brief Return a \ref DigraphWriter class + /// + /// This function just returns a \ref DigraphWriter class. + /// \relates DigraphWriter + template + DigraphWriter digraphWriter(const Digraph& digraph, + const std::string& fn) { + DigraphWriter tmp(digraph, fn); + return tmp; + } + + /// \brief Return a \ref DigraphWriter class + /// + /// This function just returns a \ref DigraphWriter class. + /// \relates DigraphWriter + template + DigraphWriter digraphWriter(const Digraph& digraph, + const char* fn) { + DigraphWriter tmp(digraph, fn); + return tmp; + } + template class GraphWriter; - /// \brief Return a \ref GraphWriter class - /// - /// This function just returns a \ref GraphWriter class. - /// \relates GraphWriter template GraphWriter graphWriter(const Graph& graph, - std::ostream& os = std::cout) { - GraphWriter 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 - GraphWriter graphWriter(const Graph& graph, const std::string& fn) { - GraphWriter tmp(graph, fn); - return tmp; - } - - /// \brief Return a \ref GraphWriter class - /// - /// This function just returns a \ref GraphWriter class. - /// \relates GraphWriter + GraphWriter graphWriter(const Graph& graph, const std::string& fn); template - GraphWriter graphWriter(const Graph& graph, const char* fn) { - GraphWriter tmp(graph, fn); - return tmp; - } + GraphWriter graphWriter(const Graph& graph, const char* fn); /// \ingroup lemon_io /// @@ -1081,13 +1073,16 @@ private: - friend GraphWriter graphWriter<>(const Graph& graph, - std::ostream& os); - friend GraphWriter graphWriter<>(const Graph& graph, - const std::string& fn); - friend GraphWriter graphWriter<>(const Graph& graph, - const char *fn); - + template + friend GraphWriter graphWriter(const GR& graph, + std::ostream& os); + template + friend GraphWriter graphWriter(const GR& graph, + const std::string& fn); + template + friend GraphWriter 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 + GraphWriter graphWriter(const Graph& graph, + std::ostream& os) { + GraphWriter tmp(graph, os); + return tmp; + } + + /// \brief Return a \ref GraphWriter class + /// + /// This function just returns a \ref GraphWriter class. + /// \relates GraphWriter + template + GraphWriter graphWriter(const Graph& graph, const std::string& fn) { + GraphWriter tmp(graph, fn); + return tmp; + } + + /// \brief Return a \ref GraphWriter class + /// + /// This function just returns a \ref GraphWriter class. + /// \relates GraphWriter + template + GraphWriter graphWriter(const Graph& graph, const char* fn) { + GraphWriter tmp(graph, fn); + return tmp; + } + class SectionWriter; SectionWriter sectionWriter(std::istream& is); diff --git a/lemon/path.h b/lemon/path.h --- a/lemon/path.h +++ b/lemon/path.h @@ -929,9 +929,8 @@ }; template ::value, - bool revEnable = RevPathTagIndicator::value> - struct PathCopySelector { + bool buildEnable = BuildTagIndicator::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 - struct PathCopySelector { + struct PathCopySelectorForward { + static void copy(Target& target, const Source& source) { + target.clear(); + target.build(source); + } + }; + + template ::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 - struct PathCopySelector { - static void copy(Target& target, const Source& source) { - target.clear(); - target.build(source); - } - }; - - template - struct PathCopySelector { + struct PathCopySelectorBackward { static void copy(Target& target, const Source& source) { target.clear(); target.buildRev(source); } }; + + template ::value> + struct PathCopySelector { + static void copy(Target& target, const Source& source) { + PathCopySelectorForward::copy(target, source); + } + }; + + template + struct PathCopySelector { + static void copy(Target& target, const Source& source) { + PathCopySelectorBackward::copy(target, source); + } + }; + } diff --git a/lemon/random.h b/lemon/random.h --- a/lemon/random.h +++ b/lemon/random.h @@ -344,56 +344,46 @@ } }; - template = 0)> + template struct ShiftMultiplier { static const Result multiplier() { Result res = ShiftMultiplier::multiplier(); res *= res; - if ((exp & 1) == 1) res *= static_cast(2.0); - return res; - } - }; - - template - struct ShiftMultiplier { - static const Result multiplier() { - Result res = ShiftMultiplier::multiplier(); - res *= res; if ((exp & 1) == 1) res *= static_cast(0.5); return res; } }; template - struct ShiftMultiplier { + struct ShiftMultiplier { static const Result multiplier() { return static_cast(1.0); } }; template - struct ShiftMultiplier { + struct ShiftMultiplier { static const Result multiplier() { return static_cast(1.0/1048576.0); } }; template - struct ShiftMultiplier { + struct ShiftMultiplier { static const Result multiplier() { - return static_cast(1.0/424967296.0); + return static_cast(1.0/4294967296.0); } }; template - struct ShiftMultiplier { + struct ShiftMultiplier { static const Result multiplier() { return static_cast(1.0/9007199254740992.0); } }; template - struct ShiftMultiplier { + struct ShiftMultiplier { static const Result multiplier() { return static_cast(1.0/18446744073709551616.0); } @@ -413,7 +403,7 @@ static const int bits = std::numeric_limits::digits; static Result convert(RandomCore& rnd) { - return Shifting:: + return Shifting:: shift(static_cast(rnd() >> (bits - rest))); } }; @@ -423,7 +413,7 @@ static const int bits = std::numeric_limits::digits; static Result convert(RandomCore& rnd) { - return Shifting:: + return Shifting:: shift(static_cast(rnd())) + RealConversion:: convert(rnd);