Class
Heap<TData>

An implementation of the Heap data structure.

Definition

Namespace:Telerik.Windows.Diagrams.Core

Assembly:Telerik.Windows.Diagrams.Core.dll

Type Parameters:

TData

The type of item stored in the Heap<TData>.

Syntax:

cs-api-definition
[SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
public class Heap<TData> : ICollection<TData>, IEnumerable<TData>, IEnumerable

Inheritance: objectHeap<TData>

Implements: ICollection<TData>IEnumerableIEnumerable<TData>

Constructors

Heap(OrderType)

Initializes a new instance of the Heap<TData> class.

Declaration

cs-api-definition
public Heap(OrderType type)

Parameters

type

OrderType

The type.

Heap(OrderType, Comparison<TData>)

Initializes a new instance of the Heap<TData> class.

Declaration

cs-api-definition
public Heap(OrderType type, Comparison<TData> comparer)

Parameters

type

OrderType

The type.

comparer

Comparison<TData>

The comparer.

Heap(OrderType, IComparer<TData>)

Initializes a new instance of the Heap<TData> class.

Declaration

cs-api-definition
public Heap(OrderType type, IComparer<TData> comparer)

Parameters

type

OrderType

The type.

comparer

IComparer<TData>

The comparer.

Heap(OrderType, int)

Initializes a new instance of the Heap<TData> class.

Declaration

cs-api-definition
public Heap(OrderType type, int capacity)

Parameters

type

OrderType

The type.

capacity

int

The capacity.

Heap(OrderType, int, Comparison<TData>)

Initializes a new instance of the Heap<TData> class.

Declaration

cs-api-definition
public Heap(OrderType type, int capacity, Comparison<TData> comparer)

Parameters

type

OrderType

The type.

capacity

int

The capacity.

comparer

Comparison<TData>

The comparer.

Heap(OrderType, int, IComparer<TData>)

Initializes a new instance of the Heap<TData> class.

Declaration

cs-api-definition
public Heap(OrderType type, int capacity, IComparer<TData> comparer)

Parameters

type

OrderType

The type.

capacity

int

The capacity.

comparer

IComparer<TData>

The comparer.

Properties

Count

Gets the number of items in this heap structure.

Declaration

cs-api-definition
public int Count { get; }

Property Value

int

Implements ICollection<TData>.Count

IsEmpty

Gets a value indicating whether this instance is empty.

Declaration

cs-api-definition
public bool IsEmpty { get; }

Property Value

bool

true if this instance is empty; otherwise, false.

IsReadOnly

Returns false; the heap is never read-only.

Declaration

cs-api-definition
public bool IsReadOnly { get; }

Property Value

bool

true if this instance is read only; otherwise, false.

Implements ICollection<TData>.IsReadOnly

Root

Gets the root of the heap.

Declaration

cs-api-definition
public TData Root { get; }

Property Value

TData

Type

Gets the type of heap.

Declaration

cs-api-definition
[SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods")]
public OrderType Type { get; }

Property Value

OrderType

The type of heap.

Methods

Add(TData)

Adds the given item to the heap.

Declaration

cs-api-definition
public void Add(TData item)

Parameters

item

TData

The item to be added.

Implements ICollection<TData>.Add(TData)

AddItem(TData)

Adds the given item to the heap.

Declaration

cs-api-definition
protected virtual void AddItem(TData item)

Parameters

item

TData

The item.

Clear()

Clears this heap of all data.

Declaration

cs-api-definition
public void Clear()

Implements ICollection<TData>.Clear()

ClearItems()

Clears all the objects in this instance.

Declaration

cs-api-definition
protected virtual void ClearItems()

Remarks

Notes to Inheritors: Derived classes can override this method to change the behavior of the Clear() method.

Contains(TData)

Returns whether the given item is in the heap.

Declaration

cs-api-definition
public bool Contains(TData item)

Parameters

item

TData

The item to test.

Returns

bool

true if contained in this heap; otherwise, false.

Implements ICollection<TData>.Contains(TData)

CopyTo(TData[], int)

Copies the heap data to an array.

Declaration

cs-api-definition
public void CopyTo(TData[] array, int arrayIndex)

Parameters

array

TData[]

The array.

arrayIndex

int

Index of the array from which the copying starts.

Implements ICollection<TData>.CopyTo(TData[], int)

GetEnumerator()

Returns an enumerator that iterates through the collection.

Declaration

cs-api-definition
public IEnumerator<TData> GetEnumerator()

Returns

IEnumerator<TData>

A IEnumerator<T> that can be used to iterate through the collection.

Implements IEnumerable<TData>.GetEnumerator()

RemoveRoot()

Removes the root from the heap.

Declaration

cs-api-definition
public TData RemoveRoot()

Returns

TData

RemoveRootItem()

Removes the root item and arrange the tree in the heap.

Declaration

cs-api-definition
protected virtual void RemoveRootItem()

ToString()

Returns a string that represents this instance.

Declaration

cs-api-definition
public override string ToString()

Returns

string

A string that represents this instance.

Overrides object.ToString()