Im finally working on my first commercial product for the ppc. Im writing PocketPad a note pad replacement that will blow pockentoepad away im going to put some really good features in that i think pocket notepad should have but is missing, im probably only gonna sell it fo 10 dollars or something cheap. My question is what are linked lists usefull for? I dont know if i need to use them or not for anything but can someone tell me what there commonly used for or could be used for. And what there advantages and disadvantages are as far as speed and such.
Basically it's what is says it is. It's a set of objects/structures which are linked together to form a chain.
You store:
a pointer to the first object
Then:
each object points to the next object in the chain
And:
the last object's pointer is NULL.
The advantage is that you can create/delete your structures and tag them onto/take them off of the linked list relatively easily. You don't have to pre-declare how much memory you're going to need (like an array), because you can add items as you wish.
A doubly-linked list allows you to move forwards AND backwards along the chain of objects.
Properties:
the list is easy to traverse.
inserting into a (unsorted) list has a constant penalty O(1)
deleting an item is O(N)
Get yourself a book on "algorithms".
Linked lists aren't the way to go on a processor like a StrongARM if you *really* want flat-out speed (because while you're traversing the list the processor fills a cache line with stuff you're not going to use)...
Cheers,
Refractor.