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

Language | Haskell98 |

- data IntPSQ p v
- null :: IntPSQ p v -> Bool
- size :: IntPSQ p v -> Int
- member :: Int -> IntPSQ p v -> Bool
- lookup :: Int -> IntPSQ p v -> Maybe (p, v)
- findMin :: Ord p => IntPSQ p v -> Maybe (Int, p, v)
- empty :: IntPSQ p v
- singleton :: Ord p => Int -> p -> v -> IntPSQ p v
- insert :: Ord p => Int -> p -> v -> IntPSQ p v -> IntPSQ p v
- delete :: Ord p => Int -> IntPSQ p v -> IntPSQ p v
- deleteMin :: Ord p => IntPSQ p v -> IntPSQ p v
- alter :: Ord p => (Maybe (p, v) -> (b, Maybe (p, v))) -> Int -> IntPSQ p v -> (b, IntPSQ p v)
- alterMin :: Ord p => (Maybe (Int, p, v) -> (b, Maybe (Int, p, v))) -> IntPSQ p v -> (b, IntPSQ p v)
- fromList :: Ord p => [(Int, p, v)] -> IntPSQ p v
- toList :: IntPSQ p v -> [(Int, p, v)]
- keys :: IntPSQ p v -> [Int]
- insertView :: Ord p => Int -> p -> v -> IntPSQ p v -> (Maybe (p, v), IntPSQ p v)
- deleteView :: Ord p => Int -> IntPSQ p v -> Maybe (p, v, IntPSQ p v)
- minView :: Ord p => IntPSQ p v -> Maybe (Int, p, v, IntPSQ p v)
- atMostView :: Ord p => p -> IntPSQ p v -> ([(Int, p, v)], IntPSQ p v)
- map :: (Int -> p -> v -> w) -> IntPSQ p v -> IntPSQ p w
- fold' :: (Int -> p -> v -> a -> a) -> a -> IntPSQ p v -> a
- valid :: Ord p => IntPSQ p v -> Bool

# Type

A priority search queue with `Int`

keys and priorities of type `p`

and
values of type `v`

. It is strict in keys, priorities and values.

# Query

lookup :: Int -> IntPSQ p v -> Maybe (p, v) #

*O(min(n,W))* The priority and value of a given key, or `Nothing`

if the
key is not bound.

# Construction

# Insertion

insert :: Ord p => Int -> p -> v -> IntPSQ p v -> IntPSQ p v #

*O(min(n,W))* Insert a new key, priority and value into the queue. If the key
is already present in the queue, the associated priority and value are
replaced with the supplied priority and value.

# Delete/update

delete :: Ord p => Int -> IntPSQ p v -> IntPSQ p v #

*O(min(n,W))* Delete a key and its priority and value from the queue. When
the key is not a member of the queue, the original queue is returned.

deleteMin :: Ord p => IntPSQ p v -> IntPSQ p v #

*O(min(n,W))* Delete the binding with the least priority, and return the
rest of the queue stripped of that binding. In case the queue is empty, the
empty queue is returned again.

alter :: Ord p => (Maybe (p, v) -> (b, Maybe (p, v))) -> Int -> IntPSQ p v -> (b, IntPSQ p v) #

*O(min(n,W))* The expression `alter f k queue`

alters the value `x`

at `k`

,
or absence thereof. `alter`

can be used to insert, delete, or update a value
in a queue. It also allows you to calculate an additional value `b`

.

alterMin :: Ord p => (Maybe (Int, p, v) -> (b, Maybe (Int, p, v))) -> IntPSQ p v -> (b, IntPSQ p v) #

# Lists

fromList :: Ord p => [(Int, p, v)] -> IntPSQ p v #

*O(n*min(n,W))* Build a queue from a list of (key, priority, value) tuples.
If the list contains more than one priority and value for the same key, the
last priority and value for the key is retained.

toList :: IntPSQ p v -> [(Int, p, v)] #

*O(n)* Convert a queue to a list of (key, priority, value) tuples. The
order of the list is not specified.

# Views

insertView :: Ord p => Int -> p -> v -> IntPSQ p v -> (Maybe (p, v), IntPSQ p v) #

*O(min(n,W))* Insert a new key, priority and value into the queue. If the key
is already present in the queue, then the evicted priority and value can be
found the first element of the returned tuple.

deleteView :: Ord p => Int -> IntPSQ p v -> Maybe (p, v, IntPSQ p v) #

*O(min(n,W))* Delete a key and its priority and value from the queue. If
the key was present, the associated priority and value are returned in
addition to the updated queue.

minView :: Ord p => IntPSQ p v -> Maybe (Int, p, v, IntPSQ p v) #

*O(min(n,W))* Retrieve the binding with the least priority, and the
rest of the queue stripped of that binding.

atMostView :: Ord p => p -> IntPSQ p v -> ([(Int, p, v)], IntPSQ p v) #

Return a list of elements ordered by key whose priorities are at most `pt`

,
and the rest of the queue stripped of these elements. The returned list of
elements can be in any order: no guarantees there.

# Traversal

fold' :: (Int -> p -> v -> a -> a) -> a -> IntPSQ p v -> a #

*O(n)* Strict fold over every key, priority and value in the queue. The order
in which the fold is performed is not specified.