public override Queue.QueueNode Add(Queue.QueueNode head, Process process) { Queue.QueueNode newNode = new Queue.QueueNode(process); // Before head if (isBetter(process, head.Process)) { newNode.Next = head; return(newNode); } // Search for the node before the inserted one while (head.Next != null) { if (isBetter(process, head.Next.Process)) { newNode.Next = head.Next; head.Next = newNode; return(null); } head = head.Next; } head.Next = newNode; return(null); }
public override Queue.QueueNode Add(Queue.QueueNode head, Process process) { while (head.Next != null) { head = head.Next; } head.Next = new Queue.QueueNode(process); return(null); }
/*** * return a node if you want to replace it with head node, otherwise you * <b>must</b> return null ***/ public abstract Queue.QueueNode Add(Queue.QueueNode list, Process process);