http://stxxl.sourceforge.net
<daniel.feist@student.kit.edu>
http://www.boost.org/LICENSE_1_0.txt
#include <stxxl/deque>
#include <iostream>
int main()
{
typedef stxxl::deque<unsigned int> deque;
deque my_deque;
unsigned int random, p, x;
unsigned int smaller_left = 0;
unsigned int smaller_right = 0;
stxxl::random_number32 rand32;
stxxl::uint64 number_of_elements = 8 * 1024 * 1024;
for (stxxl::uint64 i = 0; i < number_of_elements; i++)
{
random = rand32();
my_deque.push_front(random);
}
stxxl::deque_iterator<deque> deque_iterator = my_deque.begin();
p = rand32() % number_of_elements;
x = my_deque[p];
for (stxxl::uint64 j = 0; j < p; j++)
{
if (*deque_iterator < x)
{
smaller_left += 1;
}
++deque_iterator;
}
++deque_iterator;
for (stxxl::uint64 k = p + 1; k < number_of_elements - 1; k++)
{
if (*deque_iterator < x)
{
smaller_right += 1;
}
++deque_iterator;
}
STXXL_MSG("smaller left: " << smaller_left << ", smaller right: " << smaller_right);
return 0;
}