forked from cmuparlay/parlaylib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oct_tree.cpp
45 lines (39 loc) · 1.1 KB
/
oct_tree.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
#include <iostream>
#include <string>
#include <random>
#include "parlay/primitives.h"
#include "parlay/random.h"
#include "oct_tree.h"
// **************************************************************
// Driver
// **************************************************************
int main(int argc, char* argv[]) {
auto usage = "Usage: oct_tree <n>";
if (argc != 2) std::cout << usage << std::endl;
else {
long n;
int k = 10;
try { n = std::stol(argv[1]); }
catch (...) { std::cout << usage << std::endl; return 1; }
parlay::random_generator gen(0);
std::uniform_int_distribution<coord> dis(0,1000000000);
// generate n random points in a unit square
auto points = parlay::tabulate(n, [&] (long i) {
auto r = gen[i];
coords pnt;
for (coord& c : pnt) c = dis(r);
return pnt;
});
node* r;
long size;
parlay::internal::timer t("Time");
for (int i=0; i < 5; i++) {
t.start();
r = z_tree(points);
size = r->size;
t.next("oct_tree");
delete_tree(r);
}
std::cout << "tree size: " << size << std::endl;
}
}