Copyright | (c) Eric Mertens 2018 |
---|---|
License | ISC |
Maintainer | emertens@gmail.com |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Priority queue with Int
priorities returning smallest priority first.
Synopsis
- newtype PQueue a = PQ (IntMap [a])
- pattern Empty :: PQueue a
- pattern (:<|) :: a -> PQueue a -> PQueue a
- null :: PQueue a -> Bool
- singleton :: Int -> a -> PQueue a
- insert :: Int -> a -> PQueue a -> PQueue a
- view :: PQueue a -> Maybe (a, PQueue a)
- viewWithPriority :: PQueue a -> Maybe (Int, a, PQueue a)
- fromList :: [(Int, a)] -> PQueue a
Documentation
Priority queue. No guarantees are made regarding the order entries with the same priority are returned in.
Instances
Functor PQueue Source # | |
Foldable PQueue Source # | |
Defined in Advent.PQueue fold :: Monoid m => PQueue m -> m # foldMap :: Monoid m => (a -> m) -> PQueue a -> m # foldMap' :: Monoid m => (a -> m) -> PQueue a -> m # foldr :: (a -> b -> b) -> b -> PQueue a -> b # foldr' :: (a -> b -> b) -> b -> PQueue a -> b # foldl :: (b -> a -> b) -> b -> PQueue a -> b # foldl' :: (b -> a -> b) -> b -> PQueue a -> b # foldr1 :: (a -> a -> a) -> PQueue a -> a # foldl1 :: (a -> a -> a) -> PQueue a -> a # elem :: Eq a => a -> PQueue a -> Bool # maximum :: Ord a => PQueue a -> a # minimum :: Ord a => PQueue a -> a # | |
Traversable PQueue Source # | |
Read a => Read (PQueue a) Source # | |
Show a => Show (PQueue a) Source # |
|
pattern (:<|) :: a -> PQueue a -> PQueue a Source #
Pattern for extracting an element with the minimum priority
from the queue. See also: view
Construct a priority queue from a single priority and value.
Insert a new value into the queue given a priority.
view :: PQueue a -> Maybe (a, PQueue a) Source #
Match the lowest priority entry in a queue returning the corresponding
value and queue without that entry. See also: (:<|
)