Where did this 'specialized' idea of a head pointer come from? that's not how it's normally done.
Maybe you're confusing two separate issues-- linked lists and circular queues. 'Head' pointers aren't the same as 'root' node pointers, in conversation.
Both can have head and tail pointers, but usually it's implemented like this:
Code:
For a circular queue:
typedef struct
{
long data;
long moreData;
. . .
}node,*nodeP;
node queue[10];
nodeP headPtr;
nodeP tailPtr;
/* Create 10 nodes as an array */
headPtr = &queue[0]; /* init head */
tailPtr = &queue[0]; /* init tail */
/* as data is added to the queue, the
* head pointer is incremented to the
* next element. If the head pointer
* pointer ever == the tail (swallows
* the tail), the queue is overrun/full
* The idea is that something else is
* following along, pulling data out of
* the tailptr and incrementing it so
* it tries to catch up (or run at the
* same rate) with the headptr. If
* the tail catches up to the head
* pointer, the queue is empty.
*/
And for a linked list, like this:
Code:
typedef struct nodeStruc
{
struct nodeStruc *next;
long data;
long moreData;
. . .
}node,*nodeP;
nodeP nodeListP[10];
/* allocate 10 (or however many needed) nodes
* and link them together (or created and link them
* as needed
*/
nodeP headPtr;
headPtr = nodeListP[0];
I mean, in terms of 'head pointers', usually that mechanism is used only when working with an array or an array of structures.
I hope this was not too far off what you were looking for.