Your above code would fail to delete all the columns, half would always remain:
Say you had 3 columns
Columns 0, 1 and 2
you delete column 0, you now have columns 0, 1 as the remaining columns get promoted.
you delete column 1, you now have column 0 only
you attempt to delete column 2, but the call fails as there in no column 2
for(int i = 0; i < headCount; i++)