diff --git a/doc/lexicographic.html b/doc/lexicographic.html index 924d5a9..bcf577d 100644 --- a/doc/lexicographic.html +++ b/doc/lexicographic.html @@ -2,6 +2,11 @@ "http://www.w3.org/TR/html4/strict.dtd">
+ + +Often one has to write comparisions which give an ordering between various kinds of data. When they look in a certain specified order at one relation between two data items at a time and @@ -50,7 +56,64 @@ one can just switch the order of the arguments. Additionally, both the constructor and the function call operator provide also a three argument form which takes a functor for comparisions as a third argument. - +
+ +std::lexicographic_compare
+ The standard C++ algorithm std::lexicographic_compare
+ does essentially the same thing but in a different situation. It compares
+ sequences of data items of equal type. Whereas boost::lexicographic
+ compares individual data items of different type, and every comparison
+ must be specified explicitly by using the function call operator of the class.
+
+ Advantages
+
boost::lexicographic
as a functor.
+ ++ But this construct eats up many of the advantages of using +boost::lexicographic cmp (complex_computation (a), complex_computation (b)); +if (cmp.result () == lexicographic::equivalent) +{ + cmp (complex_computation (c), complex_computation (d)); + if (cmp.result () == lexicographic::equivalent) + { + cmp (complex_computation (e), complex_computation (f)); + } +} +// do something with cmp ++
boost::lexicographic
.
+ boost::lexicographic
, besides
+ the lack of short-circuiting, is not negligible.
+ Tests with gcc 3.2.2 showed, that the algorithmic overhead
+ is about 40% in comparison to according to if-else-cascades.
+ Additionally gcc failed to inline everything properly, so that the
+ resulting performance overhead was about a factor two.
+ An example usage are special sorting operators, such as the lexicographic @@ -223,11 +286,17 @@ bool operator < (person const &p1, person const &p2)
The author of boost::lexicographic
is Jan Langer (jan@langernetz.de).
- Ideas and suggestions from Steve Cleary, David Abrahams, Gennaro Proata and Paul Bristow were used.
+ Ideas and suggestions from Steve Cleary, David Abrahams, Gennaro Proata, Paul Bristow, Daniel Frey, Daryle Walker and Brian McNamara were used.
August 22, 2003
- © Copyright Jan Langer 2003. Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose.
-
+ October 5, 2003
+
+ © Copyright Jan Langer 2003
+ Use, modification, and distribution is subject to the Boost Software
+ License, Version 1.0. (See accompanying file
+ LICENSE_1_0.txt or copy at
+ www.boost.org/LICENSE_1_0.txt)
+