type-indexed-queues-0.1.0.1: Queues with verified and unverified versions.

Safe HaskellSafe
LanguageHaskell2010

Data.Queue.Indexed.Class

Description

Classes for common functions between the heaps.

Synopsis

Documentation

class IndexedQueue h a where Source #

A classed for indexed priority queues. Equivalent to Queue except the queues are indexed by their sizes.

Minimal complete definition

insert, empty, minViewMay, minView

Methods

empty :: h 0 a Source #

The empty queue

minView :: h (1 + n) a -> (a, h n a) Source #

Return the minimal element, and the rest of the queue.

singleton :: a -> h 1 a Source #

A queue with one element.

insert :: a -> h n a -> h (1 + n) a Source #

Add an element to the queue.

minViewMay :: h n a -> (n ~ 0 => b) -> (forall m. (1 + m) ~ n => a -> h m a -> b) -> b Source #

Pattern match on the queue, and provide a proof that it is/isn't empty to the caller.

Instances

Ord a => IndexedQueue Leftist a Source # 

Methods

empty :: Leftist 0 a Source #

minView :: Leftist (1 + n) a -> (a, Leftist n a) Source #

singleton :: a -> Leftist 1 a Source #

insert :: a -> Leftist n a -> Leftist (1 + n) a Source #

minViewMay :: Leftist n a -> ((Nat ~ n) 0 -> b) -> (forall m. (Nat ~ (1 + m)) n => a -> Leftist m a -> b) -> b Source #

Ord a => IndexedQueue Pairing a Source # 

Methods

empty :: Pairing 0 a Source #

minView :: Pairing (1 + n) a -> (a, Pairing n a) Source #

singleton :: a -> Pairing 1 a Source #

insert :: a -> Pairing n a -> Pairing (1 + n) a Source #

minViewMay :: Pairing n a -> ((Nat ~ n) 0 -> b) -> (forall m. (Nat ~ (1 + m)) n => a -> Pairing m a -> b) -> b Source #

Ord a => IndexedQueue Skew a Source # 

Methods

empty :: Skew 0 a Source #

minView :: Skew (1 + n) a -> (a, Skew n a) Source #

singleton :: a -> Skew 1 a Source #

insert :: a -> Skew n a -> Skew (1 + n) a Source #

minViewMay :: Skew n a -> ((Nat ~ n) 0 -> b) -> (forall m. (Nat ~ (1 + m)) n => a -> Skew m a -> b) -> b Source #

IndexedQueue DiffList a Source # 

Methods

empty :: DiffList 0 a Source #

minView :: DiffList (1 + n) a -> (a, DiffList n a) Source #

singleton :: a -> DiffList 1 a Source #

insert :: a -> DiffList n a -> DiffList (1 + n) a Source #

minViewMay :: DiffList n a -> ((Nat ~ n) 0 -> b) -> (forall m. (Nat ~ (1 + m)) n => a -> DiffList m a -> b) -> b Source #

IndexedQueue List a Source # 

Methods

empty :: List 0 a Source #

minView :: List (1 + n) a -> (a, List n a) Source #

singleton :: a -> List 1 a Source #

insert :: a -> List n a -> List (1 + n) a Source #

minViewMay :: List n a -> ((Nat ~ n) 0 -> b) -> (forall m. (Nat ~ (1 + m)) n => a -> List m a -> b) -> b Source #

Ord a => IndexedQueue Braun a Source # 

Methods

empty :: Braun 0 a Source #

minView :: Braun (1 + n) a -> (a, Braun n a) Source #

singleton :: a -> Braun 1 a Source #

insert :: a -> Braun n a -> Braun (1 + n) a Source #

minViewMay :: Braun n a -> ((Nat ~ n) 0 -> b) -> (forall m. (Nat ~ (1 + m)) n => a -> Braun m a -> b) -> b Source #

Ord a => IndexedQueue (Binomial 0) a Source # 

Methods

empty :: Binomial 0 0 a Source #

minView :: Binomial 0 (1 + n) a -> (a, Binomial 0 n a) Source #

singleton :: a -> Binomial 0 1 a Source #

insert :: a -> Binomial 0 n a -> Binomial 0 (1 + n) a Source #

minViewMay :: Binomial 0 n a -> ((Nat ~ n) 0 -> b) -> (forall m. (Nat ~ (1 + m)) n => a -> Binomial 0 m a -> b) -> b Source #

class IndexedQueue h a => MeldableIndexedQueue h a where Source #

Queues which can be merged. Conforming members should form a monoid under merge and empty.

Minimal complete definition

merge

Methods

merge :: h n a -> h m a -> h (n + m) a Source #

Merge two heaps. This operation is associative, and has the identity of empty.

merge x (merge y z) = merge (merge x y) z
merge x empty = merge empty x = x

Instances

Ord a => MeldableIndexedQueue Leftist a Source # 

Methods

merge :: Leftist n a -> Leftist m a -> Leftist (n + m) a Source #

Ord a => MeldableIndexedQueue Pairing a Source # 

Methods

merge :: Pairing n a -> Pairing m a -> Pairing (n + m) a Source #

Ord a => MeldableIndexedQueue Skew a Source # 

Methods

merge :: Skew n a -> Skew m a -> Skew (n + m) a Source #

MeldableIndexedQueue DiffList a Source #

Performs merging in reverse order.

Methods

merge :: DiffList n a -> DiffList m a -> DiffList (n + m) a Source #

MeldableIndexedQueue List a Source # 

Methods

merge :: List n a -> List m a -> List (n + m) a Source #

Ord a => MeldableIndexedQueue (Binomial 0) a Source # 

Methods

merge :: Binomial 0 n a -> Binomial 0 m a -> Binomial 0 (n + m) a Source #