This example code is explained in the STXXL Sorter section.
#include <limits>
struct TwoInteger
{
int i, j;
TwoInteger()
{ }
TwoInteger(int _i, int _j)
: i(_i), j(_j)
{ }
};
struct TwoIntegerComparator
{
bool operator () (const TwoInteger& a, const TwoInteger& b) const
{
return a.i < b.i;
}
TwoInteger min_value() const
{
}
TwoInteger max_value() const
{
}
};
int main()
{
sorter_type int_sorter(TwoIntegerComparator(), 64 * 1024 * 1024);
for (size_t i = 0; i < 1000; ++i)
{
int_sorter.push(TwoInteger(rand32() % 100000, (int)i));
}
int_sorter.sort();
while (!int_sorter.empty())
{
std::cout << int_sorter->i << " ";
++int_sorter;
}
return 0;
}