Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Rob Loach

Linked List VS Controlled Array

This topic is 5829 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What''s the difference between using a Linked List, and a controlled array? I''m using this to make sprites. Right now I am using a controlled dynamic array to support enemies on the screen and am exploring other options. I just don''t know why you would use a linked list if you could just use a controlled dynamic array.... Any ideas? Thanks alot, - Rob Loach OverTech Technologies ----------- "Life moves pretty fast. If you don''t stop and look around once in awhile, you could miss it." - Ferris Bueller

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
I use a simple linked list for objects that don''t need to be referenced by index. All you can do is traverse it form begin to end and get the object it points to. Very fast and only a couple lines of code.

Share this post


Link to post
Share on other sites
Linked lists have certain advantages over arrays. Increasing the size of an array is a slow operation, and to insert an element in a random position of an array requires you to shuffle, on average, n/2 data. With linked lists, both of these operations are trivial.

Of course, arrays have advantages over linked lists, as well: Random access springs to mind, and in certain situations, dynamic memory allocation may be too slow to be appropriate, and it is better to use a preallocated array (which, of course, requires you to know ahead of time how large it has to be).

(I hope my answer is pertinent to your question; I''m not entirely sure what you mean by ''controlled array''.)

Share this post


Link to post
Share on other sites
I think in terms of an game, you would want to use a controlled array inside of a wrapper class. For games, there is virtually no reason why the objects would need to be in a particular order. You only need to be able to reference an object by a handle, which can be assigned at run-type (couldn''t spell dynamically)

As a point of curiosity, does anyone know how the class works in terms of speed? Would it be practical to use it for a game? I''m currently using it for a console game, but a more intensive one might bog down too much...

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!