-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest1.cpp
46 lines (37 loc) · 1.28 KB
/
test1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/***************************************************************************
* test1.cpp
*
* Part of a simple STXXL example. See http://stxxl.sourceforge.net
*
* Copyright (C) 2013 Timo Bingmann <[email protected]>
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
**************************************************************************/
#include <iostream>
#include <limits>
#include <stxxl/vector>
#include <stxxl/random>
#include <stxxl/sort>
struct my_less_int : std::less<int>
{
int min_value() const { return std::numeric_limits<int>::min(); };
int max_value() const { return std::numeric_limits<int>::max(); };
};
int main()
{
// create vector
stxxl::VECTOR_GENERATOR<int>::result vector;
// fill vector with random integers
stxxl::random_number32 random;
for (size_t i = 0; i < 100*1024*1024; ++i) {
vector.push_back(random());
}
// sort vector using 16 MiB RAM
stxxl::sort(vector.begin(), vector.end(), my_less_int(), 16*1024*1024);
// output first and last items:
std::cout << vector.size() << " items sorted ranging from "
<< vector.front() << " to " << vector.back() << std::endl;
return 0;
}