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
.



Relevant Pages

  • Re: I hate French knots!!!!! GRRRRRRR!
    ... Also, when inserting the needle into the fabric, make sure you are not ... inserting it back into same the hole that your thread is coming out of. ... do French Knots. ...
    (rec.crafts.textiles.needlework)
  • Re: Array optimization. How ?
    ... > If to use classic array, then when element is inserted, elements ... > delete position must be moved to remove the hole. ... Pierre ... Prev by Date: ...
    (borland.public.delphi.language.basm)
  • Re: Leakproofing Spa thermostat entrance
    ... I will install just that. ... It has a hole for inserting the thermostat's bulb, ...
    (alt.home.repair)
  • Leakproofing Spa thermostat entrance
    ... I have a very old spa that likes to give me headaches. ... It has a hole for inserting the thermostat's bulb, ...
    (alt.home.repair)