Linked Lists imitation

This is a discussion on Linked Lists imitation within the C++ Programming forums, part of the General Programming Boards category; Hey all, How are all of you? I need you guys to help me out with a problem with my ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    92

    Linked Lists imitation

    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
    Code:
    i = *nexlink[i];
    Please help. Thank you.

  2. #2
    Registered User
    Join Date
    Sep 2002
    Posts
    92

    Never mind

    Thanks guys but I got it... I just had to remove the pointer sign... where is my mind today?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Singly Linked Lists: Clarification Needed
    By jedispy in forum C++ Programming
    Replies: 4
    Last Post: 12-14-2006, 05:30 PM
  2. Linked Lists 101
    By The Brain in forum C++ Programming
    Replies: 5
    Last Post: 07-24-2004, 05:32 PM
  3. Map file formats and linked lists
    By Spitball in forum Game Programming
    Replies: 2
    Last Post: 03-04-2004, 11:32 PM
  4. need help w/ linked lists
    By MKashlev in forum C++ Programming
    Replies: 11
    Last Post: 08-05-2002, 09:57 PM
  5. doubly linked lists
    By qwertiop in forum C++ Programming
    Replies: 3
    Last Post: 10-03-2001, 07:25 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21