Linked List Vs Array

BlitzMax Forums/BlitzMax Programming/Linked List Vs Array

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Are arrays really slow to resize? Is it easier to delete things out of the middle or a linked list?
Yes and Yes. Resizing or compressing an Array (removing "empty" elements) takes linear time, Link lists are compressed and resized automatically, in constant time. Deleting would be the same speed, if you can live with "Null" elements in your array. If you have to compress the array afterwards, a list is your best bet.

Arrays are good for random access and good for sequential access (both are in constant time). Linked lists on the other hand are constant for sequential, but linear for random access.

The choice of which datastructure to use, depends entirely on the problem you're trying to solve.