mirror of
https://github.com/boostorg/algorithm.git
synced 2025-07-06 09:16:33 +02:00
Fix tabs in file.
[SVN r24039]
This commit is contained in:
@ -64,52 +64,52 @@ namespace boost {
|
|||||||
// if only one element
|
// if only one element
|
||||||
ForwardIter second = first; ++second;
|
ForwardIter second = first; ++second;
|
||||||
if (second == last)
|
if (second == last)
|
||||||
return std::make_pair(min_result, max_result);
|
return std::make_pair(min_result, max_result);
|
||||||
|
|
||||||
// treat first pair separately (only one comparison for first two elements)
|
// treat first pair separately (only one comparison for first two elements)
|
||||||
ForwardIter potential_min_result = last;
|
ForwardIter potential_min_result = last;
|
||||||
if (comp(first, second))
|
if (comp(first, second))
|
||||||
max_result = second;
|
max_result = second;
|
||||||
else {
|
else {
|
||||||
min_result = second;
|
min_result = second;
|
||||||
potential_min_result = first;
|
potential_min_result = first;
|
||||||
}
|
}
|
||||||
|
|
||||||
// then each element by pairs, with at most 3 comparisons per pair
|
// then each element by pairs, with at most 3 comparisons per pair
|
||||||
first = ++second; if (first != last) ++second;
|
first = ++second; if (first != last) ++second;
|
||||||
while (second != last) {
|
while (second != last) {
|
||||||
if (comp(first, second)) {
|
if (comp(first, second)) {
|
||||||
if (comp(first, min_result)) {
|
if (comp(first, min_result)) {
|
||||||
min_result = first;
|
min_result = first;
|
||||||
potential_min_result = last;
|
potential_min_result = last;
|
||||||
}
|
}
|
||||||
if (comp(max_result, second))
|
if (comp(max_result, second))
|
||||||
max_result = second;
|
max_result = second;
|
||||||
} else {
|
} else {
|
||||||
if (comp(second, min_result)) {
|
if (comp(second, min_result)) {
|
||||||
min_result = second;
|
min_result = second;
|
||||||
potential_min_result = first;
|
potential_min_result = first;
|
||||||
}
|
}
|
||||||
if (comp(max_result, first))
|
if (comp(max_result, first))
|
||||||
max_result = first;
|
max_result = first;
|
||||||
}
|
}
|
||||||
first = ++second;
|
first = ++second;
|
||||||
if (first != last) ++second;
|
if (first != last) ++second;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if odd number of elements, treat last element
|
// if odd number of elements, treat last element
|
||||||
if (first != last) { // odd number of elements
|
if (first != last) { // odd number of elements
|
||||||
if (comp(first, min_result))
|
if (comp(first, min_result))
|
||||||
min_result = first, potential_min_result = last;
|
min_result = first, potential_min_result = last;
|
||||||
else if (comp(max_result, first))
|
else if (comp(max_result, first))
|
||||||
max_result = first;
|
max_result = first;
|
||||||
}
|
}
|
||||||
|
|
||||||
// resolve min_result being incorrect with one extra comparison
|
// resolve min_result being incorrect with one extra comparison
|
||||||
// (in which case potential_min_result is necessarily the correct result)
|
// (in which case potential_min_result is necessarily the correct result)
|
||||||
if (potential_min_result != last
|
if (potential_min_result != last
|
||||||
&& !comp(min_result, potential_min_result))
|
&& !comp(min_result, potential_min_result))
|
||||||
min_result = potential_min_result;
|
min_result = potential_min_result;
|
||||||
|
|
||||||
return std::make_pair(min_result,max_result);
|
return std::make_pair(min_result,max_result);
|
||||||
}
|
}
|
||||||
@ -352,23 +352,23 @@ namespace boost {
|
|||||||
while (second != last) {
|
while (second != last) {
|
||||||
if (!comp(second, first)) {
|
if (!comp(second, first)) {
|
||||||
if (comp(first, min_result))
|
if (comp(first, min_result))
|
||||||
min_result = first;
|
min_result = first;
|
||||||
if (!comp(second, max_result))
|
if (!comp(second, max_result))
|
||||||
max_result = second;
|
max_result = second;
|
||||||
} else {
|
} else {
|
||||||
if (comp(second, min_result))
|
if (comp(second, min_result))
|
||||||
min_result = second;
|
min_result = second;
|
||||||
if (!comp(first, max_result))
|
if (!comp(first, max_result))
|
||||||
max_result = first;
|
max_result = first;
|
||||||
}
|
}
|
||||||
first = ++second; if (first != last) ++second;
|
first = ++second; if (first != last) ++second;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (first != last) {
|
if (first != last) {
|
||||||
if (comp(first, min_result))
|
if (comp(first, min_result))
|
||||||
min_result = first;
|
min_result = first;
|
||||||
else if (!comp(first, max_result))
|
else if (!comp(first, max_result))
|
||||||
max_result = first;
|
max_result = first;
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::make_pair(min_result, max_result);
|
return std::make_pair(min_result, max_result);
|
||||||
@ -448,15 +448,15 @@ namespace boost {
|
|||||||
min_result = first;
|
min_result = first;
|
||||||
if (!comp(second, max_result)) {
|
if (!comp(second, max_result)) {
|
||||||
max_result = second;
|
max_result = second;
|
||||||
potential_max_result = last;
|
potential_max_result = last;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!comp(min_result, second))
|
if (!comp(min_result, second))
|
||||||
min_result = second;
|
min_result = second;
|
||||||
if (!comp(first, max_result)) {
|
if (!comp(first, max_result)) {
|
||||||
max_result = first;
|
max_result = first;
|
||||||
potential_max_result = second;
|
potential_max_result = second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
first = ++second;
|
first = ++second;
|
||||||
if (first != last) ++second;
|
if (first != last) ++second;
|
||||||
@ -467,7 +467,7 @@ namespace boost {
|
|||||||
min_result = first;
|
min_result = first;
|
||||||
if (!comp(first, max_result)) {
|
if (!comp(first, max_result)) {
|
||||||
max_result = first;
|
max_result = first;
|
||||||
potential_max_result = last;
|
potential_max_result = last;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,14 +55,14 @@ int repeats = 10;
|
|||||||
for (int i=0; i<repeats; ++i) { cmd ; } \
|
for (int i=0; i<repeats; ++i) { cmd ; } \
|
||||||
std::cout << " " << std::setprecision(4) \
|
std::cout << " " << std::setprecision(4) \
|
||||||
<< (double)n*repeats/t.elapsed()/1.0E6 \
|
<< (double)n*repeats/t.elapsed()/1.0E6 \
|
||||||
<< "M items/sec " << cmdname << "\n"
|
<< "M items/sec " << cmdname << "\n"
|
||||||
|
|
||||||
#define CTIMER( n, cmd , cmdname, count, opt ) \
|
#define CTIMER( n, cmd , cmdname, count, opt ) \
|
||||||
t.restart(); lc.reset(); \
|
t.restart(); lc.reset(); \
|
||||||
for (int i=0; i<repeats; ++i) { cmd ; } \
|
for (int i=0; i<repeats; ++i) { cmd ; } \
|
||||||
std::cout << " " << std::setprecision(4) \
|
std::cout << " " << std::setprecision(4) \
|
||||||
<< (double)n*repeats/t.elapsed()/1.0E6 \
|
<< (double)n*repeats/t.elapsed()/1.0E6 \
|
||||||
<< "M items/sec " << cmdname \
|
<< "M items/sec " << cmdname \
|
||||||
<< " ("<< (count)/repeats << " vs " << opt << ")\n"
|
<< " ("<< (count)/repeats << " vs " << opt << ")\n"
|
||||||
|
|
||||||
template <class CIterator>
|
template <class CIterator>
|
||||||
@ -99,10 +99,10 @@ void test_minmax_element(CIterator first, CIterator last, int n, char* name)
|
|||||||
TIMER( n, boost::max_element_if(first, last, pred),
|
TIMER( n, boost::max_element_if(first, last, pred),
|
||||||
"boost::max_element_if" << name << "");
|
"boost::max_element_if" << name << "");
|
||||||
TIMER( n, std::min_element(boost::make_filter_iterator(first, last, pred),
|
TIMER( n, std::min_element(boost::make_filter_iterator(first, last, pred),
|
||||||
boost::make_filter_iterator(last, last, pred)),
|
boost::make_filter_iterator(last, last, pred)),
|
||||||
"std::min_element_with_filter_iterator" << name << "");
|
"std::min_element_with_filter_iterator" << name << "");
|
||||||
TIMER( n, std::max_element(boost::make_filter_iterator(first, last, pred),
|
TIMER( n, std::max_element(boost::make_filter_iterator(first, last, pred),
|
||||||
boost::make_filter_iterator(last, last, pred)),
|
boost::make_filter_iterator(last, last, pred)),
|
||||||
"std::max_element_if_with_filter_iterator" << name << "");
|
"std::max_element_if_with_filter_iterator" << name << "");
|
||||||
#undef pred
|
#undef pred
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ void test_minmax(CIterator first, CIterator last, int n)
|
|||||||
template <class Container, class Iterator, class Value>
|
template <class Container, class Iterator, class Value>
|
||||||
void test_container(Iterator first, Iterator last, int n,
|
void test_container(Iterator first, Iterator last, int n,
|
||||||
Container* dummy = 0
|
Container* dummy = 0
|
||||||
BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Value) )
|
BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Value) )
|
||||||
{
|
{
|
||||||
Container c(first, last);
|
Container c(first, last);
|
||||||
test_minmax(c.begin(), c.end(), n);
|
test_minmax(c.begin(), c.end(), n);
|
||||||
|
Reference in New Issue
Block a user