TreeStructures-0.0.2: A collection of heaps and search trees
Safe HaskellSafe-Inferred
LanguageHaskell98

Data.Heap.Binary

Description

Binary provides a binary min-heap. Balance is maintained through descendant counting.

Synopsis

Documentation

data Ord n => BinaryHeap n Source #

Instances

Instances details
(Ord n, Show n) => Show (BinaryHeap n) Source # 
Instance details

Defined in Data.Heap.Binary

Ord n => Eq (BinaryHeap n) Source # 
Instance details

Defined in Data.Heap.Binary

Methods

(==) :: BinaryHeap n -> BinaryHeap n -> Bool #

(/=) :: BinaryHeap n -> BinaryHeap n -> Bool #

Ord n => Ord (BinaryHeap n) Source # 
Instance details

Defined in Data.Heap.Binary

head :: Ord a => BinaryHeap a -> a Source #

O(1). head returns the element root of the heap.

tail :: Ord a => BinaryHeap a -> BinaryHeap a Source #

O(lg n). tail discards the root of the heap and merges the subtrees.

merge :: Ord a => BinaryHeap a -> BinaryHeap a -> BinaryHeap a Source #

merge consumes two binary heaps and merges them.

singleton :: Ord a => a -> BinaryHeap a Source #

O(1). singleton consumes an element and constructs a singleton heap.

empty :: Ord a => BinaryHeap a Source #

O(1). empty produces an empty heap.

null :: Ord a => BinaryHeap a -> Bool Source #

O(1).

fromList :: Ord a => [a] -> BinaryHeap a Source #

O(n). fromList constructs a binary heap from an unsorted list.

toList :: Ord a => BinaryHeap a -> [a] Source #

O(n lg n).

insert :: Ord a => a -> BinaryHeap a -> BinaryHeap a Source #

O(lg n).