Jump to content

Getting values from a circular list in C#.

- - - - -

  • Please log in to reply
1 reply to this topic

#1
Magnus021

Magnus021

    Newbie

  • Members
  • Pip
  • 2 posts
Hi I'm trying to write a method Peek that will return the value of the element that is first in the list, The FirstFilled value. I tried to write the method. But how do I write to display this in my Program class?



Any suggestions? thank u


   public class CircList<T>

    {

        public CircNode<T> FirstFree { get; set; }

        public CircNode<T> FirstFilled { get; set; }


        public CircList()

        {

            FirstFree = new CircNode<T>();

            FirstFilled = FirstFree;

            FirstFree.Next = FirstFree;


        }


        public bool Empty()

        {

            if (FirstFree.Next == FirstFilled)

                return true;

            return false;


        }

        public void Enqueue(T value)

        {

            CircNode<T> tempNode = new CircNode<T>(value);

            if (FirstFree.Next == FirstFilled)

            {

                                

                FirstFilled = new CircNode<T>();

                tempNode.Next = FirstFilled;    

                                     

            }


        }

        public T Peek()

        {

            return FirstFilled.Next.Value;

        }

Edited by Roger, 02 April 2011 - 09:24 AM.
added code tags


#2
Magnus021

Magnus021

    Newbie

  • Members
  • Pip
  • 2 posts
Nevermind I fixed it.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users