mirror of
https://github.com/boostorg/algorithm.git
synced 2025-06-25 20:11:50 +02:00
Compare commits
76 Commits
develop
...
boost-1.54
Author | SHA1 | Date | |
---|---|---|---|
20277434f0 | |||
55cb3afefa | |||
beeedadba9 | |||
1a70166889 | |||
63da6f5713 | |||
2381d0bdac | |||
40b5941652 | |||
00dfda98b2 | |||
52eef989da | |||
8132864884 | |||
6e098b27aa | |||
60010b4165 | |||
1660dc9d48 | |||
5ae4f848b3 | |||
fe3e0bb9c4 | |||
311e169376 | |||
3dddfa1930 | |||
be6d8f9665 | |||
bced4ed8dd | |||
1b57e905ab | |||
29bd9f53d9 | |||
6341cfb1a6 | |||
7f4acd6170 | |||
314f6dcfe0 | |||
167aa6e31c | |||
d228e91494 | |||
9cc573fbd0 | |||
28a7d3eb4b | |||
883cce61a8 | |||
96d4708367 | |||
563fe27a59 | |||
76cd99ed53 | |||
0f2399fef0 | |||
044d667e79 | |||
be9da63894 | |||
787c94bc53 | |||
e87ce37b34 | |||
199a89a1e9 | |||
01492a93c6 | |||
50703b8c97 | |||
0f8d556130 | |||
bbd3220a1e | |||
9068069106 | |||
a37af3c81e | |||
f5885c6fb0 | |||
d45bb3545e | |||
d735b9fa1e | |||
62ec675581 | |||
e7cd4da67b | |||
6076f5a18e | |||
60cd5a0500 | |||
c33dad924d | |||
2f2935f07e | |||
3cbaafc27f | |||
c067b348bf | |||
c33935fa1f | |||
98a8b08afb | |||
fc0f3dcffc | |||
822636418b | |||
352e16aade | |||
89c76ea1bb | |||
50b5726a6f | |||
d4b95734dd | |||
05af96f84c | |||
5bdbb2b308 | |||
1a02969303 | |||
6309379618 | |||
37581bac55 | |||
a71a4ed5b1 | |||
c509c3fbad | |||
d8683f2498 | |||
7c0101aa51 | |||
6f3e85528f | |||
8af639b7cf | |||
d9bc7e800b | |||
b4ed9beb90 |
@ -18,7 +18,11 @@ using boostbook ;
|
||||
|
||||
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.
|
||||
|
@ -53,9 +53,15 @@ Thanks to all the people who have reviewed this library and made suggestions for
|
||||
[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]
|
||||
|
80
doc/equal.qbk
Normal file
80
doc/equal.qbk
Normal file
@ -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).
|
||||
]
|
||||
|
@ -18,7 +18,7 @@ The routine `is_partitioned` takes a sequence and a predicate. It returns true i
|
||||
|
||||
[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>
|
||||
|
87
doc/is_permutation.qbk
Normal file
87
doc/is_permutation.qbk
Normal file
@ -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).
|
||||
]
|
||||
|
82
doc/mismatch.qbk
Normal file
82
doc/mismatch.qbk
Normal file
@ -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).
|
||||
]
|
||||
|
0
include/boost/algorithm/clamp.hpp
Executable file → Normal file
0
include/boost/algorithm/clamp.hpp
Executable file → Normal file
@ -21,13 +21,10 @@
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/tr1/tr1/tuple> // for tie
|
||||
|
||||
namespace boost { namespace algorithm {
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
// Use the C++11 versions of is_permutation if it is available
|
||||
using std::is_permutation; // Section 25.2.12
|
||||
#else
|
||||
/// \cond DOXYGEN_HIDE
|
||||
namespace detail {
|
||||
template <typename Predicate, typename Iterator>
|
||||
@ -37,18 +34,82 @@ namespace detail {
|
||||
template <typename T1>
|
||||
bool operator () ( const T1 &t1 ) const { return p_ ( *it_, t1 ); }
|
||||
private:
|
||||
Predicate &p_;
|
||||
Predicate p_;
|
||||
Iterator it_;
|
||||
};
|
||||
|
||||
// Preconditions:
|
||||
// 1. The sequences are the same length
|
||||
// 2. Any common elements on the front have been removed (not necessary for correctness, just for performance)
|
||||
template< class ForwardIterator1, class ForwardIterator2, class BinaryPredicate >
|
||||
bool is_permutation_inner ( ForwardIterator1 first1, ForwardIterator1 last1,
|
||||
ForwardIterator2 first2, ForwardIterator2 last2,
|
||||
BinaryPredicate p ) {
|
||||
// for each unique value in the sequence [first1,last1), count how many times
|
||||
// it occurs, and make sure it occurs the same number of times in [first2, last2)
|
||||
for ( ForwardIterator1 iter = first1; iter != last1; ++iter ) {
|
||||
value_predicate<BinaryPredicate, ForwardIterator1> pred ( p, iter );
|
||||
|
||||
/* For each value we haven't seen yet... */
|
||||
if ( std::find_if ( first1, iter, pred ) == iter ) {
|
||||
std::size_t dest_count = std::count_if ( first2, last2, pred );
|
||||
if ( dest_count == 0 || dest_count != (std::size_t) std::count_if ( iter, last1, pred ))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template< class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
|
||||
bool is_permutation_tag ( ForwardIterator1 first1, ForwardIterator1 last1,
|
||||
ForwardIterator2 first2, ForwardIterator2 last2,
|
||||
BinaryPredicate p,
|
||||
std::forward_iterator_tag, std::forward_iterator_tag ) {
|
||||
|
||||
// Skip the common prefix (if any)
|
||||
while ( first1 != last1 && first2 != last2 && p ( *first1, *first2 )) {
|
||||
++first1;
|
||||
++first2;
|
||||
}
|
||||
if ( first1 != last1 && first2 != last2 )
|
||||
return boost::algorithm::detail::is_permutation_inner ( first1, last1, first2, last2,
|
||||
std::equal_to<typename std::iterator_traits<ForwardIterator1>::value_type> ());
|
||||
return first1 == last1 && first2 == last2;
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator1, class RandomAccessIterator2, class BinaryPredicate>
|
||||
bool is_permutation_tag ( RandomAccessIterator1 first1, RandomAccessIterator1 last1,
|
||||
RandomAccessIterator2 first2, RandomAccessIterator2 last2,
|
||||
BinaryPredicate p,
|
||||
std::random_access_iterator_tag, std::random_access_iterator_tag ) {
|
||||
// Cheap check
|
||||
if ( std::distance ( first1, last1 ) != std::distance ( first2, last2 ))
|
||||
return false;
|
||||
// Skip the common prefix (if any)
|
||||
while ( first1 != last1 && first2 != last2 && p ( *first1, *first2 )) {
|
||||
++first1;
|
||||
++first2;
|
||||
}
|
||||
|
||||
if ( first1 != last1 && first2 != last2 )
|
||||
return is_permutation_inner (first1, last1, first2, last2, p);
|
||||
return first1 == last1 && first2 == last2;
|
||||
}
|
||||
|
||||
}
|
||||
/// \endcond
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
// Use the C++11 versions of is_permutation if it is available
|
||||
using std::is_permutation; // Section 25.2.12
|
||||
#else
|
||||
|
||||
/// \fn is_permutation ( ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 first2, BinaryPredicate p )
|
||||
/// \brief Tests to see if the sequence [first,last) is a permutation of the sequence starting at first2
|
||||
///
|
||||
/// \param first The start of the input sequence
|
||||
/// \param last One past the end of the input sequence
|
||||
/// \param first1 The start of the input sequence
|
||||
/// \param last1 One past the end of the input sequence
|
||||
/// \param first2 The start of the second sequence
|
||||
/// \param p The predicate to compare elements with
|
||||
///
|
||||
@ -60,6 +121,7 @@ bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1,
|
||||
ForwardIterator2 first2, BinaryPredicate p )
|
||||
{
|
||||
// Skip the common prefix (if any)
|
||||
// std::tie (first1, first2) = std::mismatch (first1, last1, first2, p);
|
||||
std::pair<ForwardIterator1, ForwardIterator2> eq = std::mismatch (first1, last1, first2, p);
|
||||
first1 = eq.first;
|
||||
first2 = eq.second;
|
||||
@ -67,19 +129,7 @@ bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1,
|
||||
// Create last2
|
||||
ForwardIterator2 last2 = first2;
|
||||
std::advance ( last2, std::distance (first1, last1));
|
||||
|
||||
// for each unique value in the sequence [first1,last1), count how many times
|
||||
// it occurs, and make sure it occurs the same number of times in [first2, last2)
|
||||
for ( ForwardIterator1 iter = first1; iter != last1; ++iter ) {
|
||||
detail::value_predicate<BinaryPredicate, ForwardIterator1> pred ( p, iter );
|
||||
|
||||
/* For each value we haven't seen yet... */
|
||||
if ( std::find_if ( first1, iter, pred ) == iter ) {
|
||||
std::size_t dest_count = std::count_if ( first2, last2, pred );
|
||||
if ( dest_count == 0 || dest_count != (std::size_t) std::count_if ( iter, last1, pred ))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return boost::algorithm::detail::is_permutation_inner ( first1, last1, first2, last2, p );
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -88,23 +138,84 @@ bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1,
|
||||
/// \fn is_permutation ( ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 first2 )
|
||||
/// \brief Tests to see if the sequence [first,last) is a permutation of the sequence starting at first2
|
||||
///
|
||||
/// \param first The start of the input sequence
|
||||
/// \param last One past the end of the input sequence
|
||||
/// \param first1 The start of the input sequence
|
||||
/// \param last2 One past the end of the input sequence
|
||||
/// \param first2 The start of the second sequence
|
||||
/// \note This function is part of the C++2011 standard library.
|
||||
/// We will use the standard one if it is available,
|
||||
/// otherwise we have our own implementation.
|
||||
template< class ForwardIterator1, class ForwardIterator2 >
|
||||
bool is_permutation ( ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 first2 )
|
||||
bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2 )
|
||||
{
|
||||
// How should I deal with the idea that ForwardIterator1::value_type
|
||||
// and ForwardIterator2::value_type could be different? Define my own comparison predicate?
|
||||
return boost::algorithm::is_permutation ( first, last, first2,
|
||||
std::equal_to<typename std::iterator_traits<ForwardIterator1>::value_type> ());
|
||||
// Skip the common prefix (if any)
|
||||
std::pair<ForwardIterator1, ForwardIterator2> eq = std::mismatch (first1, last1, first2 );
|
||||
first1 = eq.first;
|
||||
first2 = eq.second;
|
||||
if ( first1 != last1 ) {
|
||||
// Create last2
|
||||
ForwardIterator2 last2 = first2;
|
||||
std::advance ( last2, std::distance (first1, last1));
|
||||
return boost::algorithm::detail::is_permutation_inner ( first1, last1, first2, last2,
|
||||
std::equal_to<typename std::iterator_traits<ForwardIterator1>::value_type> ());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/// \fn is_permutation ( ForwardIterator1 first, ForwardIterator1 last,
|
||||
/// ForwardIterator2 first2, ForwardIterator2 last2 )
|
||||
/// \brief Tests to see if the sequence [first,last) is a permutation of the sequence starting at first2
|
||||
///
|
||||
/// \param first1 The start of the input sequence
|
||||
/// \param last2 One past the end of the input sequence
|
||||
/// \param first2 The start of the second sequence
|
||||
/// \param last1 One past the end of the second sequence
|
||||
/// \note This function is part of the C++2011 standard library.
|
||||
/// We will use the standard one if it is available,
|
||||
/// otherwise we have our own implementation.
|
||||
template< class ForwardIterator1, class ForwardIterator2 >
|
||||
bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1,
|
||||
ForwardIterator2 first2, ForwardIterator2 last2 )
|
||||
{
|
||||
// How should I deal with the idea that ForwardIterator1::value_type
|
||||
// and ForwardIterator2::value_type could be different? Define my own comparison predicate?
|
||||
return boost::algorithm::detail::is_permutation_tag (
|
||||
first1, last1, first2, last2,
|
||||
std::equal_to<typename std::iterator_traits<ForwardIterator1>::value_type> (),
|
||||
typename std::iterator_traits<ForwardIterator1>::iterator_category (),
|
||||
typename std::iterator_traits<ForwardIterator2>::iterator_category ());
|
||||
}
|
||||
|
||||
/// \fn is_permutation ( ForwardIterator1 first, ForwardIterator1 last,
|
||||
/// ForwardIterator2 first2, ForwardIterator2 last2,
|
||||
/// BinaryPredicate p )
|
||||
/// \brief Tests to see if the sequence [first,last) is a permutation of the sequence starting at first2
|
||||
///
|
||||
/// \param first1 The start of the input sequence
|
||||
/// \param last1 One past the end of the input sequence
|
||||
/// \param first2 The start of the second sequence
|
||||
/// \param last2 One past the end of the second sequence
|
||||
/// \param pred The predicate to compare elements with
|
||||
///
|
||||
/// \note This function is part of the C++2011 standard library.
|
||||
/// We will use the standard one if it is available,
|
||||
/// otherwise we have our own implementation.
|
||||
template< class ForwardIterator1, class ForwardIterator2, class BinaryPredicate >
|
||||
bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1,
|
||||
ForwardIterator2 first2, ForwardIterator2 last2,
|
||||
BinaryPredicate pred )
|
||||
{
|
||||
return boost::algorithm::detail::is_permutation_tag (
|
||||
first1, last1, first2, last2, pred,
|
||||
typename std::iterator_traits<ForwardIterator1>::iterator_category (),
|
||||
typename std::iterator_traits<ForwardIterator2>::iterator_category ());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// \fn is_permutation ( const Range &r, ForwardIterator first2 )
|
||||
/// \brief Tests to see if the sequence [first,last) is a permutation of the sequence starting at first2
|
||||
///
|
||||
|
0
include/boost/algorithm/searching/boyer_moore.hpp
Executable file → Normal file
0
include/boost/algorithm/searching/boyer_moore.hpp
Executable file → Normal file
0
include/boost/algorithm/searching/boyer_moore_horspool.hpp
Executable file → Normal file
0
include/boost/algorithm/searching/boyer_moore_horspool.hpp
Executable file → Normal file
8
include/boost/algorithm/searching/detail/bm_traits.hpp
Executable file → Normal file
8
include/boost/algorithm/searching/detail/bm_traits.hpp
Executable file → Normal file
@ -20,11 +20,7 @@
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#ifdef BOOST_NO_CXX11_HDR_UNORDERED_MAP
|
||||
#include <boost/tr1/tr1/unordered_map>
|
||||
#else
|
||||
#include <unordered_map>
|
||||
#endif
|
||||
|
||||
#include <boost/algorithm/searching/detail/debugging.hpp>
|
||||
|
||||
@ -39,11 +35,7 @@ namespace boost { namespace algorithm { namespace detail {
|
||||
template<typename key_type, typename value_type>
|
||||
class skip_table<key_type, value_type, false> {
|
||||
private:
|
||||
#ifdef BOOST_NO_CXX11_HDR_UNORDERED_MAP
|
||||
typedef std::tr1::unordered_map<key_type, value_type> skip_map;
|
||||
#else
|
||||
typedef std::unordered_map<key_type, value_type> skip_map;
|
||||
#endif
|
||||
const value_type k_default_value;
|
||||
skip_map skip_;
|
||||
|
||||
|
0
include/boost/algorithm/searching/detail/debugging.hpp
Executable file → Normal file
0
include/boost/algorithm/searching/detail/debugging.hpp
Executable file → Normal file
0
include/boost/algorithm/searching/knuth_morris_pratt.hpp
Executable file → Normal file
0
include/boost/algorithm/searching/knuth_morris_pratt.hpp
Executable file → Normal file
@ -1,52 +0,0 @@
|
||||
/*
|
||||
Copyright (c) Marshall Clow 2012.
|
||||
|
||||
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)
|
||||
|
||||
Alternate interfaces (aka "wrappers") for algorithms.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_ALGORITHM_WRAPPERS_HPP
|
||||
#define BOOST_ALGORITHM_WRAPPERS_HPP
|
||||
|
||||
namespace boost { namespace algorithm {
|
||||
|
||||
/// \fn find_ptr ( Container &c, Key k )
|
||||
/// \return a pointer to the value matching the key in the container,
|
||||
/// or NULL if the key does not exist in the container.
|
||||
///
|
||||
/// \note: This is a wrapper around Container::find, with a useful interface.
|
||||
/// Suggested by Olaf van der Spek
|
||||
///
|
||||
/// \param c The container to be searched
|
||||
/// \param k The key value to search with
|
||||
template <class Container, class Key>
|
||||
typename Container::value_type::second_type*
|
||||
find_ptr ( Container &c, Key k )
|
||||
{
|
||||
typename Container::iterator iter = c.find ( k );
|
||||
return iter == c.end() ? NULL : &iter->second;
|
||||
}
|
||||
|
||||
/// \fn find_ptr ( const Container &c, Key k )
|
||||
/// \return a pointer to the value matching the key in the container,
|
||||
/// or NULL if the key does not exist in the container.
|
||||
///
|
||||
/// \note: This is a wrapper around Container::find, with a useful interface.
|
||||
/// Suggested by Olaf van der Spek
|
||||
///
|
||||
/// \param c The container to be searched
|
||||
/// \param k The key value to search with
|
||||
template <class Container, class Key>
|
||||
const typename Container::value_type::second_type*
|
||||
find_ptr ( const Container &c, Key k )
|
||||
{
|
||||
typename Container::const_iterator iter = c.find ( k );
|
||||
return iter == c.end() ? NULL : &iter->second;
|
||||
}
|
||||
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
3
test/Jamfile.v2
Executable file → Normal file
3
test/Jamfile.v2
Executable file → Normal file
@ -58,9 +58,6 @@ alias unit_test_framework
|
||||
[ run hex_test4.cpp unit_test_framework : : : : hex_test4 ]
|
||||
[ compile-fail hex_fail1.cpp ]
|
||||
|
||||
# Wrapper tests
|
||||
[ run wrapper_test1.cpp unit_test_framework : : : : wrapper_test1 ]
|
||||
|
||||
# Gather tests
|
||||
[ run gather_test1.cpp unit_test_framework : : : : gather_test1 ]
|
||||
[ compile-fail gather_fail1.cpp ]
|
||||
|
0
test/clamp_test.cpp
Executable file → Normal file
0
test/clamp_test.cpp
Executable file → Normal file
0
test/empty_search_test.cpp
Executable file → Normal file
0
test/empty_search_test.cpp
Executable file → Normal file
@ -24,9 +24,9 @@ bool never_eq ( const T&, const T& ) { return false; }
|
||||
int comparison_count = 0;
|
||||
template <typename T>
|
||||
bool counting_equals ( const T &a, const T &b ) {
|
||||
++comparison_count;
|
||||
return a == b;
|
||||
}
|
||||
++comparison_count;
|
||||
return a == b;
|
||||
}
|
||||
|
||||
namespace ba = boost::algorithm;
|
||||
|
||||
@ -37,85 +37,88 @@ void test_equal ()
|
||||
const int sz = sizeof (num)/sizeof(num[0]);
|
||||
|
||||
|
||||
// Empty sequences are equal to each other, but not to non-empty sequences
|
||||
BOOST_CHECK ( ba::equal ( input_iterator<int *>(num), input_iterator<int *>(num),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num)));
|
||||
BOOST_CHECK ( ba::equal ( input_iterator<int *>(num), input_iterator<int *>(num),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num),
|
||||
never_eq<int> ));
|
||||
BOOST_CHECK ( ba::equal ( random_access_iterator<int *>(num), random_access_iterator<int *>(num),
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num),
|
||||
never_eq<int> ));
|
||||
// Empty sequences are equal to each other, but not to non-empty sequences
|
||||
BOOST_CHECK ( ba::equal ( input_iterator<int *>(num), input_iterator<int *>(num),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num)));
|
||||
BOOST_CHECK ( ba::equal ( input_iterator<int *>(num), input_iterator<int *>(num),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num),
|
||||
never_eq<int> ));
|
||||
BOOST_CHECK ( ba::equal ( random_access_iterator<int *>(num), random_access_iterator<int *>(num),
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num),
|
||||
never_eq<int> ));
|
||||
|
||||
BOOST_CHECK (!ba::equal ( input_iterator<int *>(num), input_iterator<int *>(num),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + 1)));
|
||||
BOOST_CHECK (!ba::equal ( input_iterator<int *>(num + 1), input_iterator<int *>(num + 2),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num)));
|
||||
BOOST_CHECK (!ba::equal ( random_access_iterator<int *>(num + 1), random_access_iterator<int *>(num + 2),
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num)));
|
||||
BOOST_CHECK (!ba::equal ( input_iterator<int *>(num), input_iterator<int *>(num),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + 1)));
|
||||
BOOST_CHECK (!ba::equal ( input_iterator<int *>(num + 1), input_iterator<int *>(num + 2),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num)));
|
||||
BOOST_CHECK (!ba::equal ( random_access_iterator<int *>(num + 1), random_access_iterator<int *>(num + 2),
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num)));
|
||||
|
||||
// Single element sequences are equal if they contain the same value
|
||||
BOOST_CHECK ( ba::equal ( input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + 1)));
|
||||
BOOST_CHECK ( ba::equal ( input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
eq<int> ));
|
||||
BOOST_CHECK ( ba::equal ( random_access_iterator<int *>(num), random_access_iterator<int *>(num + 1),
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num + 1),
|
||||
eq<int> ));
|
||||
BOOST_CHECK (!ba::equal ( input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
never_eq<int> ));
|
||||
BOOST_CHECK (!ba::equal ( random_access_iterator<int *>(num), random_access_iterator<int *>(num + 1),
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num + 1),
|
||||
never_eq<int> ));
|
||||
// Single element sequences are equal if they contain the same value
|
||||
BOOST_CHECK ( ba::equal ( input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + 1)));
|
||||
BOOST_CHECK ( ba::equal ( input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
eq<int> ));
|
||||
BOOST_CHECK ( ba::equal ( random_access_iterator<int *>(num), random_access_iterator<int *>(num + 1),
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num + 1),
|
||||
eq<int> ));
|
||||
BOOST_CHECK (!ba::equal ( input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
never_eq<int> ));
|
||||
BOOST_CHECK (!ba::equal ( random_access_iterator<int *>(num), random_access_iterator<int *>(num + 1),
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num + 1),
|
||||
never_eq<int> ));
|
||||
|
||||
BOOST_CHECK ( ba::equal ( input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
input_iterator<int *>(num + 1), input_iterator<int *>(num + 2)));
|
||||
BOOST_CHECK ( ba::equal ( input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
input_iterator<int *>(num + 1), input_iterator<int *>(num + 2),
|
||||
eq<int> ));
|
||||
BOOST_CHECK ( ba::equal ( input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
input_iterator<int *>(num + 1), input_iterator<int *>(num + 2)));
|
||||
BOOST_CHECK ( ba::equal ( input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
input_iterator<int *>(num + 1), input_iterator<int *>(num + 2),
|
||||
eq<int> ));
|
||||
|
||||
BOOST_CHECK (!ba::equal ( input_iterator<int *>(num + 2), input_iterator<int *>(num + 3),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + 1)));
|
||||
BOOST_CHECK (!ba::equal ( input_iterator<int *>(num + 2), input_iterator<int *>(num + 3),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
eq<int> ));
|
||||
BOOST_CHECK (!ba::equal ( input_iterator<int *>(num + 2), input_iterator<int *>(num + 3),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + 1)));
|
||||
BOOST_CHECK (!ba::equal ( input_iterator<int *>(num + 2), input_iterator<int *>(num + 3),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
eq<int> ));
|
||||
|
||||
// Identical long sequences are equal.
|
||||
BOOST_CHECK ( ba::equal ( input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + sz)));
|
||||
BOOST_CHECK ( ba::equal ( input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
eq<int> ));
|
||||
BOOST_CHECK (!ba::equal ( input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
never_eq<int> ));
|
||||
// Identical long sequences are equal.
|
||||
BOOST_CHECK ( ba::equal ( input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + sz)));
|
||||
BOOST_CHECK ( ba::equal ( input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
eq<int> ));
|
||||
BOOST_CHECK (!ba::equal ( input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
never_eq<int> ));
|
||||
BOOST_CHECK ( ba::equal ( input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num + sz),
|
||||
eq<int> ));
|
||||
|
||||
// different sequences are different
|
||||
BOOST_CHECK (!ba::equal ( input_iterator<int *>(num + 1), input_iterator<int *>(num + sz),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + sz)));
|
||||
BOOST_CHECK (!ba::equal ( input_iterator<int *>(num + 1), input_iterator<int *>(num + sz),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
eq<int> ));
|
||||
BOOST_CHECK (!ba::equal ( input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + sz - 1)));
|
||||
BOOST_CHECK (!ba::equal ( input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + sz - 1),
|
||||
eq<int> ));
|
||||
// different sequences are different
|
||||
BOOST_CHECK (!ba::equal ( input_iterator<int *>(num + 1), input_iterator<int *>(num + sz),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + sz)));
|
||||
BOOST_CHECK (!ba::equal ( input_iterator<int *>(num + 1), input_iterator<int *>(num + sz),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
eq<int> ));
|
||||
BOOST_CHECK (!ba::equal ( input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + sz - 1)));
|
||||
BOOST_CHECK (!ba::equal ( input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + sz - 1),
|
||||
eq<int> ));
|
||||
|
||||
// When there's a cheap check, bail early
|
||||
comparison_count = 0;
|
||||
BOOST_CHECK (!ba::equal ( random_access_iterator<int *>(num), random_access_iterator<int *>(num + sz),
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num + sz - 1),
|
||||
counting_equals<int> ));
|
||||
BOOST_CHECK ( comparison_count == 0 );
|
||||
// And when there's not, we can't
|
||||
comparison_count = 0;
|
||||
BOOST_CHECK (!ba::equal ( input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + sz - 1),
|
||||
counting_equals<int> ));
|
||||
BOOST_CHECK ( comparison_count > 0 );
|
||||
// When there's a cheap check, bail early
|
||||
comparison_count = 0;
|
||||
BOOST_CHECK (!ba::equal ( random_access_iterator<int *>(num), random_access_iterator<int *>(num + sz),
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num + sz - 1),
|
||||
counting_equals<int> ));
|
||||
BOOST_CHECK ( comparison_count == 0 );
|
||||
// And when there's not, we can't
|
||||
comparison_count = 0;
|
||||
BOOST_CHECK (!ba::equal ( input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + sz - 1),
|
||||
counting_equals<int> ));
|
||||
BOOST_CHECK ( comparison_count > 0 );
|
||||
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ void test_sequence1 () {
|
||||
typedef input_iterator<std::vector<int>::iterator> II;
|
||||
|
||||
// This should fail to compile, since gather doesn't work with input iterators
|
||||
(void) ba::gather ( II( v.begin ()), II( v.end ()), II( v.begin ()), is_even );
|
||||
(void) ba::gather ( II( v.begin ()), II( v.end ()), II( v.begin ()), is_ten );
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,10 +19,95 @@
|
||||
#include <vector>
|
||||
#include <list>
|
||||
|
||||
#include "iterator_test.hpp"
|
||||
|
||||
template <typename T>
|
||||
bool eq ( const T& a, const T& b ) { return a == b; }
|
||||
|
||||
template <typename T>
|
||||
bool never_eq ( const T&, const T& ) { return false; }
|
||||
|
||||
namespace ba = boost::algorithm;
|
||||
// namespace ba = boost;
|
||||
|
||||
void test_sequence1 () {
|
||||
int num[] = { 1, 1, 2, 3, 5 };
|
||||
const int sz = sizeof (num)/sizeof(num[0]);
|
||||
|
||||
// Empty sequences
|
||||
BOOST_CHECK (
|
||||
ba::is_permutation (
|
||||
forward_iterator<int *>(num), forward_iterator<int *>(num),
|
||||
forward_iterator<int *>(num)));
|
||||
BOOST_CHECK (
|
||||
ba::is_permutation (
|
||||
forward_iterator<int *>(num), forward_iterator<int *>(num),
|
||||
forward_iterator<int *>(num), forward_iterator<int *>(num)));
|
||||
BOOST_CHECK (
|
||||
ba::is_permutation (
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num),
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num)));
|
||||
BOOST_CHECK (
|
||||
ba::is_permutation (
|
||||
forward_iterator<int *>(num), forward_iterator<int *>(num),
|
||||
forward_iterator<int *>(num),
|
||||
never_eq<int> )); // Since the sequences are empty, the pred is never called
|
||||
|
||||
// Empty vs. non-empty
|
||||
BOOST_CHECK ( !
|
||||
ba::is_permutation (
|
||||
forward_iterator<int *>(num), forward_iterator<int *>(num),
|
||||
forward_iterator<int *>(num), forward_iterator<int *>(num + 1)));
|
||||
|
||||
BOOST_CHECK ( !
|
||||
ba::is_permutation (
|
||||
forward_iterator<int *>(num + 1), forward_iterator<int *>(num + 2),
|
||||
forward_iterator<int *>(num), forward_iterator<int *>(num)));
|
||||
|
||||
BOOST_CHECK ( !
|
||||
ba::is_permutation (
|
||||
random_access_iterator<int *>(num + 1), random_access_iterator<int *>(num + 2),
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num)));
|
||||
|
||||
BOOST_CHECK ( !
|
||||
ba::is_permutation (
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num),
|
||||
random_access_iterator<int *>(num + 1), random_access_iterator<int *>(num + 2)));
|
||||
|
||||
// Something should be a permutation of itself
|
||||
BOOST_CHECK (
|
||||
ba::is_permutation (
|
||||
forward_iterator<int *>(num), forward_iterator<int *>(num + sz),
|
||||
forward_iterator<int *>(num)));
|
||||
BOOST_CHECK (
|
||||
ba::is_permutation (
|
||||
forward_iterator<int *>(num), forward_iterator<int *>(num + sz),
|
||||
forward_iterator<int *>(num), eq<int> ));
|
||||
BOOST_CHECK (
|
||||
ba::is_permutation (
|
||||
forward_iterator<int *>(num), forward_iterator<int *>(num + sz),
|
||||
forward_iterator<int *>(num), forward_iterator<int *>(num + sz )));
|
||||
BOOST_CHECK (
|
||||
ba::is_permutation (
|
||||
forward_iterator<int *>(num), forward_iterator<int *>(num + sz),
|
||||
forward_iterator<int *>(num), forward_iterator<int *>(num + sz ),
|
||||
eq<int> ));
|
||||
|
||||
BOOST_CHECK (
|
||||
ba::is_permutation (
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num + sz),
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num + sz)));
|
||||
BOOST_CHECK (
|
||||
ba::is_permutation (
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num + sz),
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num + sz),
|
||||
eq<int> ));
|
||||
BOOST_CHECK (
|
||||
ba::is_permutation (
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num + sz),
|
||||
forward_iterator<int *>(num), forward_iterator<int *>(num + sz),
|
||||
eq<int> ));
|
||||
|
||||
|
||||
std::vector<int> v, v1;
|
||||
|
||||
v.clear ();
|
||||
|
@ -24,9 +24,9 @@ bool never_eq ( const T&, const T& ) { return false; }
|
||||
namespace ba = boost::algorithm;
|
||||
|
||||
template <typename Iter1, typename Iter2>
|
||||
bool iter_eq ( std::pair<Iter1, Iter1> pr, Iter1 first, Iter2 second ) {
|
||||
return pr.first == first && pr.second == second;
|
||||
}
|
||||
bool iter_eq ( std::pair<Iter1, Iter2> pr, Iter1 first, Iter2 second ) {
|
||||
return pr.first == first && pr.second == second;
|
||||
}
|
||||
|
||||
void test_mismatch ()
|
||||
{
|
||||
@ -35,123 +35,129 @@ void test_mismatch ()
|
||||
const int sz = sizeof (num)/sizeof(num[0]);
|
||||
|
||||
|
||||
// No mismatch for empty sequences
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num), input_iterator<int *>(num),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num)),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num)));
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num), input_iterator<int *>(num),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num),
|
||||
never_eq<int> ),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num)));
|
||||
// No mismatch for empty sequences
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num), input_iterator<int *>(num),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num)),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num)));
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num), input_iterator<int *>(num),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num),
|
||||
never_eq<int> ),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num)));
|
||||
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( random_access_iterator<int *>(num), random_access_iterator<int *>(num),
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num),
|
||||
never_eq<int> ),
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num)));
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( random_access_iterator<int *>(num), random_access_iterator<int *>(num),
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num),
|
||||
never_eq<int> ),
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num)));
|
||||
|
||||
// Empty vs. non-empty mismatch immediately
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num), input_iterator<int *>(num),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + 1)),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num)));
|
||||
// Empty vs. non-empty mismatch immediately
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num), input_iterator<int *>(num),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + 1)),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num)));
|
||||
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num + 1), input_iterator<int *>(num + 2),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num)),
|
||||
input_iterator<int *>(num + 1), input_iterator<int *>(num)));
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num + 1), input_iterator<int *>(num + 2),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num)),
|
||||
input_iterator<int *>(num + 1), input_iterator<int *>(num)));
|
||||
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( random_access_iterator<int *>(num + 1), random_access_iterator<int *>(num + 2),
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num)),
|
||||
random_access_iterator<int *>(num + 1), random_access_iterator<int *>(num)));
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( random_access_iterator<int *>(num + 1), random_access_iterator<int *>(num + 2),
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num)),
|
||||
random_access_iterator<int *>(num + 1), random_access_iterator<int *>(num)));
|
||||
|
||||
// Single element sequences are equal if they contain the same value
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + 1)),
|
||||
input_iterator<int *>(num + 1), input_iterator<int *>(num + 1)));
|
||||
// Single element sequences are equal if they contain the same value
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + 1)),
|
||||
input_iterator<int *>(num + 1), input_iterator<int *>(num + 1)));
|
||||
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
eq<int> ),
|
||||
input_iterator<int *>(num + 1), input_iterator<int *>(num + 1)));
|
||||
eq<int> ),
|
||||
input_iterator<int *>(num + 1), input_iterator<int *>(num + 1)));
|
||||
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( random_access_iterator<int *>(num), random_access_iterator<int *>(num + 1),
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num + 1),
|
||||
eq<int> ),
|
||||
random_access_iterator<int *>(num + 1), random_access_iterator<int *>(num + 1)));
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( random_access_iterator<int *>(num), random_access_iterator<int *>(num + 1),
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num + 1),
|
||||
eq<int> ),
|
||||
random_access_iterator<int *>(num + 1), random_access_iterator<int *>(num + 1)));
|
||||
|
||||
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
never_eq<int> ),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num)));
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
never_eq<int> ),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num)));
|
||||
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( random_access_iterator<int *>(num), random_access_iterator<int *>(num + 1),
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num + 1),
|
||||
never_eq<int> ),
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num)));
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( random_access_iterator<int *>(num), random_access_iterator<int *>(num + 1),
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num + 1),
|
||||
never_eq<int> ),
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num)));
|
||||
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
input_iterator<int *>(num + 1), input_iterator<int *>(num + 2)),
|
||||
input_iterator<int *>(num + 1), input_iterator<int *>(num + 2)));
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
input_iterator<int *>(num + 1), input_iterator<int *>(num + 2)),
|
||||
input_iterator<int *>(num + 1), input_iterator<int *>(num + 2)));
|
||||
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
input_iterator<int *>(num + 1), input_iterator<int *>(num + 2),
|
||||
eq<int> ),
|
||||
input_iterator<int *>(num + 1), input_iterator<int *>(num + 2)));
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
input_iterator<int *>(num + 1), input_iterator<int *>(num + 2),
|
||||
eq<int> ),
|
||||
input_iterator<int *>(num + 1), input_iterator<int *>(num + 2)));
|
||||
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num + 2), input_iterator<int *>(num + 3),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + 1)),
|
||||
input_iterator<int *>(num + 2), input_iterator<int *>(num)));
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num + 2), input_iterator<int *>(num + 3),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + 1)),
|
||||
input_iterator<int *>(num + 2), input_iterator<int *>(num)));
|
||||
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num + 2), input_iterator<int *>(num + 3),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
eq<int> ),
|
||||
input_iterator<int *>(num + 2), input_iterator<int *>(num)));
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num + 2), input_iterator<int *>(num + 3),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + 1),
|
||||
eq<int> ),
|
||||
input_iterator<int *>(num + 2), input_iterator<int *>(num)));
|
||||
|
||||
|
||||
|
||||
// Identical long sequences are equal.
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + sz)),
|
||||
input_iterator<int *>(num + sz), input_iterator<int *>(num + sz)));
|
||||
// Identical long sequences are equal.
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + sz)),
|
||||
input_iterator<int *>(num + sz), input_iterator<int *>(num + sz)));
|
||||
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
eq<int> ),
|
||||
input_iterator<int *>(num + sz), input_iterator<int *>(num + sz)));
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
eq<int> ),
|
||||
input_iterator<int *>(num + sz), input_iterator<int *>(num + sz)));
|
||||
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
never_eq<int> ),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num)));
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
never_eq<int> ),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num)));
|
||||
|
||||
// different sequences are different
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num + 1), input_iterator<int *>(num + sz),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + sz)),
|
||||
input_iterator<int *>(num + 2), input_iterator<int *>(num + 1)));
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
random_access_iterator<int *>(num), random_access_iterator<int *>(num + sz),
|
||||
never_eq<int> ),
|
||||
input_iterator<int *>(num), random_access_iterator<int *>(num)));
|
||||
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num + 1), input_iterator<int *>(num + sz),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
eq<int> ),
|
||||
input_iterator<int *>(num + 2), input_iterator<int *>(num + 1)));
|
||||
// different sequences are different
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num + 1), input_iterator<int *>(num + sz),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + sz)),
|
||||
input_iterator<int *>(num + 2), input_iterator<int *>(num + 1)));
|
||||
|
||||
BOOST_CHECK ( iter_eq (
|
||||
ba::mismatch ( input_iterator<int *>(num + 1), input_iterator<int *>(num + sz),
|
||||
input_iterator<int *>(num), input_iterator<int *>(num + sz),
|
||||
eq<int> ),
|
||||
input_iterator<int *>(num + 2), input_iterator<int *>(num + 1)));
|
||||
|
||||
}
|
||||
|
||||
|
0
test/search_test1.cpp
Executable file → Normal file
0
test/search_test1.cpp
Executable file → Normal file
0
test/search_test2.cpp
Executable file → Normal file
0
test/search_test2.cpp
Executable file → Normal file
0
test/search_test3.cpp
Executable file → Normal file
0
test/search_test3.cpp
Executable file → Normal file
@ -1,76 +0,0 @@
|
||||
/*
|
||||
Copyright (c) Marshall Clow 2012.
|
||||
|
||||
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)
|
||||
|
||||
For more information, see http://www.boost.org
|
||||
*/
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/algorithm/wrappers.hpp>
|
||||
|
||||
#define BOOST_TEST_MAIN
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
namespace ba = boost::algorithm;
|
||||
|
||||
void test_int ()
|
||||
{
|
||||
std::map<int, int> m;
|
||||
std::multimap<int, int> mm;
|
||||
|
||||
int *ptr;
|
||||
|
||||
// try with an empty map
|
||||
BOOST_CHECK ( ba::find_ptr ( m , 3 ) == NULL );
|
||||
BOOST_CHECK ( ba::find_ptr ( mm, 3 ) == NULL );
|
||||
|
||||
m.insert ( std::make_pair <int, int> ( 5, 5 ));
|
||||
mm.insert ( std::make_pair <int, int> ( 9, 9 ));
|
||||
BOOST_CHECK ( ba::find_ptr ( m , 3 ) == NULL );
|
||||
BOOST_CHECK ( ba::find_ptr ( mm, 3 ) == NULL );
|
||||
|
||||
ptr = ba::find_ptr ( m, 5 );
|
||||
BOOST_CHECK ( ptr != NULL && *ptr == 5 );
|
||||
BOOST_CHECK ( ba::find_ptr ( m , 9 ) == NULL );
|
||||
|
||||
ptr = ba::find_ptr ( mm, 9 );
|
||||
BOOST_CHECK ( ptr != NULL && *ptr == 9 );
|
||||
BOOST_CHECK ( ba::find_ptr ( mm, 5 ) == NULL );
|
||||
|
||||
}
|
||||
|
||||
void test_str ()
|
||||
{
|
||||
std::map<int, std::string> m;
|
||||
std::multimap<int, std::string> mm;
|
||||
std::string *ptr;
|
||||
|
||||
// try with an empty map
|
||||
BOOST_CHECK ( ba::find_ptr ( m , 31 ) == NULL );
|
||||
BOOST_CHECK ( ba::find_ptr ( mm, 31 ) == NULL );
|
||||
|
||||
m.insert ( std::make_pair <int, std::string> ( 55, "fifty-five" ));
|
||||
mm.insert ( std::make_pair <int, std::string> ( 66, "sixty-six" ));
|
||||
BOOST_CHECK ( ba::find_ptr ( m , 3 ) == NULL );
|
||||
BOOST_CHECK ( ba::find_ptr ( mm, 3 ) == NULL );
|
||||
|
||||
ptr = ba::find_ptr ( m, 55 );
|
||||
BOOST_CHECK ( ptr != NULL && *ptr == "fifty-five" );
|
||||
BOOST_CHECK ( ba::find_ptr ( m , 66 ) == NULL );
|
||||
|
||||
ptr = ba::find_ptr ( mm, 66 );
|
||||
BOOST_CHECK ( ptr != NULL && *ptr == "sixty-six" );
|
||||
BOOST_CHECK ( ba::find_ptr ( mm, 55 ) == NULL );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test_main )
|
||||
{
|
||||
test_int ();
|
||||
test_str ();
|
||||
}
|
Reference in New Issue
Block a user