Class IntervalHeap<T>

A priority queue class based on an interval heap data structure.
Type parameters:
TThe item type

Implements

IEnumerable<T>, System.Collections.IEnumerable, System.IFormattable, System.ICloneable, ICollectionValue<T>, IExtensible<T>, IPriorityQueue<T>, IShowable

Bases

object, EnumerableBase<T>, CollectionValueBase<T>

Event overview

CollectionChanged, Inherited from CollectionValueBase<T> ,
CollectionCleared, Inherited from CollectionValueBase<T> ,
ItemInserted, Inherited from CollectionValueBase<T> ,
ItemRemovedAt, Inherited from CollectionValueBase<T> ,
ItemsAdded, Inherited from CollectionValueBase<T> ,
ItemsRemoved, Inherited from CollectionValueBase<T>

Property overview

ActiveEvents, Inherited from CollectionValueBase<T> ,
AllowsDuplicates ,
Comparer ,
Count ,
CountSpeed ,
DuplicatesByCounting ,
EqualityComparer ,
IsEmpty ,
IsReadOnly ,
this[IPriorityQueueHandle<T> handle] ,
ListenableEvents

Constructor overview

IntervalHeap<T>() ,
IntervalHeap<T>(System.Collections.Generic.IComparer<T> comparer) ,
IntervalHeap<T>(int capacity) ,
IntervalHeap<T>(int capacity, System.Collections.Generic.IComparer<T> comparer)

Method overview

Add(T item) ,
Add(ref IPriorityQueueHandle<T> handle, T item) ,
AddAll<U>(IEnumerable<U> items) ,
All(Fun<T,bool> predicate), Inherited from CollectionValueBase<T> ,
Apply(Act<T> action), Inherited from CollectionValueBase<T> ,
Check() ,
Choose() ,
Clone() ,
CopyTo(T[] array, int index), Inherited from CollectionValueBase<T> ,
Delete(IPriorityQueueHandle<T> handle) ,
DeleteMax() ,
DeleteMax(out IPriorityQueueHandle<T> handle) ,
DeleteMin() ,
DeleteMin(out IPriorityQueueHandle<T> handle) ,
Equals(object obj), Inherited from object ,
Exists(Fun<T,bool> predicate), Inherited from CollectionValueBase<T> ,
Filter(Fun<T,bool> predicate), Inherited from CollectionValueBase<T> ,
Finalize(), Inherited from object ,
Find(IPriorityQueueHandle<T> handle, out T item) ,
Find(Fun<T,bool> predicate, out T item), Inherited from CollectionValueBase<T> ,
FindMax() ,
FindMax(out IPriorityQueueHandle<T> handle) ,
FindMin() ,
FindMin(out IPriorityQueueHandle<T> handle) ,
GetEnumerator() ,
GetHashCode(), Inherited from object ,
GetType(), Inherited from object ,
MemberwiseClone(), Inherited from object ,
raiseCollectionChanged(), Inherited from CollectionValueBase<T> ,
raiseCollectionCleared(bool full, int count), Inherited from CollectionValueBase<T> ,
raiseCollectionCleared(bool full, int count, System.Nullable<int> offset), Inherited from CollectionValueBase<T> ,
raiseForAdd(T item), Inherited from CollectionValueBase<T> ,
raiseForInsert(int i, T item), Inherited from CollectionValueBase<T> ,
raiseForRemove(T item), Inherited from CollectionValueBase<T> ,
raiseForRemove(T item, int count), Inherited from CollectionValueBase<T> ,
raiseForRemoveAll(ICollectionValue<T> wasRemoved), Inherited from CollectionValueBase<T> ,
raiseForRemoveAt(int index, T item), Inherited from CollectionValueBase<T> ,
raiseForSetThis(int index, T value, T item), Inherited from CollectionValueBase<T> ,
raiseForUpdate(T newitem, T olditem), Inherited from CollectionValueBase<T> ,
raiseForUpdate(T newitem, T olditem, int count), Inherited from CollectionValueBase<T> ,
raiseItemInserted(T item, int index), Inherited from CollectionValueBase<T> ,
raiseItemRemovedAt(T item, int index), Inherited from CollectionValueBase<T> ,
raiseItemsAdded(T item, int count), Inherited from CollectionValueBase<T> ,
raiseItemsRemoved(T item, int count), Inherited from CollectionValueBase<T> ,
Replace(IPriorityQueueHandle<T> handle, T item) ,
Show(System.Text.StringBuilder stringbuilder, ref int rest, System.IFormatProvider formatProvider), Inherited from CollectionValueBase<T> ,
ToArray(), Inherited from CollectionValueBase<T> ,
ToString(string format, System.IFormatProvider formatProvider), Inherited from CollectionValueBase<T> ,
ToString(), Inherited from CollectionValueBase<T>

Property details

F bool AllowsDuplicatesAccess: Read-Only

Value:True since this collection has bag semantics

F System.Collections.Generic.IComparer<T> ComparerAccess: Read-Only

Value:The comparer

The comparer object supplied at creation time for this collection
int CountAccess: Read-Only

Value:The size of this collection

Speed CountSpeedAccess: Read-Only

Value:A characterization of the speed of the Count property in this collection.

The value is symbolic indicating the type of asymptotic complexity in terms of the size of this collection (worst-case or amortized as relevant).
bool DuplicatesByCountingAccess: Read-Only

Value:True if only one representative of a group of equal items is kept in the collection together with the total count.

By convention this is true for any collection with set semantics.
System.Collections.Generic.IEqualityComparer<T> EqualityComparerAccess: Read-Only

Value:

Value is null since this collection has no equality concept for its items.
bool IsEmptyAccess: Read-Only

Value:True if this collection is empty.

F bool IsReadOnlyAccess: Read-Only

Value:True if this collection is read-only.

If true any call of an updating operation will throw an ReadOnlyCollectionException
F T this[IPriorityQueueHandle<T> handle]Access: Read-Write
Get or set the item corresponding to a handle.
Throws
InvalidPriorityQueueHandleExceptionif the handle is invalid for this queue
Parameters:
handle:The reference into the heap
EventTypeEnum ListenableEventsAccess: Read-Only

Value:

Constructor details

IntervalHeap<T>() Create an interval heap with natural item comparer and default initial capacity (16)
IntervalHeap<T>(System.Collections.Generic.IComparer<T> comparer) Create an interval heap with external item comparer and default initial capacity (16)
Parameters:
comparer:The external comparer
IntervalHeap<T>(int capacity) Create an interval heap with natural item comparer and prescribed initial capacity
Parameters:
capacity:The initial capacity
IntervalHeap<T>(int capacity, System.Collections.Generic.IComparer<T> comparer) Create an interval heap with external item comparer and prescribed initial capacity
Parameters:
comparer:The external comparer
capacity:The initial capacity

Method details

F bool Add(T item) Add an item to this priority queue.
Returns:True
Parameters:
item:The item to add.
F bool Add(ref IPriorityQueueHandle<T> handle, T item) Add an item to the priority queue, receiving a handle for the item in the queue, or reusing an already existing handle.
Returns:True since item will always be added unless the call throws an exception.
Parameters:
handle:On output: a handle for the added item. On input: null for allocating a new handle, an invalid handle for reuse. A handle for reuse must be compatible with this priority queue, by being created by a priority queue of the same runtime type, but not necessarily the same priority queue object.
item:The item to add.
F void AddAll<U>(IEnumerable<U> items) Add the elements from another collection with a more specialized item type to this collection.
Type parameters:
UThe type of items to add
Constraints:
U : T
Parameters:
items:The items to add
F bool Check() Check the integrity of the internal data structures of this collection. Only avaliable in DEBUG builds???
Returns:True if check does not fail.
T Choose() Choose some item of this collection.
Throws
NoSuchItemExceptionif collection is empty.
Returns:
object Clone() Make a shallow copy of this IntervalHeap.
Returns:
F T Delete(IPriorityQueueHandle<T> handle) Delete an item with a handle from a priority queue.
Throws
InvalidPriorityQueueHandleExceptionif the handle is invalid
Returns:The deleted item
Parameters:
handle:The handle for the item. The handle will be invalidated, but reusable.
F T DeleteMax() Remove the largest item from this priority queue. /ThrowsC5.NoSuchItemException if queue is empty
Returns:The removed item.
F T DeleteMax(out IPriorityQueueHandle<T> handle) Remove the largest item from this priority queue.
Returns:The removed item.
Parameters:
handle:On return: the handle of the removed item.
F T DeleteMin() Remove the least item from this priority queue. /ThrowsC5.NoSuchItemException if queue is empty
Returns:The removed item.
F T DeleteMin(out IPriorityQueueHandle<T> handle) Remove the least item from this priority queue.
Returns:The removed item.
Parameters:
handle:On return: the handle of the removed item.
F bool Find(IPriorityQueueHandle<T> handle, out T item) Check safely if a handle is valid for this queue and if so, report the corresponding queue item.
Returns:True if the handle is valid.
Parameters:
handle:The handle to check
item:If the handle is valid this will contain the corresponding item on output.
F T FindMax() Find the current largest item of this priority queue. /ThrowsC5.NoSuchItemException if queue is empty
Returns:The largest item.
F T FindMax(out IPriorityQueueHandle<T> handle) Find the current largest item of this priority queue.
Returns:The largest item.
Parameters:
handle:On return: the handle of the item.
F T FindMin() Find the current least item of this priority queue. /ThrowsC5.NoSuchItemException if queue is empty
Returns:The least item.
F T FindMin(out IPriorityQueueHandle<T> handle) Find the current least item of this priority queue.
Returns:The least item.
Parameters:
handle:On return: the handle of the item.
System.Collections.Generic.IEnumerator<T> GetEnumerator() Create an enumerator for the collection

Note: the enumerator does *not* enumerate the items in sorted order, but in the internal table order.

Returns:The enumerator(SIC)
F T Replace(IPriorityQueueHandle<T> handle, T item) Replace an item with a handle in a priority queue with a new item. Typically used for changing the priority of some queued object.
Returns:The old item
Parameters:
handle:The handle for the old item
item:The new item