Program of Binary tree:
Btree::Btree(int O) : itemsInContainer(0)
{
finishInit(O);
}
Btree::~Btree(void)
{
if( root != 0 )
delete root;
}
void Btree::flush( DeleteType dt )
{
int oldValue = ownsElements();
ownsElements( delObj(dt) );
if( root != 0 )
delete root;
itemsInContainer = 0;
root = 0;
ownsElements( oldValue );
}
int Btree::hasMember( Object& o ) const
{
if( !o.isSortable() )
ClassLib_error( __ENOTSORT );
if( root == 0 )
return 0;
else
{
Node* loc;
int idx;
return root->found(&(Sortable&)o, &loc, &idx) != NOOBJECT;
}
}