Table of Contents

Class PriorityQueue<TKey, TValue>

Namespace
RandomizerCore.Collections
Assembly
RandomizerCore.dll

Stable binary min-heap (equal priorities -> first-in first-out)

public class PriorityQueue<TKey, TValue> where TKey : IComparable<TKey>

Type Parameters

TKey
TValue
Inheritance
PriorityQueue<TKey, TValue>
Inherited Members

Constructors

PriorityQueue()

public PriorityQueue()

PriorityQueue(IEnumerable<TValue>, Func<TValue, TKey>)

public PriorityQueue(IEnumerable<TValue> ts, Func<TValue, TKey> prioritySelector)

Parameters

ts IEnumerable<TValue>
prioritySelector Func<TValue, TKey>

PriorityQueue(int)

public PriorityQueue(int capacity)

Parameters

capacity int

Properties

Capacity

public int Capacity { get; }

Property Value

int

Count

public int Count { get; }

Property Value

int

UnorderedItems

Gets a collection that enumerates the elements of the queue in an unordered manner.

public IReadOnlyCollection<(TKey, TValue)> UnorderedItems { get; }

Property Value

IReadOnlyCollection<(TKey, TValue)>

Methods

Clear()

public void Clear()

Enqueue(TKey, TValue)

public void Enqueue(TKey priority, TValue t)

Parameters

priority TKey
t TValue

ExtractMin()

public void ExtractMin()

ExtractMin(out TKey, out TValue)

public void ExtractMin(out TKey priority, out TValue t)

Parameters

priority TKey
t TValue

ExtractMin(out TValue)

public void ExtractMin(out TValue t)

Parameters

t TValue

GetConsumingEnumerable()

Returns an enumerable which, when enumerated, extracts and returns the elements of the priority queue in order.

public IEnumerable<(TKey, TValue)> GetConsumingEnumerable()

Returns

IEnumerable<(TKey, TValue)>

TryExtractMin(out TKey, out TValue)

public bool TryExtractMin(out TKey priority, out TValue t)

Parameters

priority TKey
t TValue

Returns

bool

TryPeek(out TKey, out TValue)

public bool TryPeek(out TKey priority, out TValue t)

Parameters

priority TKey
t TValue

Returns

bool

UpdateHead(TKey)

public void UpdateHead(TKey newPriority)

Parameters

newPriority TKey