Search Results for

    Show / Hide Table of Contents

    Class UpdatablePriorityQueueExtensions

    Extension methods for IUpdatablePriorityQueue<T> implementations.

    Inheritance
    System.Object
    UpdatablePriorityQueueExtensions
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: MoreStructures.PriorityQueues.Extensions
    Assembly: MoreStructures.dll
    Syntax
    public static class UpdatablePriorityQueueExtensions

    Methods

    | Improve this Doc View Source

    PopAll<T>(IPriorityQueue<T>)

    Pops in sequence all items of the provided queue, returning the sequence of extracted items.

    Declaration
    public static IEnumerable<PrioritizedItem<T>> PopAll<T>(this IPriorityQueue<T> queue)
    Parameters
    Type Name Description
    IPriorityQueue<T> queue

    The IPriorityQueue<T>, to extract all items of.

    Returns
    Type Description
    IEnumerable<MoreStructures.PriorityQueues.PrioritizedItem<T>>

    A sequence of extracted MoreStructures.PriorityQueues.PrioritizedItem<T>, in order of priority.

    Type Parameters
    Name Description
    T

    The type of items in the queue.

    | Improve this Doc View Source

    PushOrUpdate<T>(IUpdatablePriorityQueue<T>, T, Int32)

    If the provided item already is in the queue, it updates its priority to the newPriority. Otherwise, it pushes the item in the queue, with the priority newPriority.

    Declaration
    public static PrioritizedItem<T>? PushOrUpdate<T>(this IUpdatablePriorityQueue<T> queue, T item, int newPriority)
    Parameters
    Type Name Description
    IUpdatablePriorityQueue<T> queue

    The IUpdatablePriorityQueue<T> instance to update.

    T item

    The item of type T to be pushed or updated.

    System.Int32 newPriority

    The new priority value.

    Returns
    Type Description
    System.Nullable<MoreStructures.PriorityQueues.PrioritizedItem<T>>

    The MoreStructures.PriorityQueues.PrioritizedItem<T> entry before the update, or null, if there was no entry of item before the update (and a push has been done instead).

    Type Parameters
    Name Description
    T

    The type of items of the queue.

    Remarks

    ALGORITHM
    - A Remove(T) of the provided item is attempted.
    - Then, a Push(T, Int32) of the same item is made, with the newPriority.
    - Finally, the removed item, if any, is returned as result.

    COMPLEXITY
    - Time Complexity is O(Tremove + Tpush) and Space Complexity is O(Sremove + Spush), where Tremove and Sremove are the time and space cost of Remove(T) and Tpush and Spush are the time and space cost of Push(T, Int32), respectively.

    • Improve this Doc
    • View Source
    In This Article
    Back to top Generated by DocFX