Microsoft.Samples.Collections.Heap Class
A top-heavy heap implementation which keeps its members in a semi-ordered fashion and returns them in an ordered fashion

Access: Public
Base Classes: Object
Implemented interfaces: ICollection, ICloneable, ISerializable
  Members Description  
    InitialStorageSize The initial size for a heap

 
    rm    
    nodeArray The elements stored in the heap

 
    size The number of valid elements that are stored in nodeArray

 
    version Version stamp to allow enumerators to know if they are invalid

 
    incrementSize How large should the (de)allocation be on auto-sizing operations

 
    comparer Object for comparing entries for ordering.

 
    Heap Default constructor

 
    Heap Construct a heap specifying an object to perform comparisons between heap members

 
    Heap Construct a heap specifying an object to perform comparisons between heap members and a dynamic allocation size.

 
    Synchronized Returns a synchronized (thread-safe) wrapper for the Heap.

 
    Add Add an object to the heap maintaining its heap properties

 
    Extract Extract returns the highest value object from the heap

 
    Peek Look at the element at the top of the heap without removing it.

 
    IsEmpty Test whether the heap is empty of elements.

 
    Clone Create a copy of the heap containing the same object references

 
    Clear Removes all elements from the Heap.

 
    Contains Determines whether an element is in the Heap.

 
    Parent The parent node of the given node

 
    LeftChild The left-hand child of the given node

 
    RightChild The right-hand child of the given node

 
    LeafNode Whether the given node is a leaf node

 
    IncrementSize The calculated value of the increment size

 
    GrowStorage Add new storage

 
    FlushStorage Remove unused storage

 
    IsSynchronized Gets a value indicating whether access to the heap is synchronized (thread-safe). As this is an unsynchronized heap, it will aways return false.

 
    Count Returns a value indicating the number of objects in the heap. Read-only

 
    CopyTo Copy all the elements stored on the current heap to the specified one-dimensional array starting at the specified index

 
    SyncRoot Gets an object that can be used to synchronize access to the heap

 
    GetEnumerator Returns an enumerator that can iterate through the heap in an unordered fashion.

 
    IEnumerable.GetEnumerator Returns an enumerator that can iterate through the heap in an unordered fashion.

 
    ICloneable.Clone Create a copy of the heap containing the same object references

 
    GetObjectData Populates a SerializationInfo with the data needed to serialize the heap.

 
    Heap Special constructor for serialization.

 
    HeapEnumerator Simple unordered enumerator for heaps

 
    SynchronizedHeap Simple class to provide synchronized versions of the Heap API

 
Remarks:
Based on a left-balanced binary tree - implemented on a simple array The heap grows and shrinks by doubling/halving its size starting with a size of 10 This code was inspired by the interface to the heap implementation presented in "Mastering Algorithms with C" by Kyle Loudon, published by O'Reilly & Associates.