Advertisement
Flameancer

TaskPriorityQueue

May 29th, 2015
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.37 KB | None | 0 0
  1. /**
  2.  * This a priority queue that implements a heap
  3.  * @author Jonathan Harris
  4.  * May 28, 2015
  5.  */
  6.  
  7. public class TaskPriorityQueue<Task extends Comparable<? super Task>> implements PriorityQueue<Task> {
  8.  
  9.  
  10.     Node root;
  11.  
  12.   /**
  13.    * This is the private node class for the Queue/Heap Implementation.
  14.    */
  15.    private class Node {
  16.      private Task item;
  17.      private Node lChild;
  18.      private Node mChild;
  19.      private Node rChild;
  20.  
  21.      private Node(Task item, Node lChild, Node mChild, Node rChild) {
  22.        this.item = item;
  23.        this.lChild = lChild;
  24.        this.mChild = mChild;
  25.        this.rChild = rChild;
  26.  
  27.      }
  28.    }
  29.  
  30.   public TaskPriorityQueue() {
  31.       Node root = null;
  32.   }
  33.  
  34.   /** Adds the given item to the queue. */
  35.   public void add(Task task) {
  36.       if (root == null) {
  37.           root = new Node(task, null,null,null);
  38.       }
  39.       System.out.println();
  40.       Node tempNode = root;
  41.  
  42.       System.out.println(task.getClass().getName());
  43.  
  44.       /*while(true) {
  45.           if (tempNode.item.getDueDate().compareTo(task.getDueDate()) > 0) {
  46.               //System.out.println(item.getDueDate() + " is less than node.");
  47.           }
  48.       }*/
  49.   }
  50. // Some other code
  51.  
  52.   public static void main(String[] args) {
  53.     Task task1 = new Task("05-29-1995", "task1");
  54.     TaskPriorityQueue<Task> queue = new TaskPriorityQueue<Task>();
  55.   }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement