-
Notifications
You must be signed in to change notification settings - Fork 1
/
ctree.cpp
39 lines (30 loc) · 897 Bytes
/
ctree.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
#include "ctree.h"
using namespace std;
template <class Object>
void CTree<Object>::search(Object data){
pRoot->Q.push(new Command<Object>('s',new Node<Object>(data)));
}
template <class Object>
void CTree<Object>::insert(Object data){
pRoot->Q.push(new Command<Object>('i',new Node<Object>(data)));
}
template <class Object>
void CTree<Object>::destroy(Object data){
pRoot->Q.push(new Command<Object>('d',new Node<Object>(data)));
}
template <class Object>
void CTree<Object>::stop(){
pRoot->Q.push(new Command<Object>('t',NULL));
}
template <class Object>
CTree<Object>::CTree(unsigned nodes){
if(!nodes)
return;
//create balanced CTree of Trees
pRoot = new Tree<Object>;//root of CTree
pRoot->maxNodes = nodes;
pRoot->threads = &threads;
nodes--;
//initialize boost thread
threads.push_back(new boost::thread( boost::bind(&Tree<Object>::run, &*pRoot) ));
}