Show / Hide Table of Contents

Class BinaryHeap<T>

A binary heap, useful for sorting data and priority queues.

Inheritance
object
BinaryHeap<T>
Implements
ICollection<T>
IEnumerable<T>
IEnumerable
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: NMF.Expressions
Assembly: NMF.Expressions.dll
Syntax
public class BinaryHeap<T> : ICollection<T>, IEnumerable<T>, IEnumerable
Type Parameters
Name Description
T

The element type

Constructors

| Edit this page View Source

BinaryHeap()

Creates a new binary heap

Declaration
public BinaryHeap()
| Edit this page View Source

BinaryHeap(IComparer<T>)

Creates a new binary heap.

Declaration
public BinaryHeap(IComparer<T> comparer)
Parameters
Type Name Description
IComparer<T> comparer

The comparer used to compare the items

Properties

| Edit this page View Source

Capacity

Gets or sets the capacity of the heap.

Declaration
public int Capacity { get; set; }
Property Value
Type Description
int
| Edit this page View Source

Count

Gets the number of values in the heap.

Declaration
public int Count { get; }
Property Value
Type Description
int
| Edit this page View Source

IsReadOnly

Gets whether or not the binary heap is readonly.

Declaration
public bool IsReadOnly { get; }
Property Value
Type Description
bool

Methods

| Edit this page View Source

Add(T)

Adds a key and value to the heap.

Declaration
public void Add(T item)
Parameters
Type Name Description
T item

The item to add to the heap.

| Edit this page View Source

Clear()

Removes all items from the heap.

Declaration
public void Clear()
| Edit this page View Source

Contains(T)

Checks to see if the binary heap contains the specified item.

Declaration
public bool Contains(T item)
Parameters
Type Name Description
T item

The item to search the binary heap for.

Returns
Type Description
bool

A boolean, true if binary heap contains item.

| Edit this page View Source

Copy()

Creates a new instance of an identical binary heap.

Declaration
public BinaryHeap<T> Copy()
Returns
Type Description
BinaryHeap<T>

A BinaryHeap.

| Edit this page View Source

CopyTo(T[], int)

Copies the binary heap to an array at the specified index.

Declaration
public void CopyTo(T[] array, int arrayIndex)
Parameters
Type Name Description
T[] array

One dimensional array that is the destination of the copied elements.

int arrayIndex

The zero-based index at which copying begins.

| Edit this page View Source

GetEnumerator()

Gets an enumerator for the binary heap.

Declaration
public IEnumerator<T> GetEnumerator()
Returns
Type Description
IEnumerator<T>

An IEnumerator of type T.

| Edit this page View Source

Peek()

Gets the first value in the heap without removing it.

Declaration
public T Peek()
Returns
Type Description
T

The lowest value of type TValue.

| Edit this page View Source

Remove()

Removes and returns the first item in the heap.

Declaration
public T Remove()
Returns
Type Description
T

The next value in the heap.

| Edit this page View Source

Remove(T)

Removes an item from the binary heap. This utilizes the type T's Comparer and will not remove duplicates.

Declaration
public bool Remove(T item)
Parameters
Type Name Description
T item

The item to be removed.

Returns
Type Description
bool

Boolean true if the item was removed.

Implements

ICollection<T>
IEnumerable<T>
IEnumerable

Extension Methods

ExpressionExtensions.AsOne<T>(T)
ObservableExtensions.WithUpdates<T>(ICollection<T>)
ChunkExtensions.ChunkIndexed<T, TResult>(IEnumerable<T>, int, Func<IEnumerableExpression<(T, int)>, int, TResult>)
ChunkExtensions.Chunk<T, TResult>(IEnumerable<T>, int, Func<IEnumerableExpression<T>, int, TResult>)
ObservableExtensions.WithUpdates<T>(IEnumerable<T>)
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX