TObjArray Remove.... Automatic Re Sorting ? [SOLVED]

Hi,
very recently I discovered that after Remove() of TObjArray, the Array is not shrinked automatically.
For Example, I have an Array filled with with 10 objects, their adresses are:
0x2a17bd0
0x2a58c50
0x2a2d990
0x2a21490
0x2a27810
0x2a44100
0x2a441e0
0x2a58f20
0x2a556d0
0x2a17e30

After I remove the first object, i get:
0
0x2a58c50
0x2a2d990
0x2a21490
0x2a27810
0x2a44100
0x2a441e0
0x2a58f20
0x2a556d0
0x2a17e30

Is that then a feature that the removed object stays a zero pointer instead of shrinking the array and putting the object from 2nd place to object from first place?

Thanks a lot,
Frank

Hi,

Yes, this intentional, for performance reason TObjArray give control to the user of when the gap are actually removed. The gap removal is done via a call to Compress() (and it allows you to call it only after your remove all the items you need to remove and pay the cost of compression only once).

Cheers,
Philippe.

Dear Philippe,
Compress() worked.
Problem solved.
Thanks a lot.