Re: Recursive structure?



"dspfun" <dspfun@xxxxxxxxxxx> writes:
Morris Dovey wrote:
[...]
It's not unusual to see something like:

node *head; /* Pointer to first element */
node *tail; /* Pointer to final element */

or even:

struct
{ node *head;
node *tail;
} mylist;

to provide a "root" for a list.

I'm probably missing something here because I don't see what the
purpose of such a list would be, all it is is a list of node pointers,
isn't it? What is the use of such a list? Wouldn't one like to have
some data at each entry of a list?

Yes, absolutely. A linked list with no actual data isn't much use,
except as a demonstration.

Possibly Morris thought that adding an extra "payload" member would
distract from the main point.

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.



Relevant Pages

  • Re: Lockfree queue, one producer many consumers...
    ... AFAICT it seems like your always going to have a "ping-pong" between the producer and consumers because the producer needs to read both the head and tail. ... What am I missing here? ...
    (comp.programming.threads)
  • Re: Python Doc Problem Example: os.path.split
    ... I was working on a program where i needed to split a path into dirname, ... > Split the pathname path into a pair, (head, tail) where tail is the ... > last pathname component and head is everything leading up to that. ... > tail part will never contain a slash; if path ends in a slash, ...
    (comp.unix.programmer)
  • Re: Using a link list over an array.
    ... compile (p->data is a void *) so you have not shown us some key ... int cmp ... head = list_sort; ... list_type *tail; ...
    (comp.lang.c)
  • HELP for doubly linked list
    ... forward and one pointing backwards. ... You must be able to insert a new node at the head of the ... You must be able to insert a new node at the tail of the ... tail, F – display contents forward, B – display contents backwards, ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Linked List
    ... pete wrote: ... int main ... head = tail = NULL; ... head = list_sort; ...
    (comp.lang.c)