public String toString() {
    StringBuffer sbuf = new StringBuffer();

    ListNode currListNode = itemList.next; // skip anchor node
    for (int i = 0; i < count; i++) {
      if (currListNode != null) {
        sbuf.append("[" + i + "]=" + currListNode.toString()).append("\n");
        currListNode = currListNode.next;
      } else {
        sbuf.append("[" + i + "] << END OF LIST >>\n");
        LOG.printError("ListNode is null at element [" + i + "], but count is " + count);
      }
    }
    return sbuf.toString();
  }
 /**
  * If PQ is non-empty, remove from PQ an item , X, of highest priority in PQ
  *
  * @return - highest priority item
  */
 public ComparisonKey remove() {
   ComparisonKey highestKey = null;
   ListNode highestListNode = itemList.next;
   if (highestListNode != null) {
     highestKey = highestListNode.item;
     ListNode nextHighestListNode = highestListNode.next;
     // now reset the link
     if (nextHighestListNode != null) {
       itemList.next = nextHighestListNode;
     } else {
       itemList.next = null;
     }
     count--;
   }
   LOG.printDebugMessage("Removed highestKey=" + highestKey.toString());
   return highestKey;
 }
  public void insert(ComparisonKey newKey) {
    LOG.printDebugMessage("Insert " + newKey.toString());
    if (isEmpty()) {
      LOG.printDebugMessage("Adding first link!");
      itemList.next = new ListNode(newKey, null);
    } else {
      // insert the new item in order so we maintain a sorted list
      ListNode prevListNode = itemList;

      ListNode currListNode = itemList.next;

      boolean isInserted = false;

      while (!isInserted) {

        if (currListNode != null && newKey.compareTo(currListNode.item) >= 0) {
          LOG.printDebugMessage("currListNode is null or newKey > currListNode.item");
          ListNode newListNode = new ListNode(newKey, currListNode);
          prevListNode.next = newListNode;
          isInserted = true;

        } else if (currListNode == null) {
          LOG.printDebugMessage("reached the end of the linked list");
          ListNode newListNode = new ListNode(newKey, null);
          prevListNode.next = newListNode;
          isInserted = true;

        } else {
          LOG.printDebugMessage("move to next pointer");
          prevListNode = currListNode;
          currListNode = currListNode.next;
        } // if(currListNode==null)
      } // while(!isInserted)
    }

    count++;
  }