Re: Array optimization. How ?
- From: Jens Gruschel <nospam@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 07 Jul 2005 11:35:31 +0200
- 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 .
- Follow-Ups:
- Re: Array optimization. How ?
- From: Dmitry Arefiev [gs-soft.ru]
- Re: Array optimization. How ?
- References:
- Array optimization. How ?
- From: Dmitry Arefiev [gs-soft.ru]
- Array optimization. How ?
- Prev by Date: Re: Array optimization. How ?
- Next by Date: Re: Array optimization. How ?
- Previous by thread: Re: Array optimization. How ?
- Next by thread: Re: Array optimization. How ?
- Index(es):
Relevant Pages
|