fsprojects/FSharpx.Collections


Heap

Namespace: FSharpx.Collections

Functions and values

Function or valueDescription
empty isDescending
Signature: isDescending:bool -> Heap<'T>
Type parameters: 'T

O(1). Returns a empty heap.

head xs
Signature: xs:Heap<'T> -> 'T
Type parameters: 'T

O(1) worst case. Returns the min or max element.

insert x xs
Signature: x:'T -> xs:Heap<'T> -> Heap<'T>
Type parameters: 'T

O(log n) amortized time. Returns a new heap with the element inserted.

isDescending xs
Signature: xs:Heap<'T> -> bool
Type parameters: 'T

O(1). Returns true if the heap has max element at head.

isEmpty xs
Signature: xs:Heap<'T> -> bool
Type parameters: 'T

O(1). Returns true if the heap has no elements.

length xs
Signature: xs:Heap<'T> -> int
Type parameters: 'T

O(n). Returns the count of elememts.

merge xs ys
Signature: xs:Heap<'T> -> ys:Heap<'T> -> Heap<'T>
Type parameters: 'T

O(log n) amortized time. Returns heap from merging two heaps, both must have same descending.

ofSeq isDescending s
Signature: isDescending:bool -> s:seq<'T> -> Heap<'T>
Type parameters: 'T

O(n log n). Returns heap, bool isDescending, from the sequence.

rev xs
Signature: xs:Heap<'T> -> Heap<'T>
Type parameters: 'T

O(n). Returns heap reversed.

tail xs
Signature: xs:Heap<'T> -> Heap<'T>
Type parameters: 'T

O(log n) amortized time. Returns a new heap of the elements trailing the head.

toSeq xs
Signature: xs:Heap<'T> -> seq<'T>
Type parameters: 'T

O(n). Views the given heap as a sequence.

tryHead xs
Signature: xs:Heap<'T> -> 'T option
Type parameters: 'T

O(1) worst case. Returns option first min or max element.

tryMerge xs ys
Signature: xs:Heap<'T> -> ys:Heap<'T> -> Heap<'T> option
Type parameters: 'T

O(log n) amortized time. Returns heap option from merging two heaps.

tryTail xs
Signature: xs:Heap<'T> -> Heap<'T> option
Type parameters: 'T

O(log n) amortized time. Returns option heap of the elements trailing the head.

tryUncons xs
Signature: xs:Heap<'T> -> ('T * Heap<'T>) option
Type parameters: 'T

O(log n) amortized time. Returns option head element and tail.

uncons xs
Signature: xs:Heap<'T> -> 'T * Heap<'T>
Type parameters: 'T

O(log n) amortized time. Returns the head element and tail.

Active patterns

Active patternDescription
( |Cons|Nil| ) h
Signature: h:Heap<'T> -> Choice<('T * Heap<'T>),unit>
Type parameters: 'T

CompiledName: |Cons|Nil|

Fork me on GitHub