Ejemplo n.º 1
0
 public void Add(T new_data, U new_comparable)                           //sorted add
 {
     if (head == null || head.compareable.CompareTo(new_comparable) > 0) //is this the first node in the list or will the flower spawn before current
     {
         InsertFront(new_data, new_comparable);
     }
     else//append
     {
         head.Add(new_data, new_comparable);
     }
 }
 public void Add(T new_data, U new_compareable)                          //sorted add
 {
     if (next == null)                                                   //is this the end of the list
     {
         next = new PriorityQueueNode <T, U>(new_data, new_compareable); //append data
     }
     else if (next.compareable.CompareTo(new_compareable) < 0)           //is the new data larger than next?
     {
         next.Add(new_data, new_compareable);                            //pass it to the next node to check
     }
     else//current value is smaller than next so needs to be linked in here
     {
         PriorityQueueNode <T, U> temp = new PriorityQueueNode <T, U>(new_data, new_compareable);
         temp.next = next;
         next      = temp;
     }
 }