mirror of
https://github.com/boostorg/algorithm.git
synced 2025-06-25 20:11:50 +02:00
Compare commits
8 Commits
boost-1.80
...
esp-idf-co
Author | SHA1 | Date | |
---|---|---|---|
9dc04a60f4 | |||
e4d4a685da | |||
7d8a063d35 | |||
0666c4ce35 | |||
6f4d74c6bb | |||
6d58f2b9d1 | |||
6a5ca4e89c | |||
e8ba63c4ad |
@ -3,6 +3,8 @@
|
|||||||
# Distributed under the Boost Software License, Version 1.0.
|
# Distributed under the Boost Software License, Version 1.0.
|
||||||
# https://www.boost.org/LICENSE_1_0.txt
|
# https://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
if(NOT DEFINED IDF_TARGET)
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.5...3.16)
|
cmake_minimum_required(VERSION 3.5...3.16)
|
||||||
|
|
||||||
project(boost_algorithm VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
project(boost_algorithm VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
||||||
@ -39,3 +41,33 @@ if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
|
|||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
else()
|
||||||
|
|
||||||
|
FILE(GLOB_RECURSE headers include/*.h include/*.hpp)
|
||||||
|
|
||||||
|
idf_component_register(
|
||||||
|
SRCS
|
||||||
|
${headers}
|
||||||
|
INCLUDE_DIRS
|
||||||
|
include
|
||||||
|
REQUIRES
|
||||||
|
boost_array
|
||||||
|
boost_assert
|
||||||
|
boost_bind
|
||||||
|
boost_concept_check
|
||||||
|
boost_config
|
||||||
|
boost_core
|
||||||
|
boost_exception
|
||||||
|
boost_function
|
||||||
|
boost_iterator
|
||||||
|
boost_mpl
|
||||||
|
boost_range
|
||||||
|
boost_regex
|
||||||
|
boost_static_assert
|
||||||
|
boost_throw_exception
|
||||||
|
boost_tuple
|
||||||
|
boost_type_traits
|
||||||
|
boost_unordered
|
||||||
|
)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
@ -16,12 +16,12 @@ The routine `apply_permutation` takes a item sequence and a order sequence. It r
|
|||||||
The routine `apply_reverse_permutation` takes a item sequence and a order sequence. It will reshuffle item sequence according to order sequence. Every value in order sequence means where the item goes to. Order sequence needs to be exactly a permutation of the sequence [0, 1, ... , N], where N is the biggest index in the item sequence (zero-indexed).
|
The routine `apply_reverse_permutation` takes a item sequence and a order sequence. It will reshuffle item sequence according to order sequence. Every value in order sequence means where the item goes to. Order sequence needs to be exactly a permutation of the sequence [0, 1, ... , N], where N is the biggest index in the item sequence (zero-indexed).
|
||||||
|
|
||||||
Implementations are based on these articles:
|
Implementations are based on these articles:
|
||||||
https://blogs.msdn.microsoft.com/oldnewthing/20170102-00/?p=95095
|
https://devblogs.microsoft.com/oldnewthing/20170102-00/?p=95095
|
||||||
https://blogs.msdn.microsoft.com/oldnewthing/20170103-00/?p=95105
|
https://devblogs.microsoft.com/oldnewthing/20170103-00/?p=95105
|
||||||
https://blogs.msdn.microsoft.com/oldnewthing/20170104-00/?p=95115
|
https://devblogs.microsoft.com/oldnewthing/20170104-00/?p=95115
|
||||||
https://blogs.msdn.microsoft.com/oldnewthing/20170109-00/?p=95145
|
https://devblogs.microsoft.com/oldnewthing/20170109-00/?p=95145
|
||||||
https://blogs.msdn.microsoft.com/oldnewthing/20170110-00/?p=95155
|
https://devblogs.microsoft.com/oldnewthing/20170110-00/?p=95155
|
||||||
https://blogs.msdn.microsoft.com/oldnewthing/20170111-00/?p=95165
|
https://devblogs.microsoft.com/oldnewthing/20170111-00/?p=95165
|
||||||
|
|
||||||
The routines come in 2 forms; the first one takes two iterators to define the item range and one iterator to define the beginning of index range. The second form takes range to define the item sequence and range to define index sequence.
|
The routines come in 2 forms; the first one takes two iterators to define the item range and one iterator to define the beginning of index range. The second form takes range to define the item sequence and range to define index sequence.
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include <functional> // for plus and multiplies
|
#include <functional> // for plus and multiplies
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <boost/utility/enable_if.hpp> // for boost::disable_if
|
#include <boost/core/enable_if.hpp> // for boost::disable_if
|
||||||
#include <boost/type_traits/is_integral.hpp>
|
#include <boost/type_traits/is_integral.hpp>
|
||||||
|
|
||||||
namespace boost { namespace algorithm {
|
namespace boost { namespace algorithm {
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include <boost/range/begin.hpp>
|
#include <boost/range/begin.hpp>
|
||||||
#include <boost/range/end.hpp>
|
#include <boost/range/end.hpp>
|
||||||
#include <boost/type_traits/type_identity.hpp> // for boost::type_identity
|
#include <boost/type_traits/type_identity.hpp> // for boost::type_identity
|
||||||
#include <boost/utility/enable_if.hpp> // for boost::disable_if
|
#include <boost/core/enable_if.hpp> // for boost::disable_if
|
||||||
|
|
||||||
namespace boost { namespace algorithm {
|
namespace boost { namespace algorithm {
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <boost/range/begin.hpp>
|
#include <boost/range/begin.hpp>
|
||||||
#include <boost/range/end.hpp>
|
#include <boost/range/end.hpp>
|
||||||
#include <boost/utility/enable_if.hpp>
|
#include <boost/core/enable_if.hpp>
|
||||||
#include <boost/type_traits/is_same.hpp>
|
#include <boost/type_traits/is_same.hpp>
|
||||||
|
|
||||||
namespace boost { namespace algorithm {
|
namespace boost { namespace algorithm {
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include <boost/range/begin.hpp>
|
#include <boost/range/begin.hpp>
|
||||||
#include <boost/range/end.hpp>
|
#include <boost/range/end.hpp>
|
||||||
|
|
||||||
#include <boost/utility/enable_if.hpp>
|
#include <boost/core/enable_if.hpp>
|
||||||
#include <boost/type_traits/is_same.hpp>
|
#include <boost/type_traits/is_same.hpp>
|
||||||
#include <boost/type_traits/type_identity.hpp> // for boost::type_identity
|
#include <boost/type_traits/type_identity.hpp> // for boost::type_identity
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#include <boost/exception/info.hpp>
|
#include <boost/exception/info.hpp>
|
||||||
#include <boost/throw_exception.hpp>
|
#include <boost/throw_exception.hpp>
|
||||||
|
|
||||||
#include <boost/utility/enable_if.hpp>
|
#include <boost/core/enable_if.hpp>
|
||||||
#include <boost/type_traits/is_integral.hpp>
|
#include <boost/type_traits/is_integral.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ bool is_palindrome(const R& range, Predicate p)
|
|||||||
/// \note This function will return true for empty sequences and for palindromes.
|
/// \note This function will return true for empty sequences and for palindromes.
|
||||||
/// For other sequences function will return false.
|
/// For other sequences function will return false.
|
||||||
/// Complexity: O(N).
|
/// Complexity: O(N).
|
||||||
bool is_palindrome(const char* str)
|
inline bool is_palindrome(const char* str)
|
||||||
{
|
{
|
||||||
if(!str)
|
if(!str)
|
||||||
return true;
|
return true;
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include <boost/range/begin.hpp>
|
#include <boost/range/begin.hpp>
|
||||||
#include <boost/range/end.hpp>
|
#include <boost/range/end.hpp>
|
||||||
|
|
||||||
#include <boost/utility/enable_if.hpp>
|
#include <boost/core/enable_if.hpp>
|
||||||
#include <boost/type_traits/is_same.hpp>
|
#include <boost/type_traits/is_same.hpp>
|
||||||
|
|
||||||
#include <boost/algorithm/searching/detail/bm_traits.hpp>
|
#include <boost/algorithm/searching/detail/bm_traits.hpp>
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include <boost/range/begin.hpp>
|
#include <boost/range/begin.hpp>
|
||||||
#include <boost/range/end.hpp>
|
#include <boost/range/end.hpp>
|
||||||
|
|
||||||
#include <boost/utility/enable_if.hpp>
|
#include <boost/core/enable_if.hpp>
|
||||||
#include <boost/type_traits/is_same.hpp>
|
#include <boost/type_traits/is_same.hpp>
|
||||||
|
|
||||||
#include <boost/algorithm/searching/detail/bm_traits.hpp>
|
#include <boost/algorithm/searching/detail/bm_traits.hpp>
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include <boost/range/begin.hpp>
|
#include <boost/range/begin.hpp>
|
||||||
#include <boost/range/end.hpp>
|
#include <boost/range/end.hpp>
|
||||||
|
|
||||||
#include <boost/utility/enable_if.hpp>
|
#include <boost/core/enable_if.hpp>
|
||||||
#include <boost/type_traits/is_same.hpp>
|
#include <boost/type_traits/is_same.hpp>
|
||||||
|
|
||||||
#include <boost/algorithm/searching/detail/debugging.hpp>
|
#include <boost/algorithm/searching/detail/debugging.hpp>
|
||||||
|
@ -28,8 +28,8 @@
|
|||||||
namespace ba = boost::algorithm;
|
namespace ba = boost::algorithm;
|
||||||
// namespace ba = boost;
|
// namespace ba = boost;
|
||||||
|
|
||||||
BOOST_CXX14_CONSTEXPR bool is_true ( int v ) { return true; }
|
BOOST_CXX14_CONSTEXPR bool is_true ( int ) { return true; }
|
||||||
BOOST_CXX14_CONSTEXPR bool is_false ( int v ) { return false; }
|
BOOST_CXX14_CONSTEXPR bool is_false ( int ) { return false; }
|
||||||
BOOST_CXX14_CONSTEXPR bool is_even ( int v ) { return v % 2 == 0; }
|
BOOST_CXX14_CONSTEXPR bool is_even ( int v ) { return v % 2 == 0; }
|
||||||
BOOST_CXX14_CONSTEXPR bool is_odd ( int v ) { return v % 2 == 1; }
|
BOOST_CXX14_CONSTEXPR bool is_odd ( int v ) { return v % 2 == 1; }
|
||||||
BOOST_CXX14_CONSTEXPR bool is_zero ( int v ) { return v == 0; }
|
BOOST_CXX14_CONSTEXPR bool is_zero ( int v ) { return v == 0; }
|
||||||
|
@ -25,7 +25,7 @@ void test_short_input1 () {
|
|||||||
std::string s;
|
std::string s;
|
||||||
|
|
||||||
try { ba::unhex ( std::string ( "A" ), std::back_inserter(s)); }
|
try { ba::unhex ( std::string ( "A" ), std::back_inserter(s)); }
|
||||||
catch ( const std::exception &ex ) { return; }
|
catch ( const std::exception & ) { return; }
|
||||||
BOOST_TEST_MESSAGE ( "Failed to catch std::exception in test_short_input1" );
|
BOOST_TEST_MESSAGE ( "Failed to catch std::exception in test_short_input1" );
|
||||||
BOOST_CHECK ( false );
|
BOOST_CHECK ( false );
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@ void test_short_input2 () {
|
|||||||
std::string s;
|
std::string s;
|
||||||
|
|
||||||
try { ba::unhex ( std::string ( "A" ), std::back_inserter(s)); }
|
try { ba::unhex ( std::string ( "A" ), std::back_inserter(s)); }
|
||||||
catch ( const ba::hex_decode_error &ex ) { return; }
|
catch ( const ba::hex_decode_error & ) { return; }
|
||||||
BOOST_TEST_MESSAGE ( "Failed to catch ba::hex_decode_error in test_short_input2" );
|
BOOST_TEST_MESSAGE ( "Failed to catch ba::hex_decode_error in test_short_input2" );
|
||||||
BOOST_CHECK ( false );
|
BOOST_CHECK ( false );
|
||||||
}
|
}
|
||||||
@ -43,7 +43,7 @@ void test_short_input3 () {
|
|||||||
std::string s;
|
std::string s;
|
||||||
|
|
||||||
try { ba::unhex ( std::string ( "A" ), std::back_inserter(s)); }
|
try { ba::unhex ( std::string ( "A" ), std::back_inserter(s)); }
|
||||||
catch ( const ba::not_enough_input &ex ) { return; }
|
catch ( const ba::not_enough_input & ) { return; }
|
||||||
BOOST_TEST_MESSAGE ( "Failed to catch ba::not_enough_input in test_short_input3" );
|
BOOST_TEST_MESSAGE ( "Failed to catch ba::not_enough_input in test_short_input3" );
|
||||||
BOOST_CHECK ( false );
|
BOOST_CHECK ( false );
|
||||||
}
|
}
|
||||||
@ -53,8 +53,8 @@ void test_short_input4 () {
|
|||||||
std::string s;
|
std::string s;
|
||||||
|
|
||||||
try { ba::unhex ( std::string ( "A" ), std::back_inserter(s)); }
|
try { ba::unhex ( std::string ( "A" ), std::back_inserter(s)); }
|
||||||
catch ( const ba::non_hex_input &ex ) { BOOST_CHECK ( false ); }
|
catch ( const ba::non_hex_input & ) { BOOST_CHECK ( false ); }
|
||||||
catch ( const ba::not_enough_input &ex ) { return; }
|
catch ( const ba::not_enough_input & ) { return; }
|
||||||
catch ( ... ) { BOOST_CHECK ( false ); }
|
catch ( ... ) { BOOST_CHECK ( false ); }
|
||||||
BOOST_CHECK ( false );
|
BOOST_CHECK ( false );
|
||||||
}
|
}
|
||||||
@ -64,8 +64,8 @@ void test_short_input5 () {
|
|||||||
std::string s;
|
std::string s;
|
||||||
|
|
||||||
try { ba::unhex ( "A", std::back_inserter(s)); }
|
try { ba::unhex ( "A", std::back_inserter(s)); }
|
||||||
catch ( const ba::non_hex_input &ex ) { BOOST_CHECK ( false ); }
|
catch ( const ba::non_hex_input & ) { BOOST_CHECK ( false ); }
|
||||||
catch ( const ba::not_enough_input &ex ) { return; }
|
catch ( const ba::not_enough_input & ) { return; }
|
||||||
catch ( ... ) { BOOST_CHECK ( false ); }
|
catch ( ... ) { BOOST_CHECK ( false ); }
|
||||||
BOOST_CHECK ( false );
|
BOOST_CHECK ( false );
|
||||||
}
|
}
|
||||||
@ -125,8 +125,8 @@ void test_nonhex_input4 () {
|
|||||||
std::string s;
|
std::string s;
|
||||||
|
|
||||||
try { ba::unhex ( "P1234FA1234", std::back_inserter(s)); }
|
try { ba::unhex ( "P1234FA1234", std::back_inserter(s)); }
|
||||||
catch ( const ba::not_enough_input &ex ) { BOOST_CHECK ( false ); }
|
catch ( const ba::not_enough_input & ) { BOOST_CHECK ( false ); }
|
||||||
catch ( const ba::non_hex_input &ex ) { return; }
|
catch ( const ba::non_hex_input & ) { return; }
|
||||||
catch ( ... ) { BOOST_CHECK ( false ); }
|
catch ( ... ) { BOOST_CHECK ( false ); }
|
||||||
BOOST_CHECK ( false );
|
BOOST_CHECK ( false );
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ void test_sequence1 () {
|
|||||||
std::vector<int> v, v1;
|
std::vector<int> v, v1;
|
||||||
|
|
||||||
v.clear ();
|
v.clear ();
|
||||||
for ( std::size_t i = 5; i < 15; ++i )
|
for ( int i = 5; i < 15; ++i )
|
||||||
v.push_back ( i );
|
v.push_back ( i );
|
||||||
v1 = v;
|
v1 = v;
|
||||||
BOOST_CHECK ( ba::is_permutation ( v.begin (), v.end (), v.begin ())); // better be a permutation of itself!
|
BOOST_CHECK ( ba::is_permutation ( v.begin (), v.end (), v.begin ())); // better be a permutation of itself!
|
||||||
|
@ -32,7 +32,7 @@ namespace {
|
|||||||
|
|
||||||
// Check using iterators
|
// Check using iterators
|
||||||
template<typename Container>
|
template<typename Container>
|
||||||
void check_one_iter ( const Container &haystack, const std::string &needle, int expected ) {
|
void check_one_iter ( const Container &haystack, const std::string &needle, std::ptrdiff_t expected ) {
|
||||||
typedef typename Container::const_iterator iter_type;
|
typedef typename Container::const_iterator iter_type;
|
||||||
typedef typename std::pair<iter_type, iter_type> ret_type;
|
typedef typename std::pair<iter_type, iter_type> ret_type;
|
||||||
typedef std::string::const_iterator pattern_type;
|
typedef std::string::const_iterator pattern_type;
|
||||||
@ -53,7 +53,7 @@ namespace {
|
|||||||
// iter_type it1r = ret1r.first;
|
// iter_type it1r = ret1r.first;
|
||||||
// iter_type it2 = ret2.first;
|
// iter_type it2 = ret2.first;
|
||||||
// iter_type it3 = ret3.first;
|
// iter_type it3 = ret3.first;
|
||||||
const int dist = ret1.first == hEnd ? -1 : std::distance ( hBeg, ret1.first );
|
const std::ptrdiff_t dist = ret1.first == hEnd ? -1 : std::distance ( hBeg, ret1.first );
|
||||||
|
|
||||||
std::cout << "(Iterators) Pattern is " << needle.length () << ", haysstack is " << haystack.length () << " chars long; " << std::endl;
|
std::cout << "(Iterators) Pattern is " << needle.length () << ", haysstack is " << haystack.length () << " chars long; " << std::endl;
|
||||||
try {
|
try {
|
||||||
@ -97,7 +97,7 @@ namespace {
|
|||||||
// Check using pointers
|
// Check using pointers
|
||||||
// We're assuming that the container implements contiguous storage here.
|
// We're assuming that the container implements contiguous storage here.
|
||||||
template<typename Container>
|
template<typename Container>
|
||||||
void check_one_pointer ( const Container &haystack, const std::string &needle, int expected ) {
|
void check_one_pointer ( const Container &haystack, const std::string &needle, std::ptrdiff_t expected ) {
|
||||||
typedef const typename Container::value_type *ptr_type;
|
typedef const typename Container::value_type *ptr_type;
|
||||||
typedef typename std::pair<ptr_type, ptr_type> ret_type;
|
typedef typename std::pair<ptr_type, ptr_type> ret_type;
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ namespace {
|
|||||||
ret_type ret1 = ba::boyer_moore_search (hBeg, hEnd, nBeg, nEnd);
|
ret_type ret1 = ba::boyer_moore_search (hBeg, hEnd, nBeg, nEnd);
|
||||||
ret_type ret2 = ba::boyer_moore_horspool_search (hBeg, hEnd, nBeg, nEnd);
|
ret_type ret2 = ba::boyer_moore_horspool_search (hBeg, hEnd, nBeg, nEnd);
|
||||||
ret_type ret3 = ba::knuth_morris_pratt_search (hBeg, hEnd, nBeg, nEnd);
|
ret_type ret3 = ba::knuth_morris_pratt_search (hBeg, hEnd, nBeg, nEnd);
|
||||||
const int dist = ret1.first == hEnd ? -1 : std::distance ( hBeg, ret1.first );
|
const std::ptrdiff_t dist = ret1.first == hEnd ? -1 : std::distance ( hBeg, ret1.first );
|
||||||
|
|
||||||
std::cout << "(Pointers) Pattern is " << needle.length () << ", haysstack is " << haystack.length () << " chars long; " << std::endl;
|
std::cout << "(Pointers) Pattern is " << needle.length () << ", haysstack is " << haystack.length () << " chars long; " << std::endl;
|
||||||
try {
|
try {
|
||||||
@ -147,7 +147,7 @@ namespace {
|
|||||||
|
|
||||||
// Check using objects
|
// Check using objects
|
||||||
template<typename Container>
|
template<typename Container>
|
||||||
void check_one_object ( const Container &haystack, const std::string &needle, int expected ) {
|
void check_one_object ( const Container &haystack, const std::string &needle, std::ptrdiff_t expected ) {
|
||||||
typedef typename Container::const_iterator iter_type;
|
typedef typename Container::const_iterator iter_type;
|
||||||
typedef typename std::pair<iter_type, iter_type> ret_type;
|
typedef typename std::pair<iter_type, iter_type> ret_type;
|
||||||
typedef std::string::const_iterator pattern_type;
|
typedef std::string::const_iterator pattern_type;
|
||||||
@ -169,7 +169,7 @@ namespace {
|
|||||||
ret_type retr1r = bm_r (haystack);
|
ret_type retr1r = bm_r (haystack);
|
||||||
ret_type ret2 = bmh (hBeg, hEnd);
|
ret_type ret2 = bmh (hBeg, hEnd);
|
||||||
ret_type ret3 = kmp (hBeg, hEnd);
|
ret_type ret3 = kmp (hBeg, hEnd);
|
||||||
const int dist = ret1.first == hEnd ? -1 : std::distance ( hBeg, ret1.first );
|
const std::ptrdiff_t dist = ret1.first == hEnd ? -1 : std::distance ( hBeg, ret1.first );
|
||||||
|
|
||||||
std::cout << "(Objects) Pattern is " << needle.length () << ", haysstack is " << haystack.length () << " chars long; " << std::endl;
|
std::cout << "(Objects) Pattern is " << needle.length () << ", haysstack is " << haystack.length () << " chars long; " << std::endl;
|
||||||
try {
|
try {
|
||||||
@ -224,7 +224,7 @@ namespace {
|
|||||||
|
|
||||||
|
|
||||||
template<typename Container>
|
template<typename Container>
|
||||||
void check_one ( const Container &haystack, const std::string &needle, int expected ) {
|
void check_one ( const Container &haystack, const std::string &needle, std::ptrdiff_t expected ) {
|
||||||
check_one_iter ( haystack, needle, expected );
|
check_one_iter ( haystack, needle, expected );
|
||||||
check_one_pointer ( haystack, needle, expected );
|
check_one_pointer ( haystack, needle, expected );
|
||||||
check_one_object ( haystack, needle, expected );
|
check_one_object ( haystack, needle, expected );
|
||||||
|
@ -85,7 +85,7 @@ namespace {
|
|||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void check_one ( const vec &haystack, const vec &needle, int expected ) {
|
void check_one ( const vec &haystack, const vec &needle, std::ptrdiff_t expected ) {
|
||||||
std::size_t i;
|
std::size_t i;
|
||||||
std::clock_t sTime;
|
std::clock_t sTime;
|
||||||
unsigned long stdDiff;
|
unsigned long stdDiff;
|
||||||
@ -147,7 +147,7 @@ BOOST_AUTO_TEST_CASE( test_main )
|
|||||||
std::cout << "---- Middle -----" << std::endl;
|
std::cout << "---- Middle -----" << std::endl;
|
||||||
check_one ( c1, p1f, -2 ); // Don't know answer
|
check_one ( c1, p1f, -2 ); // Don't know answer
|
||||||
std::cout << "------ End ------" << std::endl;
|
std::cout << "------ End ------" << std::endl;
|
||||||
check_one ( c1, p1e, c1.size() - p1e.size ());
|
check_one ( c1, p1e, static_cast<std::ptrdiff_t>(c1.size() - p1e.size ()));
|
||||||
std::cout << "--- Not found ---" << std::endl;
|
std::cout << "--- Not found ---" << std::endl;
|
||||||
check_one ( c1, p1n, -1 ); // Not found
|
check_one ( c1, p1n, -1 ); // Not found
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ namespace {
|
|||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void check_one ( const vec &haystack, const vec &needle, int expected ) {
|
void check_one ( const vec &haystack, const vec &needle, std::ptrdiff_t expected ) {
|
||||||
std::size_t i;
|
std::size_t i;
|
||||||
std::clock_t sTime;
|
std::clock_t sTime;
|
||||||
unsigned long stdDiff;
|
unsigned long stdDiff;
|
||||||
@ -147,7 +147,7 @@ BOOST_AUTO_TEST_CASE( test_main )
|
|||||||
std::cout << "---- Middle -----" << std::endl;
|
std::cout << "---- Middle -----" << std::endl;
|
||||||
check_one ( c1, p1f, -2 ); // Don't know answer
|
check_one ( c1, p1f, -2 ); // Don't know answer
|
||||||
std::cout << "------ End ------" << std::endl;
|
std::cout << "------ End ------" << std::endl;
|
||||||
check_one ( c1, p1e, c1.size() - p1e.size ());
|
check_one ( c1, p1e, static_cast<std::ptrdiff_t>(c1.size() - p1e.size ()));
|
||||||
std::cout << "--- Not found ---" << std::endl;
|
std::cout << "--- Not found ---" << std::endl;
|
||||||
check_one ( c1, p1n, -1 ); // Not found
|
check_one ( c1, p1n, -1 ); // Not found
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ namespace {
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void check_one ( const vec &haystack, const vec &needle, int expected ) {
|
void check_one ( const vec &haystack, const vec &needle, std::ptrdiff_t expected ) {
|
||||||
|
|
||||||
std::pair<vec::const_iterator, vec::const_iterator> res;
|
std::pair<vec::const_iterator, vec::const_iterator> res;
|
||||||
std::pair<vec::const_iterator, vec::const_iterator> exp; // the expected result
|
std::pair<vec::const_iterator, vec::const_iterator> exp; // the expected result
|
||||||
@ -117,7 +117,7 @@ BOOST_AUTO_TEST_CASE( test_main )
|
|||||||
std::cout << "---- Middle -----" << std::endl;
|
std::cout << "---- Middle -----" << std::endl;
|
||||||
check_one ( c1, p1f, -2 ); // Don't know answer
|
check_one ( c1, p1f, -2 ); // Don't know answer
|
||||||
std::cout << "------ End ------" << std::endl;
|
std::cout << "------ End ------" << std::endl;
|
||||||
check_one ( c1, p1e, c1.size() - p1e.size ());
|
check_one ( c1, p1e, static_cast<std::ptrdiff_t>(c1.size() - p1e.size ()));
|
||||||
std::cout << "--- Not found ---" << std::endl;
|
std::cout << "--- Not found ---" << std::endl;
|
||||||
check_one ( c1, p1n, -1 ); // Not found
|
check_one ( c1, p1n, -1 ); // Not found
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user