99 QTreeNB(PType *xp,IndexType *particles,IndexType nparticles
100 ,PosType boundary_p1[],PosType boundary_p2[]);
103 const bool isEmpty();
105 const bool noChild();
107 const unsigned long getNbranches();
109 return (branch->child0 == NULL)*(branch->child1 == NULL)
110 *(branch->child2 == NULL)*(branch->child3 == NULL);
114 void getCurrent(IndexType *particles,IndexType *nparticles);
117 void moveToChild(
int child);
118 bool WalkStep(
bool allowDescent);
131 unsigned long Nbranches;
132 void _freeQTree(
short child);
139template<
typename PType>
141 ,PosType boundary_p1[],PosType boundary_p2[]): xxp(xp) {
150 top->boxsize2 = (boundary_p2[0]-boundary_p1[0])*(boundary_p2[0]-boundary_p1[0]);
152 top->nparticles = nparticles;
156 top->
center[0] = (boundary_p1[0] + boundary_p2[0])/2;
157 top->
center[1] = (boundary_p1[1] + boundary_p2[1])/2;
172template<
typename PType>
189 void movetop(){current = top;}
199 bool down(
short child);
201 return (current->child0 == NULL)*(current->child1 == NULL)
202 *(current->child2 == NULL)*(current->child3 == NULL);
204 bool TreeWalkStep(
bool allowDescent);
206 size_t getNbranches(){
return nbranches;}
212template<
typename PType>
220 assert(Nbranches ==0);
224template<
typename PType>
227 if(Nbranches <= 1)
return 1;
231 assert(Nbranches == 1);
236template<
typename PType>
244 if(current->child0 != NULL){
249 if(current->child1 != NULL){
254 if(current->child2 != NULL){
259 if(current->child3 != NULL){
264 if( atLeaf(current) ){
276 if(child==0) current->child0 = NULL;
277 if(child==1) current->child1 = NULL;
278 if(child==2) current->child2 = NULL;
279 if(child==3) current->child3 = NULL;
292template<
typename PType>
295 return(Nbranches == 0);
304template<
typename PType>
309 std::cerr <<
"QTreeNB Error: calling atTop() on empty tree" << std::endl;
312 return(current == top);
319template<
typename PType>
322 return(current == NULL);
330template<
typename PType>
335 std::cerr <<
"QTreeNB Error: calling getCurrent() when current is off end" << std::endl;
339 *nparticles = current->nparticles;
349template<
typename PType>
362template<
typename PType>
370 std::cerr <<
"QTreeNB Error: calling moveTop() on empty tree" << std::endl;
385template<
typename PType>
390 std::cerr <<
"QTreeNB Error: call to moveUp() when current is off end" << std::endl;
393 if( current == top ){
395 std::cerr <<
"QTreeNB Error: call to moveUp() tried to move off the top" << std::endl;
399 current = current->
prev;
409template<
typename PType>
413 ERROR_MESSAGE(); std::cout <<
"QTreeNB Error: calling moveChildren() when current is off end" << std::endl;
417 if( current->child0 == NULL ){
418 ERROR_MESSAGE(); std::cout <<
"QTreeNB Error: moveToChild() typing to move to child1 when it doesn't exist" << std::endl;
421 current = current->child0;
424 if( current->child1 == NULL ){
425 ERROR_MESSAGE(); std::cout <<
"QTreeNB Error: moveToChild() typing to move to child1 when it doesn't exist" << std::endl;
428 current = current->child1;
431 if( current->child2 == NULL ){
432 ERROR_MESSAGE(); std::cout <<
"QTreeNB Error: moveToChild() typing to move to child2 when it doesn't exist" << std::endl;
435 current = current->child2;
438 if( current->child3 == NULL ){
439 ERROR_MESSAGE(); std::cout <<
"QTreeNB Error: moveToChild() typing to move to child2 when it doesn't exist" << std::endl;
442 current = current->child3;
447template<
typename PType>
452 current->child0 = branch0;
453 current->child1 = branch1;
454 current->child2 = branch2;
455 current->child3 = branch3;
457 int level = current->
level+1;
458 branch0->
level = level;
459 branch1->
level = level;
460 branch2->
level = level;
461 branch3->
level = level;
469 branch0->
prev = current;
470 branch1->
prev = current;
471 branch2->
prev = current;
472 branch3->
prev = current;
478template<
typename PType>
480 if(allowDescent && current->child0 != NULL){
492template<
typename PType>
494 if( current == top ){
497 current = current->
prev;
502template<
typename PType>
506 if( current->child0 == NULL ){
507 ERROR_MESSAGE(); std::cout <<
"QTreeNB Error: moveToChild() typing to move to child1 when it doesn't exist" << std::endl;
510 current = current->child0;
514 if( current->child1 == NULL ){
515 ERROR_MESSAGE(); std::cout <<
"QTreeNB Error: moveToChild() typing to move to child1 when it doesn't exist" << std::endl;
518 current = current->child1;
522 if( current->child2 == NULL ){
523 ERROR_MESSAGE(); std::cout <<
"QTreeNB Error: moveToChild() typing to move to child2 when it doesn't exist" << std::endl;
526 current = current->child2;
530 if( current->child3 == NULL ){
531 ERROR_MESSAGE(); std::cout <<
"QTreeNB Error: moveToChild() typing to move to child2 when it doesn't exist" << std::endl;
534 current = current->child3;
540template<
typename PType>
542 if(allowDescent && current->child0 != NULL){