|
x->child[i + 1];
}
x->size--;
if ( x->size == 0 )
{
x = x->child[0];
BTreeDelete( x, k );
}
else
{
BTreeDelete( x->child[i - 1], k );
}
}
// merge with the right node x->child[i + 1]
else if ( i < x->size )
{
// update x->child[i]
x->child[i]->key[t - 1] = x->key[i];
for ( int j = t; j < 2 * t - 1; ++j )
{
x->child[i]->key[j] = x->child[i + 1]->key[j - t];
x->child[i]->child[j] = x->child[i + 1]->child[j - t];
}
x->child[i]->child[2 * t - 1] = x->child[i + 1]->child[t - 1];
x->child[i]->size = 2 * t - 1;
// delete x->child[i + 1]
delete x->child[i + 1];
// update x
for ( int j = i; j < x->size - 1; ++j )
{
x->key[j] = x->key[j + 1];
x->child[j + 1] = x->child[j + 2];
}
x->size--;
if ( x->size == 0 )
{
x = x->child[0];
BTreeDelete( x, k );
}
else
{
BTreeDelete( x->child[i - 1], k );
}
}
} // end if case 3
else
{
BTreeDelete( x->child[i], k );
}
//
}
}
|