mirror of
https://github.com/boostorg/algorithm.git
synced 2026-01-25 17:52:08 +00:00
Compare commits
87 Commits
develop
...
boost-1.59
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a09963bf93 | ||
|
|
cf249c090c | ||
|
|
645be22fa7 | ||
|
|
28b12d7264 | ||
|
|
4d28d579e3 | ||
|
|
5adab54486 | ||
|
|
685a76f094 | ||
|
|
5988a55b96 | ||
|
|
850fc02667 | ||
|
|
5279c8f061 | ||
|
|
8b89b5ba27 | ||
|
|
ca23b6f4f8 | ||
|
|
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 |
@@ -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
|
||||
@@ -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