Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / General Programming / Link List Implementation (design query) Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
Effin Goose

July 30, 1999, 10:08 AM

Hi,

This is just a general question on your implementation of link lists. For example, do u use templates? Or do u simply give the data structure a next/prev pointer? Or do u code a more generic node structure that takes a void pointer... Anyhow, was just wondering...

Ryan

 
Jan Niestadt

July 30, 1999, 10:21 AM

Effin Goose wrote:
>>For example, do u use templates?

A list template can be very handy. I've written one, you can find it in the archive of part 7 of my scripting engine tutorials (stack.h). It can function as both a list (FIFO) and a stack (LIFO).

>>Or do u simply give the data structure a next/prev pointer?

That depends on how you need to traverse the list.. If you only need to go in one direction, just make a singly-linked list with next pointers, otherwise use a doubly-linked list (a little more bookkeeping is required, so that's slower). A circular list is also an option.

>>Or do u code a more generic node structure that takes a void pointer...

Using void pointers is the C alternative to templates :-)
A template has the advantage that you don't HAVE to store pointers, you can also store a vector in it if you like. Plus it's cleaner code, so bugs are easier to find.

 
This thread contains 2 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.