About func in lists.c

Martin Mares mj at ucw.cz
Sat Jan 13 22:22:33 CET 2001


Hi!

> isnt that we should change n->prev = (node *) &l->head to n->prev = (node
> *) &l->null

No.  I admit the list structure is very tricky and also somewhat awkward,
but it's both efficient and easy to manipulate once one understand the
basic trick: The list head always contains two synthetic nodes which are
always present in the list: the head and the tail. But because the `next'
entry of the tail and the `prev' entry of the head are both NULL, the
nodes can be overlayed over each other:

	head	head_node.next
	null	head_node.prev	tail_node.next
	tail			tail_node.prev

				Have a nice fortnight
-- 
Martin `MJ' Mares   <mj at ucw.cz>   http://atrey.karlin.mff.cuni.cz/~mj/
Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth
And God said: E = 1/2mv^2 - Ze^2/r ...and there *WAS* light!



More information about the Bird-users mailing list