Example #1
0
    public void Enqueue(EntryType entry, ComparatorType comparator)
    {
        PriorityQueueBodyNode <EntryType, ComparatorType> fish = nodesPool.Catch();

        fish.Initialize(entry, comparator);

        tail.Bubble(fish);

        ++Count;
    }
Example #2
0
    public override void Bubble(PriorityQueueBodyNode <EntryType, ComparatorType> node)
    {
        previous.next = node;

        node.previous = previous;

        node.next = this;

        previous = node;
    }
Example #3
0
    public ComparatorType PeekAtPriority()
    {
        if (Count == 0)
        {
            return(default(ComparatorType));
        }

        PriorityQueueBodyNode <EntryType, ComparatorType> entry = (PriorityQueueBodyNode <EntryType, ComparatorType>)head.previous;

        return(entry.priority);
    }
Example #4
0
    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);
        }
    }
Example #5
0
    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);
    }
Example #6
0
 public override void Bubble(PriorityQueueBodyNode <EntryType, ComparatorType> node)
 {
     next.Bubble(node);
 }
Example #7
0
 public abstract void Bubble(PriorityQueueBodyNode <EntryType, ComparatorType> node);