I am not sure if this will be useful... This is the method i used to set up my ringQueue. and it also belongs to the RingQueue class.
Code:public class RingQueue{ ... ... /** * Set up a circular linked list / Queue of length L * @param reference to the front of the queue * @param max length of the queue **/ private void setupQ(Node head,int L){ Node temp = head; for(int i=0;i<L;i++){ if(temp == null) temp = new Node(null,null); else if(i+1==L) temp.setNext(head); else{ temp.setNext(new Node(null,null)); temp=temp.getNext(); } } System.out.println("Ring Queue setup complete"); } }




Reply With Quote
