Peter Bancroft wrote: > > Pau Bruneau commented on Peter Bancrofts comments... > > >> You could implement this as an array. > >> With some of the array elements being the address of the links. > >> > >This seems to me to be a bad suggestion. The beauty of the linked list is that > >you don't have to worry about free records, remaining space (you have the > >whole heap basically at your disposal), and other administration. > > > >Maybe I'm missing something, but I'd sooner die than code a linked list using > >anything but handles. > > It's easy to prototype a linked list in an array so that a beginner could > get the hang of how it all works. For a beginner this _may_ be fast enough. > It certainly was for me when I wrote an assembler for the 8048 series of > microprocessors. It didn't matter to me if it took 5 seconds or 2 minutes > to run. > > What are the advantages of handles in linked lists, apart from saving your > life? 8) The advantage is you don't have to worry about your array running out of space, because there is no array. You don't have to worry about how big to make your array, thereby limiting the size of your list, again, because there is no array. You don't have to worry about wasting memory, because no matter how big or small the list is, it always takes up exactly (number of elements) * (size of element) bytes. I agree that speed is not a concern either way in 99% of the cases. In fact, your method may be faster because you can jump directly to an element. But for me, the nature of a linked list is such that I only use it for the type of applications that wouldn't benefit much from that capability. Perhaps to open my eyes a little, Peter, tell me what you would do when your list gets full and you have to add another element to it. Thanks, PB