Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Circular Queue Structures

  1. #1
    Junior Member LeeDD's Avatar
    Join Date
    Feb 2013
    Location
    Caribbean
    Posts
    27
    My Mood
    Relaxed
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Circular Queue Structures

    I Jus wanna Kno if my code is correct? if there is any errors please let me know


    front = -1
    rear = -1
    size = 0


    // Enqueue circular structure
    public void Enqueue ()
    {
     
        if (size < maxSize)
    {    
          rear = rear + 1;
    }
     
         Queue [rear] = e;
     
         size =+ 1;
     
        if (rear + 1 == maxSize)
    {
            rear = -1;
    }
     
    }

    // Dequeue circular Structure
    public E dequeue()
    {
        if (size = 1)
          {
              size += 1;
              front++;
              e = Queue[front + 1];
           }
     
        if (front++ == 0)
           {
             return e;
            }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,130
    Thanks
    48
    Thanked 2,156 Times in 2,129 Posts

    Default Re: Circular Queue Structures

    Do you have code that calls the methods for testing?
    Does it work as expected?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member LeeDD's Avatar
    Join Date
    Feb 2013
    Location
    Caribbean
    Posts
    27
    My Mood
    Relaxed
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Circular Queue Structures

    yea but is on book.. i hav not placed it in any compiler.. its jus a general outline of how it should work.. i jus wan kno if these implementations will work as a circular structure

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,130
    Thanks
    48
    Thanked 2,156 Times in 2,129 Posts

    Default Re: Circular Queue Structures

    i jus wan kno if these implementations will work
    A good way to find out is to write a testing program that creates objects and calls their methods to see if they will work.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member LeeDD's Avatar
    Join Date
    Feb 2013
    Location
    Caribbean
    Posts
    27
    My Mood
    Relaxed
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Circular Queue Structures

    tru!!! i jus wanted to get past it

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,130
    Thanks
    48
    Thanked 2,156 Times in 2,129 Posts

    Default Re: Circular Queue Structures

    I can't test the posted code without having a method that creates instances of the classes and calls its methods. You will need to do that to see if the code works.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. File Structures and Format
    By sci4me in forum Java Theory & Questions
    Replies: 3
    Last Post: March 10th, 2013, 05:44 PM
  2. data structures question
    By hwoarang69 in forum Algorithms & Recursion
    Replies: 2
    Last Post: November 4th, 2012, 02:07 PM
  3. Please help about data structures.
    By bruce88 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: September 16th, 2012, 04:11 PM
  4. Replies: 0
    Last Post: November 6th, 2011, 02:55 PM
  5. Source Code to Implement Circular Queue in Java
    By rainbow9 in forum Java Programming Tutorials
    Replies: 0
    Last Post: August 20th, 2011, 02:30 AM