struct my_type
{
typedef unsigned key_type;
key_type m_key;
char m_data[128 - sizeof(key_type)];
key_type key() const
{
return m_key;
}
my_type() { }
my_type(key_type k) : m_key(k) { }
static my_type min_value()
{
}
static my_type max_value()
{
}
};
inline bool operator < (
const my_type& a,
const my_type& b)
{
return a.key() < b.key();
}
inline bool operator == (
const my_type& a,
const my_type& b)
{
return a.key() == b.key();
}
struct Cmp
{
typedef my_type first_argument_type;
typedef my_type second_argument_type;
typedef bool result_type;
bool operator () (const my_type& a, const my_type& b) const
{
return a < b;
}
static my_type min_value()
{
return my_type::min_value();
}
static my_type max_value()
{
return my_type::max_value();
}
};
std::ostream&
operator << (std::ostream& o,
const my_type& obj)
{
o << obj.key();
return o;
}
int main(int argc, char** argv)
{
if (argc < 3)
{
std::cout << "Usage: " << argv[0] << " action file" << std::endl;
std::cout << " where action is one of generate, sort, ksort, stable_sort, stable_ksort" << std::endl;
return -1;
}
if (strcmp(argv[1], "generate") == 0) {
const my_type::key_type num_elements = 1 * 1024 * 1024;
my_type* array = (my_type*)stxxl::aligned_alloc<STXXL_BLOCK_ALIGN>(block_size);
memset(array, 0, block_size);
my_type::key_type cur_key = num_elements;
for (unsigned i = 0; i < num_elements / records_in_block; i++)
{
for (unsigned j = 0; j < records_in_block; j++)
array[j].m_key = cur_key--;
}
stxxl::aligned_dealloc<STXXL_BLOCK_ALIGN>(array);
}
else {
#if STXXL_PARALLEL_MULTIWAY_MERGE
#endif
unsigned memory_to_use = 50 * 1024 * 1024;
vector_type v(&f);
if (strcmp(argv[1], "sort") == 0) {
#if 0 // stable_sort is not yet implemented
}
else if (strcmp(argv[1], "stable_sort") == 0) {
stxxl::stable_sort(v.begin(), v.end(), memory_to_use);
#endif
}
else if (strcmp(argv[1], "ksort") == 0) {
}
else if (strcmp(argv[1], "stable_ksort") == 0) {
}
else {
}
}
return 0;
}