1.1 --- a/lemon/lgf_reader.h Mon Feb 16 15:03:32 2009 +0000
1.2 +++ b/lemon/lgf_reader.h Fri Feb 20 20:36:26 2009 +0000
1.3 @@ -390,37 +390,13 @@
1.4 template <typename Digraph>
1.5 class DigraphReader;
1.6
1.7 - /// \brief Return a \ref DigraphReader class
1.8 - ///
1.9 - /// This function just returns a \ref DigraphReader class.
1.10 - /// \relates DigraphReader
1.11 template <typename Digraph>
1.12 - DigraphReader<Digraph> digraphReader(Digraph& digraph,
1.13 - std::istream& is = std::cin) {
1.14 - DigraphReader<Digraph> tmp(digraph, is);
1.15 - return tmp;
1.16 - }
1.17 -
1.18 - /// \brief Return a \ref DigraphReader class
1.19 - ///
1.20 - /// This function just returns a \ref DigraphReader class.
1.21 - /// \relates DigraphReader
1.22 + DigraphReader<Digraph> digraphReader(Digraph& digraph,
1.23 + std::istream& is = std::cin);
1.24 template <typename Digraph>
1.25 - DigraphReader<Digraph> digraphReader(Digraph& digraph,
1.26 - const std::string& fn) {
1.27 - DigraphReader<Digraph> tmp(digraph, fn);
1.28 - return tmp;
1.29 - }
1.30 -
1.31 - /// \brief Return a \ref DigraphReader class
1.32 - ///
1.33 - /// This function just returns a \ref DigraphReader class.
1.34 - /// \relates DigraphReader
1.35 + DigraphReader<Digraph> digraphReader(Digraph& digraph, const std::string& fn);
1.36 template <typename Digraph>
1.37 - DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) {
1.38 - DigraphReader<Digraph> tmp(digraph, fn);
1.39 - return tmp;
1.40 - }
1.41 + DigraphReader<Digraph> digraphReader(Digraph& digraph, const char *fn);
1.42
1.43 /// \ingroup lemon_io
1.44 ///
1.45 @@ -584,12 +560,13 @@
1.46
1.47 private:
1.48
1.49 - friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
1.50 - std::istream& is);
1.51 - friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
1.52 - const std::string& fn);
1.53 - friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
1.54 - const char *fn);
1.55 + template <typename DGR>
1.56 + friend DigraphReader<DGR> digraphReader(DGR& digraph, std::istream& is);
1.57 + template <typename DGR>
1.58 + friend DigraphReader<DGR> digraphReader(DGR& digraph,
1.59 + const std::string& fn);
1.60 + template <typename DGR>
1.61 + friend DigraphReader<DGR> digraphReader(DGR& digraph, const char *fn);
1.62
1.63 DigraphReader(DigraphReader& other)
1.64 : _is(other._is), local_is(other.local_is), _digraph(other._digraph),
1.65 @@ -1210,38 +1187,47 @@
1.66
1.67 };
1.68
1.69 + /// \brief Return a \ref DigraphReader class
1.70 + ///
1.71 + /// This function just returns a \ref DigraphReader class.
1.72 + /// \relates DigraphReader
1.73 + template <typename Digraph>
1.74 + DigraphReader<Digraph> digraphReader(Digraph& digraph, std::istream& is) {
1.75 + DigraphReader<Digraph> tmp(digraph, is);
1.76 + return tmp;
1.77 + }
1.78 +
1.79 + /// \brief Return a \ref DigraphReader class
1.80 + ///
1.81 + /// This function just returns a \ref DigraphReader class.
1.82 + /// \relates DigraphReader
1.83 + template <typename Digraph>
1.84 + DigraphReader<Digraph> digraphReader(Digraph& digraph,
1.85 + const std::string& fn) {
1.86 + DigraphReader<Digraph> tmp(digraph, fn);
1.87 + return tmp;
1.88 + }
1.89 +
1.90 + /// \brief Return a \ref DigraphReader class
1.91 + ///
1.92 + /// This function just returns a \ref DigraphReader class.
1.93 + /// \relates DigraphReader
1.94 + template <typename Digraph>
1.95 + DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) {
1.96 + DigraphReader<Digraph> tmp(digraph, fn);
1.97 + return tmp;
1.98 + }
1.99 +
1.100 template <typename Graph>
1.101 class GraphReader;
1.102 -
1.103 - /// \brief Return a \ref GraphReader class
1.104 - ///
1.105 - /// This function just returns a \ref GraphReader class.
1.106 - /// \relates GraphReader
1.107 +
1.108 template <typename Graph>
1.109 - GraphReader<Graph> graphReader(Graph& graph, std::istream& is = std::cin) {
1.110 - GraphReader<Graph> tmp(graph, is);
1.111 - return tmp;
1.112 - }
1.113 -
1.114 - /// \brief Return a \ref GraphReader class
1.115 - ///
1.116 - /// This function just returns a \ref GraphReader class.
1.117 - /// \relates GraphReader
1.118 + GraphReader<Graph> graphReader(Graph& graph,
1.119 + std::istream& is = std::cin);
1.120 template <typename Graph>
1.121 - GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) {
1.122 - GraphReader<Graph> tmp(graph, fn);
1.123 - return tmp;
1.124 - }
1.125 -
1.126 - /// \brief Return a \ref GraphReader class
1.127 - ///
1.128 - /// This function just returns a \ref GraphReader class.
1.129 - /// \relates GraphReader
1.130 + GraphReader<Graph> graphReader(Graph& graph, const std::string& fn);
1.131 template <typename Graph>
1.132 - GraphReader<Graph> graphReader(Graph& graph, const char* fn) {
1.133 - GraphReader<Graph> tmp(graph, fn);
1.134 - return tmp;
1.135 - }
1.136 + GraphReader<Graph> graphReader(Graph& graph, const char *fn);
1.137
1.138 /// \ingroup lemon_io
1.139 ///
1.140 @@ -1368,10 +1354,12 @@
1.141 }
1.142
1.143 private:
1.144 - friend GraphReader<Graph> graphReader<>(Graph& graph, std::istream& is);
1.145 - friend GraphReader<Graph> graphReader<>(Graph& graph,
1.146 - const std::string& fn);
1.147 - friend GraphReader<Graph> graphReader<>(Graph& graph, const char *fn);
1.148 + template <typename GR>
1.149 + friend GraphReader<GR> graphReader(GR& graph, std::istream& is);
1.150 + template <typename GR>
1.151 + friend GraphReader<GR> graphReader(GR& graph, const std::string& fn);
1.152 + template <typename GR>
1.153 + friend GraphReader<GR> graphReader(GR& graph, const char *fn);
1.154
1.155 GraphReader(GraphReader& other)
1.156 : _is(other._is), local_is(other.local_is), _graph(other._graph),
1.157 @@ -2040,6 +2028,36 @@
1.158
1.159 };
1.160
1.161 + /// \brief Return a \ref GraphReader class
1.162 + ///
1.163 + /// This function just returns a \ref GraphReader class.
1.164 + /// \relates GraphReader
1.165 + template <typename Graph>
1.166 + GraphReader<Graph> graphReader(Graph& graph, std::istream& is) {
1.167 + GraphReader<Graph> tmp(graph, is);
1.168 + return tmp;
1.169 + }
1.170 +
1.171 + /// \brief Return a \ref GraphReader class
1.172 + ///
1.173 + /// This function just returns a \ref GraphReader class.
1.174 + /// \relates GraphReader
1.175 + template <typename Graph>
1.176 + GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) {
1.177 + GraphReader<Graph> tmp(graph, fn);
1.178 + return tmp;
1.179 + }
1.180 +
1.181 + /// \brief Return a \ref GraphReader class
1.182 + ///
1.183 + /// This function just returns a \ref GraphReader class.
1.184 + /// \relates GraphReader
1.185 + template <typename Graph>
1.186 + GraphReader<Graph> graphReader(Graph& graph, const char* fn) {
1.187 + GraphReader<Graph> tmp(graph, fn);
1.188 + return tmp;
1.189 + }
1.190 +
1.191 class SectionReader;
1.192
1.193 SectionReader sectionReader(std::istream& is);
2.1 --- a/lemon/lgf_writer.h Mon Feb 16 15:03:32 2009 +0000
2.2 +++ b/lemon/lgf_writer.h Fri Feb 20 20:36:26 2009 +0000
2.3 @@ -350,38 +350,17 @@
2.4 template <typename Digraph>
2.5 class DigraphWriter;
2.6
2.7 - /// \brief Return a \ref DigraphWriter class
2.8 - ///
2.9 - /// This function just returns a \ref DigraphWriter class.
2.10 - /// \relates DigraphWriter
2.11 template <typename Digraph>
2.12 DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
2.13 - std::ostream& os = std::cout) {
2.14 - DigraphWriter<Digraph> tmp(digraph, os);
2.15 - return tmp;
2.16 - }
2.17 -
2.18 - /// \brief Return a \ref DigraphWriter class
2.19 - ///
2.20 - /// This function just returns a \ref DigraphWriter class.
2.21 - /// \relates DigraphWriter
2.22 + std::ostream& os = std::cout);
2.23 template <typename Digraph>
2.24 DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
2.25 - const std::string& fn) {
2.26 - DigraphWriter<Digraph> tmp(digraph, fn);
2.27 - return tmp;
2.28 - }
2.29 + const std::string& fn);
2.30
2.31 - /// \brief Return a \ref DigraphWriter class
2.32 - ///
2.33 - /// This function just returns a \ref DigraphWriter class.
2.34 - /// \relates DigraphWriter
2.35 template <typename Digraph>
2.36 DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
2.37 - const char* fn) {
2.38 - DigraphWriter<Digraph> tmp(digraph, fn);
2.39 - return tmp;
2.40 - }
2.41 + const char* fn);
2.42 +
2.43
2.44 /// \ingroup lemon_io
2.45 ///
2.46 @@ -526,12 +505,15 @@
2.47
2.48 private:
2.49
2.50 - friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
2.51 - std::ostream& os);
2.52 - friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
2.53 - const std::string& fn);
2.54 - friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
2.55 - const char *fn);
2.56 + template <typename DGR>
2.57 + friend DigraphWriter<DGR> digraphWriter(const DGR& digraph,
2.58 + std::ostream& os);
2.59 + template <typename DGR>
2.60 + friend DigraphWriter<DGR> digraphWriter(const DGR& digraph,
2.61 + const std::string& fn);
2.62 + template <typename DGR>
2.63 + friend DigraphWriter<DGR> digraphWriter(const DGR& digraph,
2.64 + const char *fn);
2.65
2.66 DigraphWriter(DigraphWriter& other)
2.67 : _os(other._os), local_os(other.local_os), _digraph(other._digraph),
2.68 @@ -933,39 +915,49 @@
2.69 /// @}
2.70 };
2.71
2.72 + /// \brief Return a \ref DigraphWriter class
2.73 + ///
2.74 + /// This function just returns a \ref DigraphWriter class.
2.75 + /// \relates DigraphWriter
2.76 + template <typename Digraph>
2.77 + DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
2.78 + std::ostream& os) {
2.79 + DigraphWriter<Digraph> tmp(digraph, os);
2.80 + return tmp;
2.81 + }
2.82 +
2.83 + /// \brief Return a \ref DigraphWriter class
2.84 + ///
2.85 + /// This function just returns a \ref DigraphWriter class.
2.86 + /// \relates DigraphWriter
2.87 + template <typename Digraph>
2.88 + DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
2.89 + const std::string& fn) {
2.90 + DigraphWriter<Digraph> tmp(digraph, fn);
2.91 + return tmp;
2.92 + }
2.93 +
2.94 + /// \brief Return a \ref DigraphWriter class
2.95 + ///
2.96 + /// This function just returns a \ref DigraphWriter class.
2.97 + /// \relates DigraphWriter
2.98 + template <typename Digraph>
2.99 + DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
2.100 + const char* fn) {
2.101 + DigraphWriter<Digraph> tmp(digraph, fn);
2.102 + return tmp;
2.103 + }
2.104 +
2.105 template <typename Graph>
2.106 class GraphWriter;
2.107
2.108 - /// \brief Return a \ref GraphWriter class
2.109 - ///
2.110 - /// This function just returns a \ref GraphWriter class.
2.111 - /// \relates GraphWriter
2.112 template <typename Graph>
2.113 GraphWriter<Graph> graphWriter(const Graph& graph,
2.114 - std::ostream& os = std::cout) {
2.115 - GraphWriter<Graph> tmp(graph, os);
2.116 - return tmp;
2.117 - }
2.118 -
2.119 - /// \brief Return a \ref GraphWriter class
2.120 - ///
2.121 - /// This function just returns a \ref GraphWriter class.
2.122 - /// \relates GraphWriter
2.123 + std::ostream& os = std::cout);
2.124 template <typename Graph>
2.125 - GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) {
2.126 - GraphWriter<Graph> tmp(graph, fn);
2.127 - return tmp;
2.128 - }
2.129 -
2.130 - /// \brief Return a \ref GraphWriter class
2.131 - ///
2.132 - /// This function just returns a \ref GraphWriter class.
2.133 - /// \relates GraphWriter
2.134 + GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn);
2.135 template <typename Graph>
2.136 - GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) {
2.137 - GraphWriter<Graph> tmp(graph, fn);
2.138 - return tmp;
2.139 - }
2.140 + GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn);
2.141
2.142 /// \ingroup lemon_io
2.143 ///
2.144 @@ -1081,13 +1073,16 @@
2.145
2.146 private:
2.147
2.148 - friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
2.149 - std::ostream& os);
2.150 - friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
2.151 - const std::string& fn);
2.152 - friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
2.153 - const char *fn);
2.154 -
2.155 + template <typename GR>
2.156 + friend GraphWriter<GR> graphWriter(const GR& graph,
2.157 + std::ostream& os);
2.158 + template <typename GR>
2.159 + friend GraphWriter<GR> graphWriter(const GR& graph,
2.160 + const std::string& fn);
2.161 + template <typename GR>
2.162 + friend GraphWriter<GR> graphWriter(const GR& graph,
2.163 + const char *fn);
2.164 +
2.165 GraphWriter(GraphWriter& other)
2.166 : _os(other._os), local_os(other.local_os), _graph(other._graph),
2.167 _skip_nodes(other._skip_nodes), _skip_edges(other._skip_edges) {
2.168 @@ -1534,6 +1529,37 @@
2.169 /// @}
2.170 };
2.171
2.172 + /// \brief Return a \ref GraphWriter class
2.173 + ///
2.174 + /// This function just returns a \ref GraphWriter class.
2.175 + /// \relates GraphWriter
2.176 + template <typename Graph>
2.177 + GraphWriter<Graph> graphWriter(const Graph& graph,
2.178 + std::ostream& os) {
2.179 + GraphWriter<Graph> tmp(graph, os);
2.180 + return tmp;
2.181 + }
2.182 +
2.183 + /// \brief Return a \ref GraphWriter class
2.184 + ///
2.185 + /// This function just returns a \ref GraphWriter class.
2.186 + /// \relates GraphWriter
2.187 + template <typename Graph>
2.188 + GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) {
2.189 + GraphWriter<Graph> tmp(graph, fn);
2.190 + return tmp;
2.191 + }
2.192 +
2.193 + /// \brief Return a \ref GraphWriter class
2.194 + ///
2.195 + /// This function just returns a \ref GraphWriter class.
2.196 + /// \relates GraphWriter
2.197 + template <typename Graph>
2.198 + GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) {
2.199 + GraphWriter<Graph> tmp(graph, fn);
2.200 + return tmp;
2.201 + }
2.202 +
2.203 class SectionWriter;
2.204
2.205 SectionWriter sectionWriter(std::istream& is);
3.1 --- a/lemon/path.h Mon Feb 16 15:03:32 2009 +0000
3.2 +++ b/lemon/path.h Fri Feb 20 20:36:26 2009 +0000
3.3 @@ -929,9 +929,8 @@
3.4 };
3.5
3.6 template <typename Target, typename Source,
3.7 - bool buildEnable = BuildTagIndicator<Target>::value,
3.8 - bool revEnable = RevPathTagIndicator<Source>::value>
3.9 - struct PathCopySelector {
3.10 + bool buildEnable = BuildTagIndicator<Target>::value>
3.11 + struct PathCopySelectorForward {
3.12 static void copy(Target& target, const Source& source) {
3.13 target.clear();
3.14 for (typename Source::ArcIt it(source); it != INVALID; ++it) {
3.15 @@ -941,7 +940,16 @@
3.16 };
3.17
3.18 template <typename Target, typename Source>
3.19 - struct PathCopySelector<Target, Source, false, true> {
3.20 + struct PathCopySelectorForward<Target, Source, true> {
3.21 + static void copy(Target& target, const Source& source) {
3.22 + target.clear();
3.23 + target.build(source);
3.24 + }
3.25 + };
3.26 +
3.27 + template <typename Target, typename Source,
3.28 + bool buildEnable = BuildTagIndicator<Target>::value>
3.29 + struct PathCopySelectorBackward {
3.30 static void copy(Target& target, const Source& source) {
3.31 target.clear();
3.32 for (typename Source::RevArcIt it(source); it != INVALID; ++it) {
3.33 @@ -951,21 +959,29 @@
3.34 };
3.35
3.36 template <typename Target, typename Source>
3.37 - struct PathCopySelector<Target, Source, true, false> {
3.38 - static void copy(Target& target, const Source& source) {
3.39 - target.clear();
3.40 - target.build(source);
3.41 - }
3.42 - };
3.43 -
3.44 - template <typename Target, typename Source>
3.45 - struct PathCopySelector<Target, Source, true, true> {
3.46 + struct PathCopySelectorBackward<Target, Source, true> {
3.47 static void copy(Target& target, const Source& source) {
3.48 target.clear();
3.49 target.buildRev(source);
3.50 }
3.51 };
3.52
3.53 +
3.54 + template <typename Target, typename Source,
3.55 + bool revEnable = RevPathTagIndicator<Source>::value>
3.56 + struct PathCopySelector {
3.57 + static void copy(Target& target, const Source& source) {
3.58 + PathCopySelectorForward<Target, Source>::copy(target, source);
3.59 + }
3.60 + };
3.61 +
3.62 + template <typename Target, typename Source>
3.63 + struct PathCopySelector<Target, Source, true> {
3.64 + static void copy(Target& target, const Source& source) {
3.65 + PathCopySelectorBackward<Target, Source>::copy(target, source);
3.66 + }
3.67 + };
3.68 +
3.69 }
3.70
3.71
4.1 --- a/lemon/random.h Mon Feb 16 15:03:32 2009 +0000
4.2 +++ b/lemon/random.h Fri Feb 20 20:36:26 2009 +0000
4.3 @@ -344,56 +344,46 @@
4.4 }
4.5 };
4.6
4.7 - template <typename Result, int exp, bool pos = (exp >= 0)>
4.8 + template <typename Result, int exp>
4.9 struct ShiftMultiplier {
4.10 static const Result multiplier() {
4.11 Result res = ShiftMultiplier<Result, exp / 2>::multiplier();
4.12 res *= res;
4.13 - if ((exp & 1) == 1) res *= static_cast<Result>(2.0);
4.14 - return res;
4.15 - }
4.16 - };
4.17 -
4.18 - template <typename Result, int exp>
4.19 - struct ShiftMultiplier<Result, exp, false> {
4.20 - static const Result multiplier() {
4.21 - Result res = ShiftMultiplier<Result, exp / 2>::multiplier();
4.22 - res *= res;
4.23 if ((exp & 1) == 1) res *= static_cast<Result>(0.5);
4.24 return res;
4.25 }
4.26 };
4.27
4.28 template <typename Result>
4.29 - struct ShiftMultiplier<Result, 0, true> {
4.30 + struct ShiftMultiplier<Result, 0> {
4.31 static const Result multiplier() {
4.32 return static_cast<Result>(1.0);
4.33 }
4.34 };
4.35
4.36 template <typename Result>
4.37 - struct ShiftMultiplier<Result, -20, true> {
4.38 + struct ShiftMultiplier<Result, 20> {
4.39 static const Result multiplier() {
4.40 return static_cast<Result>(1.0/1048576.0);
4.41 }
4.42 };
4.43
4.44 template <typename Result>
4.45 - struct ShiftMultiplier<Result, -32, true> {
4.46 + struct ShiftMultiplier<Result, 32> {
4.47 static const Result multiplier() {
4.48 - return static_cast<Result>(1.0/424967296.0);
4.49 + return static_cast<Result>(1.0/4294967296.0);
4.50 }
4.51 };
4.52
4.53 template <typename Result>
4.54 - struct ShiftMultiplier<Result, -53, true> {
4.55 + struct ShiftMultiplier<Result, 53> {
4.56 static const Result multiplier() {
4.57 return static_cast<Result>(1.0/9007199254740992.0);
4.58 }
4.59 };
4.60
4.61 template <typename Result>
4.62 - struct ShiftMultiplier<Result, -64, true> {
4.63 + struct ShiftMultiplier<Result, 64> {
4.64 static const Result multiplier() {
4.65 return static_cast<Result>(1.0/18446744073709551616.0);
4.66 }
4.67 @@ -413,7 +403,7 @@
4.68 static const int bits = std::numeric_limits<Word>::digits;
4.69
4.70 static Result convert(RandomCore<Word>& rnd) {
4.71 - return Shifting<Result, - shift - rest>::
4.72 + return Shifting<Result, shift + rest>::
4.73 shift(static_cast<Result>(rnd() >> (bits - rest)));
4.74 }
4.75 };
4.76 @@ -423,7 +413,7 @@
4.77 static const int bits = std::numeric_limits<Word>::digits;
4.78
4.79 static Result convert(RandomCore<Word>& rnd) {
4.80 - return Shifting<Result, - shift - bits>::
4.81 + return Shifting<Result, shift + bits>::
4.82 shift(static_cast<Result>(rnd())) +
4.83 RealConversion<Result, Word, rest-bits, shift + bits>::
4.84 convert(rnd);