Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84743 - branches/release/libs/algorithm/doc
From: marshall_at_[hidden]
Date: 2013-06-11 12:21:22


Author: marshall
Date: 2013-06-11 12:21:22 EDT (Tue, 11 Jun 2013)
New Revision: 84743
URL: http://svn.boost.org/trac/boost/changeset/84743

Log:
Merge doc changes from trunk

Added:
   branches/release/libs/algorithm/doc/equal.qbk
      - copied unchanged from r84742, trunk/libs/algorithm/doc/equal.qbk
   branches/release/libs/algorithm/doc/is_permutation.qbk
      - copied unchanged from r84742, trunk/libs/algorithm/doc/is_permutation.qbk
   branches/release/libs/algorithm/doc/mismatch.qbk
      - copied unchanged from r84742, trunk/libs/algorithm/doc/mismatch.qbk
Properties modified:
   branches/release/libs/algorithm/doc/ (props changed)
   branches/release/libs/algorithm/doc/Jamfile.v2 (contents, props changed)
   branches/release/libs/algorithm/doc/algorithm.qbk (contents, props changed)
   branches/release/libs/algorithm/doc/all_of.qbk (props changed)
   branches/release/libs/algorithm/doc/any_of.qbk (props changed)
   branches/release/libs/algorithm/doc/boyer_moore.qbk (props changed)
   branches/release/libs/algorithm/doc/boyer_moore_horspool.qbk (props changed)
   branches/release/libs/algorithm/doc/clamp-hpp.qbk (props changed)
   branches/release/libs/algorithm/doc/hex.qbk (props changed)
   branches/release/libs/algorithm/doc/is_partitioned.qbk (contents, props changed)
   branches/release/libs/algorithm/doc/knuth_morris_pratt.qbk (props changed)
   branches/release/libs/algorithm/doc/none_of.qbk (props changed)
   branches/release/libs/algorithm/doc/one_of.qbk (props changed)
   branches/release/libs/algorithm/doc/ordered-hpp.qbk (props changed)
   branches/release/libs/algorithm/doc/partition_point.qbk (props changed)
Text files modified:
   branches/release/libs/algorithm/doc/Jamfile.v2 | 6 ++
   branches/release/libs/algorithm/doc/algorithm.qbk | 6 ++
   branches/release/libs/algorithm/doc/equal.qbk | 80 ++++++++++++++++++++++++++++++++++++
   branches/release/libs/algorithm/doc/is_partitioned.qbk | 2
   branches/release/libs/algorithm/doc/is_permutation.qbk | 87 ++++++++++++++++++++++++++++++++++++++++
   branches/release/libs/algorithm/doc/mismatch.qbk | 82 +++++++++++++++++++++++++++++++++++++
   6 files changed, 261 insertions(+), 2 deletions(-)

Modified: branches/release/libs/algorithm/doc/Jamfile.v2
==============================================================================
--- branches/release/libs/algorithm/doc/Jamfile.v2 Tue Jun 11 10:50:59 2013 (r84742)
+++ branches/release/libs/algorithm/doc/Jamfile.v2 2013-06-11 12:21:22 EDT (Tue, 11 Jun 2013) (r84743)
@@ -18,7 +18,11 @@
 
 doxygen autodoc
     :
- [ glob ../../../boost/algorithm/*.hpp ../../../boost/algorithm/searching/*.hpp ]
+ [ glob ../../../boost/algorithm/*.hpp
+ ../../../boost/algorithm/searching/*.hpp
+ ../../../boost/algorithm/cxx11/*.hpp
+ ../../../boost/algorithm/cxx14/*.hpp
+ ]
     :
        <doxygen:param>"PREDEFINED=\"BOOST_ALGORITHM_DOXYGEN=1\""
        <doxygen:param>WARNINGS=YES # Default NO, but useful to see warnings, especially in a logfile.

Modified: branches/release/libs/algorithm/doc/algorithm.qbk
==============================================================================
--- branches/release/libs/algorithm/doc/algorithm.qbk Tue Jun 11 10:50:59 2013 (r84742)
+++ branches/release/libs/algorithm/doc/algorithm.qbk 2013-06-11 12:21:22 EDT (Tue, 11 Jun 2013) (r84743)
@@ -53,9 +53,15 @@
 [include one_of.qbk]
 [include ordered-hpp.qbk]
 [include is_partitioned.qbk]
+[include is_permutation.qbk]
 [include partition_point.qbk]
 [endsect]
 
+[section:CXX14 C++14 Algorithms]
+[include equal.qbk]
+[include mismatch.qbk]
+[endsect]
+
 [section:Misc Other Algorithms]
 [include clamp-hpp.qbk]
 [include gather.qbk]

Copied: branches/release/libs/algorithm/doc/equal.qbk (from r84742, trunk/libs/algorithm/doc/equal.qbk)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/release/libs/algorithm/doc/equal.qbk 2013-06-11 12:21:22 EDT (Tue, 11 Jun 2013) (r84743, copy of r84742, trunk/libs/algorithm/doc/equal.qbk)
@@ -0,0 +1,80 @@
+[/ File equal.qbk]
+
+[section:equal equal ]
+
+[/license
+Copyright (c) 2013 Marshall Clow
+
+Distributed under the Boost Software License, Version 1.0.
+(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+]
+
+The header file 'equal.hpp' contains two variants of a the stl algorithm `equal`. The algorithm tests to see if two sequences contain equal values;
+
+Before (the proposed) C++14 the algorithm `std::equal` took three iterators and an optional comparison predicate. The first two iterators `[first1, last1)` defined a sequence, and the second one `first2` defined the start of the second sequence. The second sequence was assumed to be the same length as the first.
+
+In C++14, two new variants were introduced, taking four iterators and an optional comparison predicate. The four iterators define two sequences `[first1, last1)` and `[first2, last2)` explicitly, rather than defining the second one implicitly. This leads to correct answers in more cases (and avoid undefined behavior in others).
+
+Consider the two sequences:
+```
+ auto seq1 = { 0, 1, 2 };
+ auto seq2 = { 0, 1, 2, 3, 4 };
+
+ std::equal ( seq1.begin (), seq1.end (), seq2.begin ()); // true
+ std::equal ( seq2.begin (), seq2.end (), seq1.begin ()); // Undefined behavior
+ std::equal ( seq1.begin (), seq1.end (), seq1.begin (), seq2.end ()); // false
+```
+
+You can argue that `true` is the correct answer in the first case, even though the sequences are not the same. The first N entries in `seq2` are the same as the entries in `seq1` - but that's not all that's in `seq2`. But in the second case, the algorithm will read past the end of `seq1`, resulting in undefined behavior (large earthquake, incorrect results, pregnant cat, etc).
+
+However, if the two sequences are specified completely, it's clear that they are not equal.
+
+[heading interface]
+
+The function `equal` returns true if the two sequences compare equal; i.e, if each element in the sequence compares equal to the corresponding element in the other sequence. One version uses `std::equal_to` to do the comparison; the other lets the caller pass predicate to do the comparisons.
+
+``
+template <class InputIterator1, class InputIterator2>
+bool equal ( InputIterator1 first1, InputIterator1 last1,
+ InputIterator2 first2, InputIterator2 last2 );
+
+template <class InputIterator1, class InputIterator2, class BinaryPredicate>
+bool equal ( InputIterator1 first1, InputIterator1 last1,
+ InputIterator2 first2, InputIterator2 last2, BinaryPredicate pred );
+``
+
+[heading Examples]
+
+Given the container `c1` containing `{ 0, 1, 2, 3, 14, 15 }`, and `c2` containing `{ 1, 2, 3 }`, then
+``
+equal ( c1.begin (), c1.end (), c2.begin (), c2.end ()) --> false
+equal ( c1.begin () + 1, c1.begin () + 3, c2.begin (), c2.end ()) --> true
+equal ( c1.end (), c1.end (), c2.end (), c2.end ()) --> true // empty sequences are alway equal to each other
+``
+
+[heading Iterator Requirements]
+
+`equal` works on all iterators except output iterators.
+
+[heading Complexity]
+
+Both of the variants of `equal` run in ['O(N)] (linear) time; that is, they compare against each element in the list once. If the sequence is found to be not equal at any point, the routine will terminate immediately, without examining the rest of the elements.
+
+[heading Exception Safety]
+
+Both of the variants of `equal` take their parameters by value and do not depend upon any global state. Therefore, all the routines in this file provide the strong exception guarantee.
+
+[heading Notes]
+
+* The four iterator version of the routine `equal` is part of the C++14 standard. When C++14 standard library implementations become available, the implementation from the standard library should be used.
+
+* `equal` returns true for two empty ranges, no matter what predicate is passed to test against.
+
+[endsect]
+
+[/ File equal.qbk
+Copyright 2011 Marshall Clow
+Distributed under the Boost Software License, Version 1.0.
+(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).
+]
+

Modified: branches/release/libs/algorithm/doc/is_partitioned.qbk
==============================================================================
--- branches/release/libs/algorithm/doc/is_partitioned.qbk Tue Jun 11 10:50:59 2013 (r84742)
+++ branches/release/libs/algorithm/doc/is_partitioned.qbk 2013-06-11 12:21:22 EDT (Tue, 11 Jun 2013) (r84743)
@@ -18,7 +18,7 @@
 
 [heading interface]
 
-The function `is_partitioned` returns true the items in the sequence are separated according to their ability to satisfy the predicate. There are two versions; one takes two iterators, and the other takes a range.
+The function `is_partitioned` returns true if the items in the sequence are separated according to their ability to satisfy the predicate. There are two versions; one takes two iterators, and the other takes a range.
 
 ``
 template<typename InputIterator, typename Predicate>

Copied: branches/release/libs/algorithm/doc/is_permutation.qbk (from r84742, trunk/libs/algorithm/doc/is_permutation.qbk)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/release/libs/algorithm/doc/is_permutation.qbk 2013-06-11 12:21:22 EDT (Tue, 11 Jun 2013) (r84743, copy of r84742, trunk/libs/algorithm/doc/is_permutation.qbk)
@@ -0,0 +1,87 @@
+[/ File is_permutation.qbk]
+
+[section:is_permutation is_permutation ]
+
+[/license
+Copyright (c) 2010-2012 Marshall Clow
+
+Distributed under the Boost Software License, Version 1.0.
+(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+]
+
+The header file 'is_permutation.hpp' contains six variants of a single algorithm, `is_permutation`. The algorithm tests to see if one sequence is a permutation of a second one; in other words, it contains all the same members, possibly in a different order.
+
+The routine `is_permutation` takes two sequences and an (optional) predicate. It returns true if the two sequences contain the same members. If it is passed a predicate, it uses the predicate to compare the elements of the sequence to see if they are the same.
+
+`is_permutation` come in three forms. The first one takes two iterators to define the first range, and the starting iterator of the second range. The second form takes a two iterators to define the first range and two more to define the second range. The third form takes a single range parameter, and uses Boost.Range to traverse it.
+
+
+[heading Interface]
+
+The function `is_permutation` returns true if the two input sequences contain the same elements. There are six versions; two take three iterators, two take four iterators, and the other two take two ranges.
+
+In general, you should prefer the four iterator versions over the three iterator ones. The three iterator version has to "create" the fourth iterator internally by calling `std::advance(first2, std::distance(first1,last1))`, and if the second sequence is shorter than the first, that's undefined behavior.
+
+``
+template< class ForwardIterator1, class ForwardIterator2 >
+bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2 );
+
+template< class ForwardIterator1, class ForwardIterator2, class BinaryPredicate >
+bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1,
+ ForwardIterator2 first2, BinaryPredicate p );
+
+
+template< class ForwardIterator1, class ForwardIterator2 >
+bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2 );
+
+template< class ForwardIterator1, class ForwardIterator2, class BinaryPredicate >
+bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1,
+ ForwardIterator2 first2, ForwardIterator2 last2,
+ BinaryPredicate p );
+
+template <typename Range, typename ForwardIterator>
+bool is_permutation ( const Range &r, ForwardIterator first2 );
+
+template <typename Range, typename ForwardIterator, typename BinaryPredicate>
+bool is_permutation ( const Range &r, ForwardIterator first2, BinaryPredicate pred );
+
+``
+
+[heading Examples]
+
+Given the container `c1` containing `{ 0, 1, 2, 3, 14, 15 }`, and `c2` containing `{ 15, 14, 3, 1, 2 }`, then
+``
+is_permutation ( c1.begin(), c1.end (), c2.begin(), c2.end ()) --> false
+is_permutation ( c1.begin() + 1, c1.end (), c2.begin(), c2.end ()) --> true
+
+is_permutation ( c1.end (), c1.end (), c2.end(), c2.end ()) --> true // all empty ranges are permutations of each other
+``
+
+[heading Iterator Requirements]
+
+`is_permutation` works on forward iterators or better.
+
+[heading Complexity]
+
+All of the variants of `is_permutation` run in ['O(N^2)] (quadratic) time; that is, they compare against each element in the list (potentially) N times. If passed random-access iterators, `is_permutation` can return quickly if the sequences are different sizes.
+
+[heading Exception Safety]
+
+All of the variants of `is_permutation` take their parameters by value, and do not depend upon any global state. Therefore, all the routines in this file provide the strong exception guarantee.
+
+[heading Notes]
+
+* The three iterator versions of the routine `is_permutation` are part of the C++11 standard. When compiled using a C++11 implementation, the implementation from the standard library will be used.
+
+* The four iterator versions of the routine `is_permutation` are part of the proposed C++14 standard. When C++14 standard libraries become available, the implementation should be changed to use the implementation from the standard library (if available).
+
+* `is_permutation` returns true when passed a pair of empty ranges, no matter what predicate is passed to test with.
+
+[endsect]
+
+[/ File is_permutation.qbk
+Copyright 2011 Marshall Clow
+Distributed under the Boost Software License, Version 1.0.
+(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).
+]
+

Copied: branches/release/libs/algorithm/doc/mismatch.qbk (from r84742, trunk/libs/algorithm/doc/mismatch.qbk)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/release/libs/algorithm/doc/mismatch.qbk 2013-06-11 12:21:22 EDT (Tue, 11 Jun 2013) (r84743, copy of r84742, trunk/libs/algorithm/doc/mismatch.qbk)
@@ -0,0 +1,82 @@
+[/ File mismatch.qbk]
+
+[section:mismatch mismatch ]
+
+[/license
+Copyright (c) 2013 Marshall Clow
+
+Distributed under the Boost Software License, Version 1.0.
+(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+]
+
+The header file 'mismatch.hpp' contains two variants of a the stl algorithm `mismatch`. The algorithm finds the first point in two sequences where they do not match.
+
+Before (the proposed) C++14 the algorithm `std::mismatch` took three iterators and an optional comparison predicate. The first two iterators `[first1, last1)` defined a sequence, and the second one `first2` defined the start of the second sequence. The second sequence was assumed to be the same length as the first.
+
+In C++14, two new variants were introduced, taking four iterators and an optional comparison predicate. The four iterators define two sequences `[first1, last1)` and `[first2, last2)` explicitly, rather than defining the second one implicitly. This leads to correct answers in more cases (and avoid undefined behavior in others).
+
+Consider the two sequences:
+```
+ auto seq1 = { 0, 1, 2 };
+ auto seq2 = { 0, 1, 2, 3, 4 };
+
+ std::mismatch ( seq1.begin (), seq1.end (), seq2.begin ()); // <3, 3>
+ std::mismatch ( seq2.begin (), seq2.end (), seq1.begin ()); // Undefined behavior
+ std::mismatch ( seq1.begin (), seq1.end (), seq1.begin (), seq2.end ()); // <3, 3>
+```
+
+The first N entries in `seq2` are the same as the entries in `seq1` - but that's not all that's in `seq2`. In the second case, the algorithm will read past the end of `seq1`, resulting in undefined behavior (large earthquake, incorrect results, pregnant cat, etc).
+
+However, if the two sequences are specified completely, it's clear that where the mismatch occurs.
+
+[heading interface]
+
+The function `mismatch` returns a pair of iterators which denote the first mismatching elements in each sequence. If the sequences match completely, `mismatch` returns their end iterators. One version uses `std::equal_to` to do the comparison; the other lets the caller pass predicate to do the comparisons.
+
+``
+template <class InputIterator1, class InputIterator2>
+std::pair<InputIterator1, InputIterator2>
+mismatch ( InputIterator1 first1, InputIterator1 last1,
+ InputIterator2 first2, InputIterator2 last2 );
+
+template <class InputIterator1, class InputIterator2, class BinaryPredicate>
+std::pair<InputIterator1, InputIterator2>
+mismatch ( InputIterator1 first1, InputIterator1 last1,
+ InputIterator2 first2, InputIterator2 last2, BinaryPredicate pred );
+``
+
+[heading Examples]
+
+Given the container `c1` containing `{ 0, 1, 2, 3, 14, 15 }`, and `c2` containing `{ 1, 2, 3 }`, then
+``
+mismatch ( c1.begin(), c1.end(), c2.begin(), c2.end()) --> <c1.begin(), c2.begin()> // first elements do not match
+mismatch ( c1.begin() + 1, c1.begin() + 4, c2.begin(), c2.end()) --> <c1.begin() + 4, c2.end ()> // all elements of `c2` match
+mismatch ( c1.end(), c1.end(), c2.end(), c2.end()) --> <c1.end(), c2.end()> // empty sequences don't match at the end.
+``
+
+[heading Iterator Requirements]
+
+`mismatch` works on all iterators except output iterators.
+
+[heading Complexity]
+
+Both of the variants of `mismatch` run in ['O(N)] (linear) time; that is, they compare against each element in the list once. If the sequence is found to be equal at any point, the routine will terminate immediately, without examining the rest of the elements.
+
+[heading Exception Safety]
+
+Both of the variants of `mismatch` take their parameters by value and do not depend upon any global state. Therefore, all the routines in this file provide the strong exception guarantee.
+
+[heading Notes]
+
+* If the sequences are equal (or both are empty), then mismatch returns the end iterators of both sequences.
+
+* The four iterator version of the routine `mismatch` is part of the C++14 standard. When C++14 standard library implementations become available, the implementation from the standard library should be used.
+
+[endsect]
+
+[/ File mismatch.qbk
+Copyright 2011 Marshall Clow
+Distributed under the Boost Software License, Version 1.0.
+(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).
+]
+


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk