Fix tabs in file.

[SVN r24039]
This commit is contained in:
Rene Rivera
2004-07-25 15:09:51 +00:00
parent 4b3118ed2b
commit 33122fefa7
3 changed files with 43 additions and 43 deletions

View File

@ -64,52 +64,52 @@ namespace boost {
// if only one element
ForwardIter second = first; ++second;
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)
ForwardIter potential_min_result = last;
if (comp(first, second))
max_result = second;
max_result = second;
else {
min_result = second;
potential_min_result = first;
min_result = second;
potential_min_result = first;
}
// then each element by pairs, with at most 3 comparisons per pair
first = ++second; if (first != last) ++second;
while (second != last) {
if (comp(first, second)) {
if (comp(first, min_result)) {
min_result = first;
potential_min_result = last;
}
if (comp(max_result, second))
max_result = second;
} else {
if (comp(second, min_result)) {
min_result = second;
potential_min_result = first;
}
if (comp(max_result, first))
max_result = first;
}
first = ++second;
if (first != last) ++second;
if (comp(first, second)) {
if (comp(first, min_result)) {
min_result = first;
potential_min_result = last;
}
if (comp(max_result, second))
max_result = second;
} else {
if (comp(second, min_result)) {
min_result = second;
potential_min_result = first;
}
if (comp(max_result, first))
max_result = first;
}
first = ++second;
if (first != last) ++second;
}
// if odd number of elements, treat last element
if (first != last) { // odd number of elements
if (comp(first, min_result))
min_result = first, potential_min_result = last;
else if (comp(max_result, first))
max_result = first;
if (comp(first, min_result))
min_result = first, potential_min_result = last;
else if (comp(max_result, first))
max_result = first;
}
// resolve min_result being incorrect with one extra comparison
// (in which case potential_min_result is necessarily the correct result)
if (potential_min_result != last
&& !comp(min_result, potential_min_result))
min_result = potential_min_result;
&& !comp(min_result, potential_min_result))
min_result = potential_min_result;
return std::make_pair(min_result,max_result);
}
@ -352,23 +352,23 @@ namespace boost {
while (second != last) {
if (!comp(second, first)) {
if (comp(first, min_result))
min_result = first;
min_result = first;
if (!comp(second, max_result))
max_result = second;
max_result = second;
} else {
if (comp(second, min_result))
min_result = second;
min_result = second;
if (!comp(first, max_result))
max_result = first;
max_result = first;
}
first = ++second; if (first != last) ++second;
}
if (first != last) {
if (comp(first, min_result))
min_result = first;
min_result = first;
else if (!comp(first, max_result))
max_result = first;
max_result = first;
}
return std::make_pair(min_result, max_result);
@ -448,15 +448,15 @@ namespace boost {
min_result = first;
if (!comp(second, max_result)) {
max_result = second;
potential_max_result = last;
}
potential_max_result = last;
}
} else {
if (!comp(min_result, second))
min_result = second;
if (!comp(first, max_result)) {
max_result = first;
potential_max_result = second;
}
potential_max_result = second;
}
}
first = ++second;
if (first != last) ++second;
@ -467,7 +467,7 @@ namespace boost {
min_result = first;
if (!comp(first, max_result)) {
max_result = first;
potential_max_result = last;
potential_max_result = last;
}
}

View File

@ -55,14 +55,14 @@ int repeats = 10;
for (int i=0; i<repeats; ++i) { cmd ; } \
std::cout << " " << std::setprecision(4) \
<< (double)n*repeats/t.elapsed()/1.0E6 \
<< "M items/sec " << cmdname << "\n"
<< "M items/sec " << cmdname << "\n"
#define CTIMER( n, cmd , cmdname, count, opt ) \
t.restart(); lc.reset(); \
for (int i=0; i<repeats; ++i) { cmd ; } \
std::cout << " " << std::setprecision(4) \
<< (double)n*repeats/t.elapsed()/1.0E6 \
<< "M items/sec " << cmdname \
<< "M items/sec " << cmdname \
<< " ("<< (count)/repeats << " vs " << opt << ")\n"
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),
"boost::max_element_if" << name << "");
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 << "");
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 << "");
#undef pred

View File

@ -176,7 +176,7 @@ void test_minmax(CIterator first, CIterator last, int n)
template <class Container, class Iterator, class Value>
void test_container(Iterator first, Iterator last, int n,
Container* dummy = 0
BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Value) )
BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Value) )
{
Container c(first, last);
test_minmax(c.begin(), c.end(), n);