mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-24 21:10:33 +05:00
searchtree with BlockAllocator (again)
This commit is contained in:
parent
fae350929c
commit
f008de5b04
@ -404,43 +404,23 @@ public:
|
|||||||
nchilds = 0;
|
nchilds = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeleteChilds ()
|
void DeleteChilds (BlockAllocator & ball)
|
||||||
{
|
{
|
||||||
if (left)
|
if (left)
|
||||||
{
|
{
|
||||||
left->DeleteChilds();
|
left->DeleteChilds(ball);
|
||||||
delete left;
|
ball.Free(left);
|
||||||
left = NULL;
|
left = NULL;
|
||||||
}
|
}
|
||||||
if (right)
|
if (right)
|
||||||
{
|
{
|
||||||
right->DeleteChilds();
|
right->DeleteChilds(ball);
|
||||||
delete right;
|
ball.Free(right);
|
||||||
right = NULL;
|
right = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// friend class T_ADTree<DIM>;
|
|
||||||
|
|
||||||
/*
|
|
||||||
// slow without blockallocator !!!!!
|
|
||||||
|
|
||||||
static BlockAllocator ball;
|
|
||||||
void * operator new(size_t)
|
|
||||||
{
|
|
||||||
return ball.Alloc();
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator delete (void * p)
|
|
||||||
{
|
|
||||||
ball.Free(p);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// template <int DIM, typename T>
|
|
||||||
// BlockAllocator T_ADTreeNode<DIM,T> :: ball(sizeof (T_ADTreeNode<DIM,T>));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <int dim, typename T = INDEX>
|
template <int dim, typename T = INDEX>
|
||||||
@ -451,20 +431,22 @@ public:
|
|||||||
Point<dim> cmin, cmax;
|
Point<dim> cmin, cmax;
|
||||||
// NgArray<T_ADTreeNode<dim>*> ela;
|
// NgArray<T_ADTreeNode<dim>*> ela;
|
||||||
ClosedHashTable<T, T_ADTreeNode<dim,T>*> ela;
|
ClosedHashTable<T, T_ADTreeNode<dim,T>*> ela;
|
||||||
|
|
||||||
|
BlockAllocator ball{sizeof(T_ADTreeNode<dim,T>)};
|
||||||
public:
|
public:
|
||||||
T_ADTree (Point<dim> acmin, Point<dim> acmax)
|
T_ADTree (Point<dim> acmin, Point<dim> acmax)
|
||||||
{
|
{
|
||||||
cmin = acmin;
|
cmin = acmin;
|
||||||
cmax = acmax;
|
cmax = acmax;
|
||||||
|
|
||||||
root = new T_ADTreeNode<dim,T>;
|
root = new (ball.Alloc()) T_ADTreeNode<dim,T>;
|
||||||
root->sep = (cmin[0] + cmax[0]) / 2;
|
root->sep = (cmin[0] + cmax[0]) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
~T_ADTree ()
|
~T_ADTree ()
|
||||||
{
|
{
|
||||||
root->DeleteChilds();
|
root->DeleteChilds(ball);
|
||||||
delete root;
|
ball.Free(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Insert (Point<dim> p, T pi)
|
void Insert (Point<dim> p, T pi)
|
||||||
@ -514,8 +496,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
next = new T_ADTreeNode<dim,T>;
|
next = new (ball.Alloc()) T_ADTreeNode<dim,T>;
|
||||||
// memcpy (next->data, p, dim * sizeof(float));
|
|
||||||
next->data = p;
|
next->data = p;
|
||||||
next->pi = pi;
|
next->pi = pi;
|
||||||
next->sep = (bmin[dir] + bmax[dir]) / 2;
|
next->sep = (bmin[dir] + bmax[dir]) / 2;
|
||||||
|
Loading…
Reference in New Issue
Block a user