Search Results for

    Show / Hide Table of Contents

    Class PriorityQueue<T>

    An implementation of a min-Priority Queue using a heap. Has O(1) .Contains()! See https://bitbucket.org/BlueRaja/high-speed-priority-queue-for-c/wiki/Getting%20Started for more information.

    Inheritance
    object
    PriorityQueue<T>
    Namespace: Evergine.Common.Collections
    Assembly: Evergine.Common.dll
    Syntax
    public sealed class PriorityQueue<T> where T : PriorityQueueNode
    Type Parameters
    Name Description
    T

    The values in the queue. Must implement the PriorityQueueNode interface.

    Constructors

    PriorityQueue(int)

    Initializes a new instance of the PriorityQueue<T> class.

    Declaration
    public PriorityQueue(int maxNodes)
    Parameters
    Type Name Description
    int maxNodes

    The maximum number of nodes allowed to be enqueued (exceeding this will cause an exception).

    Properties

    Count

    Gets the number of nodes.

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    int

    The count.

    First

    Gets the head of the queue without removing it (use Dequeue() for that). O(1).

    Declaration
    public T First { get; }
    Property Value
    Type Description
    T

    Returns the head of the queue without removing it (use Dequeue() for that). O(1).

    Methods

    Clear()

    Clears the instance.

    Declaration
    public void Clear()

    Contains(T)

    Determines whether [contains] [the specified node].

    Declaration
    public bool Contains(T node)
    Parameters
    Type Name Description
    T node

    The node.

    Returns
    Type Description
    bool

    True if it contains the node; false otherwise.

    Dequeue()

    Removes the head of the queue (node with the highest priority; ties are broken by order of insertion) and returns it. O(log n).

    Declaration
    public T Dequeue()
    Returns
    Type Description
    T

    The dequeued node.

    Enqueue(T, double)

    Enqueues the specified node.

    Declaration
    public void Enqueue(T node, double priority)
    Parameters
    Type Name Description
    T node

    The node.

    double priority

    The priority.

    Remove(T)

    Removes a node from the queue. Note that the node does not need to be the head of the queue. O(log n).

    Declaration
    public void Remove(T node)
    Parameters
    Type Name Description
    T node

    The node.

    Extension Methods

    ReflectionHelper.GetMemberAssembly(object)
    ReflectionHelper.GetTypeName(object)
    In this article
    Back to top
    Generated by DocFX