Click or drag to resize
BinaryHeapTElement Class
Simple heap which is based on a binary tree: the binary heap. See: http://en.wikipedia.org/wiki/Binary_heap Binary heaps are quite efficient, however if you're doing a lot of merging between heaps, the Binary heap is inefficient. Consider a Fibonacci heap instead in these situations.
Inheritance Hierarchy
SystemObject
  SD.Tools.Algorithmia.HeapsHeapBaseTElement
    SD.Tools.Algorithmia.HeapsBinaryHeapTElement

Namespace:  SD.Tools.Algorithmia.Heaps
Assembly:  SD.Tools.Algorithmia (in SD.Tools.Algorithmia.dll) Version: 1.2.0.0 (1.2.16.0406)
Syntax
public class BinaryHeap<TElement> : HeapBase<TElement>
where TElement : class

Type Parameters

TElement
The type of the elements in this heap

The BinaryHeapTElement type exposes the following members.

Constructors
  NameDescription
Public methodBinaryHeapTElement
Initializes a new instance of the BinaryHeapTElement class.
Top
Properties
  NameDescription
Public propertyCount
Gets the number of elements in the heap.
(Overrides HeapBaseTElementCount.)
Protected propertyElementCompareFunc
Gets the element compare func, which is the func to compare two elements based on the heap type: the function returns true if the first element is indeed the correct parent of the second element or false if not.
(Inherited from HeapBaseTElement.)
Public propertyIsMinHeap
Gets a value indicating whether this instance is a min heap (true) or a max heap (false)
(Inherited from HeapBaseTElement.)
Protected propertyKeyCompareFunc
Gets the key compare func to compare elements based on key.
(Inherited from HeapBaseTElement.)
Public propertyRoot
Gets the root of the heap. Depending on the fact if this is a min or max heap, it returns the element with the minimum key (min heap) or the element with the maximum key (max heap). If the heap is empty, null / default is returned
(Overrides HeapBaseTElementRoot.)
Top
Methods
  NameDescription
Public methodClear
Clears all elements from the heap
(Overrides HeapBaseTElementClear.)
Public methodContains
Determines whether this heap contains the element specified
(Overrides HeapBaseTElementContains(TElement).)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodExtractRoot
Extracts and removes the root of the heap.
(Overrides HeapBaseTElementExtractRoot.)
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.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodInsert
Inserts the specified element into the heap at the right spot
(Overrides HeapBaseTElementInsert(TElement).)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodMerge
Merges the specified heap into this heap.
Public methodRemove
Removes the element specified
(Overrides HeapBaseTElementRemove(TElement).)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodUpdateKeyTKeyType(TElement, ActionTElement, TKeyType, TKeyType)
Updates the key of the element passed in. Only use this method for elements where the key is a property of the element, not the element itself. This means that if you have a heap with value typed elements (e.g. integers), updating the key is updating the value of the element itself, and because a heap might contain elements with the same value, this could lead to undefined results.
(Overrides HeapBaseTElementUpdateKeyTKeyType(TElement, ActionTElement, TKeyType, TKeyType).)
Public methodUpdateKeyTKeyType(TElement, ActionTElement, TKeyType, TKeyType)
Updates the key of the element passed in. Only use this method for elements where the key is a property of the element, not the element itself. This means that if you have a heap with value typed elements (e.g. integers), updating the key is updating the value of the element itself, and because a heap might contain elements with the same value, this could lead to undefined results.
(Inherited from HeapBaseTElement.)
Top
Remarks
Heaps can't store value types. This is because changing a value type really makes it a different value, while changing the contents of an object doesn't make it a different object.
See Also