title: Insertion into a priority queue implemented by doubly linked list with sentinels
body: <p>I am writing a priority queue using doubly linked list with sentinels</p>
  
  <pre><code>class Node {
      protected Node next;
      protected Node prev;
      protected int value;
      public Node() {
      }
      public Node(int value) {
          this.value = value;
      }
  }
  </code></pre>
  
  <p>This is my node class where I have set a condition that the Value lies between 0 and 11111 for ease in sorting.</p>
  
  <pre><code>public class someName {
      protected Node firstSentinel;
      protected Node lastSentinel;
  
      public someName() {
          firstSentinel = new Node();
          lastSentinel = new Node();
          firstSentinel.value = 11111;
          lastSentinel.value = 0;
          firstSentinel.prev = null;
          firstSentinel.next = lastSentinel;
          lastSentinel.prev = firstSentinel;
          lastSentinel.next = null;
      }
  
      public void enQueue(Node x) {
          if (firstSentinel.next == lastSentinel)// list is empty
          {
              firstSentinel.next = x;
              x.prev = firstSentinel;
              x.next = lastSentinel;
              lastSentinel.prev = x;
          } else {
              Node temp = x;
              Node curr = firstSentinel.next;
              while (curr != lastSentinel &amp;&amp; temp.value &lt;= curr.value) {
                  curr = curr.next;
              }
              Node tempCurr = curr;
              temp.next = tempCurr;
              temp.prev = tempCurr.prev;
              tempCurr.prev = temp;
              tempCurr.prev.next = temp;
          }
      }
  
      public Node deQueue() {
          if (firstSentinel.next == lastSentinel) {
              return null;
          } else {
              Node temp = new Node();
              temp = firstSentinel.next;
              firstSentinel.next = temp.next;
              temp.next.prev = firstSentinel;
              return temp;
          }
      }
  
      public void printt() {
          Node temp = new Node();
          temp = firstSentinel.next;
          while (temp != lastSentinel) {
              System.out.println(temp.value);
              temp = temp.next;
          }
      }
  
      public static void main(String[] args) {
          someName PQ = new someName();
          Node a = new Node(2);
          PQ.enQueue(a);
          PQ.printt();
          Node aa = new Node(456);
          PQ.enQueue(aa);
          Node aaa = new Node(123);
          PQ.enQueue(aaa);
          PQ.printt();
          Node aaaa = new Node(6);
          PQ.enQueue(aaaa);
          PQ.printt();
          Node aaaaa = new Node(1123);
          PQ.enQueue(aaaaa);
          PQ.printt();
      }
  }
  </code></pre>
  
  <p>When the program is run it just outputs twos. Which makes be believe that only 1 node(first node especially) is getting inserted. In this priority queue i am interested in descending order and as such the first sentinel value is being set to 11111 and last's is being set to 0. I think I am doing something stupid in enqueue. I will be glad if someone points me in the right direction. </p>