Re: Array optimization. How ?



- elements are 4 byte pointers
- array must have access by element index

If to use classic array, then when element is inserted, elements after insert position must be moved to make a hole for new element. And when element is deleted, then elements after delete position must be moved to remove the hole. That all becoming slow when array has Y x 100,000 of elements.

Your elements don't have some natural order (alphabetically or given by some priority field)? This would allow you to use a B-Tree (perfect to insert elements very fast, but based on an order, not on an index).


Another idea that comes to my mind is using a hash table (maybe based on an integer). Again there are some requirements for your elements.

Probably both solutions are not suitable to your problem, I just wanted to give some alternative data structures (I don't know how exactly your lements look like, and based on which decision you get the index when inserting them).

Jens
.