Hi everyone I am sending to you my piece of code. I think to answer my question this code is enough so I didn't send all of code. In switch case I can see T1,T2 using with double ! what does that mean?
BinQueue
Merge( BinQueue H1, BinQueue H2 )
{
BinTree T1, T2, Carry = NULL;
int i, j;
if( H1->CurrentSize + H2->CurrentSize > Capacity )
Error( "Merge would exceed capacity" );
H1->CurrentSize += H2->CurrentSize;
for( i = 0, j = 1; j <= H1->CurrentSize; i++, j *= 2 )
{
T1 = H1->TheTrees[ i ]; T2 = H2->TheTrees[ i ];
switch( !!T1 + 2 * !!T2 + 4 * !!Carry )//what does mean??
{
case 0: /* No trees */
case 1: /* Only H1 */
break;
case 2: /* Only H2 */
H1->TheTrees[ i ] = T2;
H2->TheTrees[ i ] = NULL;
break;
case 4: /* Only Carry */
H1->TheTrees[ i ] = Carry;
Carry = NULL;
break;
case 3: /* H1 and H2 */
Carry = CombineTrees( T1, T2 );
H1->TheTrees[ i ] = H2->TheTrees[ i ] = NULL;
break;
case 5: /* H1 and Carry */
Carry = CombineTrees( T1, Carry );
H1->TheTrees[ i ] = NULL;
break;
case 6: /* H2 and Carry */
Carry = CombineTrees( T2, Carry );
H2->TheTrees[ i ] = NULL;
break;
case 7: /* All three */
H1->TheTrees[ i ] = Carry;
Carry = CombineTrees( T1, T2 );
H2->TheTrees[ i ] = NULL;
break;
}
}
return H1;
}