http://stxxl.sourceforge.net
<beckmann@cs.uni-frankfurt.de>
http://www.boost.org/LICENSE_1_0.txt
#define STXXL_VERBOSE_LEVEL 1
#include <stxxl/queue>
typedef stxxl::uint64 my_type;
int main(int argc, char ** argv)
{
if (argc < 2)
{
std::cout << "Usage: " << argv[0] << " [n in MiB]" << std::endl;
return -1;
}
stxxl::int64 mega = 1 << 20;
stxxl::int64 megabytes = atoi(argv[1]);
stxxl::int64 nelements = megabytes * mega / sizeof(my_type);
stxxl::int64 i;
my_type in = 0, out = 0;
stxxl::queue<my_type> q;
STXXL_MSG("op-sequence: ( push, pop, push ) * n");
for (i = 0; i < nelements; ++i)
{
if ((i % mega) == 0)
STXXL_MSG("Insert " << i);
q.push(in++);
assert(q.front() == out);
q.pop();
++out;
q.push(in++);
}
STXXL_MSG("op-sequence: ( pop, push, pop ) * n");
for ( ; i > 0; --i)
{
if ((i % mega) == 0)
STXXL_MSG("Remove " << i);
assert(q.front() == out);
q.pop();
++out;
q.push(in++);
assert(q.front() == out);
q.pop();
++out;
}
assert(q.empty());
assert(in == out);
std::cout << *stxxl::stats::get_instance();
}