public void Enqueue(EntryType entry, ComparatorType comparator) { PriorityQueueBodyNode <EntryType, ComparatorType> fish = nodesPool.Catch(); fish.Initialize(entry, comparator); tail.Bubble(fish); ++Count; }
public override void Bubble(PriorityQueueBodyNode <EntryType, ComparatorType> node) { previous.next = node; node.previous = previous; node.next = this; previous = node; }
public ComparatorType PeekAtPriority() { if (Count == 0) { return(default(ComparatorType)); } PriorityQueueBodyNode <EntryType, ComparatorType> entry = (PriorityQueueBodyNode <EntryType, ComparatorType>)head.previous; return(entry.priority); }
public override void Bubble(PriorityQueueBodyNode <EntryType, ComparatorType> node) { if (priority.CompareTo(node.priority) > 0) { previous.next = node; node.previous = previous; node.next = this; previous = node; } else { next.Bubble(node); } }
public EntryType Dequeue() { if (Count == 0) { return(default(EntryType)); } PriorityQueueBodyNode <EntryType, ComparatorType> entry = (PriorityQueueBodyNode <EntryType, ComparatorType>)head.previous; entry.previous.next = head; head.previous = entry.previous; nodesPool.Release(entry); --Count; return(entry.item); }
public override void Bubble(PriorityQueueBodyNode <EntryType, ComparatorType> node) { next.Bubble(node); }
public abstract void Bubble(PriorityQueueBodyNode <EntryType, ComparatorType> node);