Safe Haskell | Trustworthy |
---|---|

Language | Haskell2010 |

Space-efficient queues with amortized \( O(\log n) \) operations. These directly use an underlying array-based implementation, without doing any special optimization for the first few and last few elements of the queue.

# Documentation

A queue.

pattern Empty :: Queue a | A bidirectional pattern synonym for the empty queue. |

pattern (:<) :: a -> Queue a -> Queue a infixr 5 | A unidirectional pattern synonym for viewing the front of a queue. |

## Instances

Functor Queue Source # | |

Foldable Queue Source # | |

Defined in Data.CompactSequence.Queue.Simple.Internal fold :: Monoid m => Queue m -> m # foldMap :: Monoid m => (a -> m) -> Queue a -> m # foldr :: (a -> b -> b) -> b -> Queue a -> b # foldr' :: (a -> b -> b) -> b -> Queue a -> b # foldl :: (b -> a -> b) -> b -> Queue a -> b # foldl' :: (b -> a -> b) -> b -> Queue a -> b # foldr1 :: (a -> a -> a) -> Queue a -> a # foldl1 :: (a -> a -> a) -> Queue a -> a # elem :: Eq a => a -> Queue a -> Bool # maximum :: Ord a => Queue a -> a # minimum :: Ord a => Queue a -> a # | |

Traversable Queue Source # | |

IsList (Queue a) Source # | |

Eq a => Eq (Queue a) Source # | |

Ord a => Ord (Queue a) Source # | |

Defined in Data.CompactSequence.Queue.Simple.Internal | |

Show a => Show (Queue a) Source # | |

Semigroup (Queue a) Source # | |

Monoid (Queue a) Source # | |

type Item (Queue a) Source # | |

Defined in Data.CompactSequence.Queue.Simple.Internal |

take :: Int -> Queue a -> Queue a Source #

Take up to the given number of elements from the front of a queue to form a new queue. \( O(\min (k, n)) \), where \( k \) is the integer argument and \( n \) is the size of the queue.

fromList :: [a] -> Queue a Source #

\( O(n \log n) \). Convert a list to a `Queue`

, with the head of the
list at the front of the queue.

fromListN :: Int -> [a] -> Queue a Source #

\( O(n) \). Convert a list of the given size to a `Queue`

, with the
head of the list at the front of the queue.

fromListNIncremental :: Int -> [a] -> Queue a Source #

\( O(n) \). Convert a list of the given size to a `Queue`

, with the
head of the list at the front of the queue. Unlike `fromListN`

,
the conversion is performed incrementally. This is generally
beneficial if the list is represented compactly (e.g., an enumeration)
or when it's otherwise not important to consume the entire list
immediately.