Click or drag to resize

SortedPriorityQueueTElement Class

Simple priority queue which uses a list for storing the elements which is always kept sorted. Inserts can be slow, as worst case inserts (insert at the front) requires a move of all elements, so the order is somewhere around the order of insertion sort, O((n^2)/4). Lookups and removals are very fast: O(1).
Inheritance Hierarchy
SystemObject
  SD.Tools.Algorithmia.PriorityQueuesPriorityQueueBaseTElement
    SD.Tools.Algorithmia.PriorityQueuesSortedPriorityQueueTElement

Namespace:  SD.Tools.Algorithmia.PriorityQueues
Assembly:  SD.Tools.Algorithmia (in SD.Tools.Algorithmia.dll) Version: 1.4.0.0 (1.4.19.0711)
Syntax
public class SortedPriorityQueue<TElement> : PriorityQueueBase<TElement>

Type Parameters

TElement
The type of the elements in this queue

The SortedPriorityQueueTElement type exposes the following members.

Constructors
  NameDescription
Public methodSortedPriorityQueueTElement
Initializes a new instance of the SortedPriorityQueueTElement class.
Top
Properties
Methods
  NameDescription
Public methodAdd
Adds the specified element to the queue
(Overrides PriorityQueueBaseTElementAdd(TElement).)
Public methodClear
Clears the queue.
(Overrides PriorityQueueBaseTElementClear.)
Public methodContains
Determines whether the queue contains the element specified
(Overrides PriorityQueueBaseTElementContains(TElement).)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Protected methodGetEnumerator
Gets the enumerator for this queue
(Overrides PriorityQueueBaseTElementGetEnumerator.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodPeek
Peeks at the first element of the queue (the one with the highest priority, according to the priority comparison) and returns that element without removing it
(Overrides PriorityQueueBaseTElementPeek.)
Public methodRemove
Removes the first element from the queue, if the queue isn't empty.
(Overrides PriorityQueueBaseTElementRemove.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Explicit Interface Implementations
Remarks
If you store value types in this queue, be aware that Peek() and Remove() on an empty queue will return the default value for the value type used, e.g. 0 for a priority queue with Int32 values. Therefore, consult Count to check whether there are any values in the queue.
See Also