- #1
John O' Meara
- 330
- 0
Can someone explain how the function queue::store(int i) (see attachment) works for a sequence of calls to it. Or give a reference to something or give a diagram, please.
Doesn't each instant (i.e., each memory location) have its own head, tail and next pointers as well as as the data member, num? A queue made from an array has only two indices; say called head and tail, and are much easier to understand.
After the first call to the store() function, say address 0x8000 is allocated, then the pointers are pointing as indicated on the attachment, yes/no?
On the 2nd call to store(), we have: "if(tail) tail->next = item;". Which tail is it- 0x8000 or 0x8020's? And then we have: "tail->next = item;". Why not say next = item; Is it the 'next' of the instant 0x8000 or 0x8020? confused. Please help, thanks in advance for your time.
Doesn't each instant (i.e., each memory location) have its own head, tail and next pointers as well as as the data member, num? A queue made from an array has only two indices; say called head and tail, and are much easier to understand.
After the first call to the store() function, say address 0x8000 is allocated, then the pointers are pointing as indicated on the attachment, yes/no?
On the 2nd call to store(), we have: "if(tail) tail->next = item;". Which tail is it- 0x8000 or 0x8020's? And then we have: "tail->next = item;". Why not say next = item; Is it the 'next' of the instant 0x8000 or 0x8020? confused. Please help, thanks in advance for your time.