Hey all,
How are all of you? I need you guys to help me out with a problem with my project that I am having. I am supposed to do a mock version of a linked list. I have three array of sixteen elements a class mylist like so...
Code:
class mylist {
public:
int front;
int back;
};
This is my header file that I am using:
Code:
#define MYNULL (-1)
// this is the memory for you to manage
#define MSIZE 16
static int prevlink[MSIZE];//prevlink has an array of 16 elements
static char content[MSIZE];//content has an array of 16 elements
static int nextlink[MSIZE];//nextlink has an array of 16 elements
For those of you familar with linked lists, please help me with the following:
I need to count what the size of the list is. This is what I have so far:
Code:
// count the size of the link
int mysize(mylist &list)
{
// go to list's front
int i = list.front;
// traverse the list by going to next link while nextlink != MYNULL
int count = 0;
//int *nextlink[i];
while(i != MYNULL){
// interate into next nextlink[i]
i = *nextlink[i];
// increment count;
count++;
}
return count;
}
Basically my code tells to look at the location at the top of the list and traverse the list by using the nextlink array until you reach a (-1), MYNULL in the array which will stop the count. Meanwhile, increment count and at the end return count. The error message that I am having deals with the Please help. Thank you.