This is in the acommon.inc:
Quotestruct _linked_list
{
_linked_list *pNext;
_linked_list *pPrev;
pointer pData;
}
I don't understand that.
Larry
Its basicly a structure used for the location of the data used in linked lists. It stores the next and previous locations in memory of the data. And pData stores the actual data.
Lewis
What it looks like to me though is:
it's a struct whose 1st two elements are of a type struct(the same one) who's 1st two elements are of a type struct(the same one) who's 1st two ........ad infinitem(sp)
like
struct s1
{
s2 item1;
int item2;
}
struct s2
{
s3 item3;
int item4;
struct s3
........
but with struct _linked_list s1,s2,s3 are all the same structure
it looks like you're using a structure inside of it self which would make it nested to infinity.
Larry
But those two elements are pointers. You're right, if it said _linked_list prev; it would be nested to infinity, and the compiler would probably report an error - either that or go into an infinite loop.
A typed pointer can be confusing at first, it was when I first learned C. But a pointer to anything is just an address, and the type just tells the compiler that you don't have to explicitly cast when you dereference it.
That's the power of a linked list, the nesting for however many levels you need. For example, if you had a large list, this is completely fine to write:
void *pData = pList->pNext->pNext->pNext->pNext->pNext->pNext->pNext->pData;
The '*' denotes a pointer to a type.
int *p;
is a pointer to an integer.