aboutsummaryrefslogtreecommitdiffstats
path: root/_test/meowpp.cpp
blob: ae89e73e3e3bfc8386ba4941472ebda51a4a727f (plain) (blame)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "dsa/KD_Tree.h"
#include "dsa/SplayTree.h"
#include "dsa/DisjointSet.h"
#include "dsa/Heaps.h"
#include "Usage.h"

#include <cstdio>
#include <vector>

int main(){
  meow::Usage usg("hi!");
  printf("==%s==\n", usg.getUsage().c_str());
  meow::DisjointSet dsj(10);
  for(int i = 0; i < 10; i++) printf("%2d ", (int)dsj.root(i));
  dsj.merge(1, 2);
  dsj.merge(1, 2);
  dsj.merge(1, 3);
  dsj.merge(2, 3);
  dsj.merge(1, 5);
  printf("\n");
  for(int i = 0; i < 10; i++) printf("%2d ", (int)dsj.root(i));
  printf("\n");
  dsj.reset(7);
  meow::MergeableHeap<double> hp;
  hp.push(5.7);
  hp.push(5.3);
  hp.push(5.2);//
  hp.push(5.1);//
  meow::MergeableHeap<double> hp2;
  hp2.push(6.7);
  hp2.push(4.3);
  hp2.push(2.2);
  hp2.push(8.1);//
  hp.pop();
  hp2.pop();
  hp.pop();
  hp.merge(&hp2);
  while(!hp.empty()){
    printf("==%f==\n", hp.top());
    hp.pop();
  }
  meow::KD_Tree<std::vector<double>, double, double> kd(3);
  std::vector<double> v(3); double k;
  v[0] = 0; v[1] = 0; v[2] = 0; k = 0.0; kd.insert(v, k);
  v[0] = 2; v[1] = 0; v[2] = 0; k = 0.1; kd.insert(v, k);
  v[0] = 0; v[1] = 2; v[2] = 0; k = 0.2; kd.insert(v, k);
  v[0] = 0; v[1] = 0; v[2] = 2; k = 0.3; kd.insert(v, k);
  v[0] = 2; v[1] = 2; v[2] = 0; k = 0.4; kd.insert(v, k);
  v[0] = 2; v[1] = 0; v[2] = 2; k = 0.5; kd.insert(v, k);
  v[0] = 0; v[1] = 2; v[2] = 2; k = 0.6; kd.insert(v, k);
  v[0] = 2; v[1] = 2; v[2] = 2; k = 0.7; kd.insert(v, k);
  v[0] = 0.1; v[1] = 0.9; v[2] = 0.1; k = kd.query(v, 1); printf("//%f//\n", k);
  v[0] = 0.1; v[1] = 1.9; v[2] = 0.1; k = kd.query(v, 1); printf("//%f//\n", k);
  v[0] = 1.1; v[1] = 1.9; v[2] = 1.1; k = kd.query(v, 1); printf("//%f//\n", k);
  v[0] = 0.1; v[1] = 1.9; v[2] = 3.1; k = kd.query(v, 1); printf("//%f//\n", k);
  v[0] = 0.1; v[1] = -51.9; v[2] = 10.1; k = kd.query(v, 1); printf("//%f//\n", k);
  
  return 0;
}