Things to avoid?

Started by
2 comments, last by frizb 24 years, 6 months ago
There is no concrete answer to that becos it all depends on the particular problem you are dealing with. If you're dealing with data that needs to be sorted/inserted/deleted on the fly, then linked list would be the way to go. But for simple lists of items, go with simple arrays.
Advertisement
You want to look at what your situation is

If you are going to be iterating through the entire list in one go, and order is unimportant, then a linked list can be much faster, however, if you are accessing the data in no particular order, the it might be faster to use an array.

------------------
LoungePig
OpenGUI


In one of the game programming books I have been reading, they mention that you should avoid using linked lists. Is this info wrong or no longer applicable like using floats, or should I avoid them? If so, what are my alternatives?
Still Learning...
It also depends on the size of the data to be placed in the array/LL.
Remember there is an overhead of at least one pointer (if not two) of 4 bytes and the time it takes to malloc memory every time a new element is added.
Basically they are slower to create, more prone to memory leaks due to bad programming and more of a hassle to maintain.
But if you don't know the size of the data to be stored then linked lists are the way to go.
I use them all the time, you just have to get used to them and create some library's.

This topic is closed to new replies.

Advertisement