title: Priority Queue using Priority List Misses All the Middle Values in Java
body: <p>I am having an issue building a PList based Priority queue. Essentially, if I add items, all it ever does when I run a main function is spit out the highest and the lowest priority values. </p>
  
  <p>Here is my PQueue insert item method</p>
  
  <pre><code>public class PQueue {
  PList pq;
  PList top;
  
  
  public PQueue(){
      this.pq=null;
  }
  public PQueue(int priority, char x){
  this.pq=new PList(x, priority, null);
  top=this.pq;
  }
  
  public boolean isEmpty(){
      if(this.pq==null){
          return true;
      }else{
          return false;
      }
  }
  
  public void insertItem(int priority, char x){
      if(isEmpty()){
          this.pq=new PList(x, priority);
          top=this.pq;            
      }else{
          PList p=top;
          while(p.priority&lt;top.priority &amp;&amp; p!=null){
              p=p.next;
          }PList n=new PList(x, priority, p.next);
          p.next=n;
          if(n.priority&gt;top.priority){
              top=n;
          }
      }
  
  }
  public void show(PrintStream p){
      PList prnt= top;
      while(prnt!=null){
          p.println(prnt.content);
          prnt=prnt.next;
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Here is my linked list::</p>
  
  <pre><code>package se2s03;
  
  public class PList {
  public char content;
  public int priority;
  public PList next;
  
  PList(final char a, final int b, final PList ll){
      this.content=a;
      this.priority=b;
      this.next=ll;
  }
  PList(final char a, final int b){
      this.content=a;
      this.priority=b;
  }
  </code></pre>
  
  <p>}</p>