<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi !<br>
<p>Reverse iterators are well known (?) and work perfectly :<br>
</p>
<p>------------------------------------------------------------------<br>
Reverse iterators are bidirectional iterators that invert the meaning
of
operators +, -, ++ and --. Thus, incrementing a reverse iterator moves
it one
position <i>backwards</i>, whereas decrementing it causes it to move
to the
<i>next</i> element. The <tt>rbegin()</tt> and <tt>rend()</tt> member
functions
return reverse iterators:</p>
<pre>void print_backwards(vector<int> &vi)
{
vector<int>::reverse_iterator rit=vi.rbegin();
while (rit<vi.rend())
{
cout<<*rit<<endl;
++rit; //move one position backwards
}
}
-----------------------------------------------
</pre>
==> My question :<br>
How can we use them (or anything else) to *reverse* std::sort a
std::vector (or any std::sortable object) ?<br>
<br>
What I wouldn't like to write is something like the following stuff :<br>
<br>
if (DirectOrder) <br>
std::sort(fileList->begin(), fileList->end(),
userSuppliedLessThanFunction);<br>
else<br>
std::sort(fileList->begin(), fileList->end(),
userSuppliedGreaterThanFunction);<br>
<br>
Thx<br>
<br>
JPRx<br>
</body>
</html>