Copyright | (c) Masahiro Sakai 2012 |
---|---|
License | BSD-style |
Maintainer | masahiro.sakai@gmail.com |
Stability | provisional |
Portability | non-portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Extensions |
|
Priority queue implemented as array-based binary heap.
Synopsis
- data PriorityQueue
- type Value = Int
- type Index = Int
- newPriorityQueue :: IO PriorityQueue
- newPriorityQueueBy :: (Value -> Value -> IO Bool) -> IO PriorityQueue
- class Monad m => NewFifo q (m :: Type -> Type) where
- newFifo :: m q
- getElems :: PriorityQueue -> IO [Value]
- clear :: PriorityQueue -> IO ()
- clone :: PriorityQueue -> IO PriorityQueue
- class Monad m => Enqueue q (m :: Type -> Type) a | q -> a where
- enqueue :: q -> a -> m ()
- enqueueBatch :: q -> [a] -> m ()
- class Monad m => Dequeue q (m :: Type -> Type) a | q -> a where
- dequeue :: q -> m (Maybe a)
- dequeueBatch :: q -> m [a]
- class Monad m => QueueSize q (m :: Type -> Type) where
- member :: PriorityQueue -> Value -> IO Bool
- update :: PriorityQueue -> Value -> IO ()
- rebuild :: PriorityQueue -> IO ()
- getHeapArray :: PriorityQueue -> IO (IOUArray Index Value)
- getHeapVec :: PriorityQueue -> IO (UVec Value)
- resizeHeapCapacity :: PriorityQueue -> Int -> IO ()
- resizeTableCapacity :: PriorityQueue -> Int -> IO ()
PriorityQueue type
data PriorityQueue Source #
Priority queue implemented as array-based binary heap.
Instances
NewFifo PriorityQueue IO Source # | |
Defined in ToySolver.Internal.Data.IndexedPriorityQueue newFifo :: IO PriorityQueue # | |
QueueSize PriorityQueue IO Source # | |
Defined in ToySolver.Internal.Data.IndexedPriorityQueue queueSize :: PriorityQueue -> IO Int # | |
Dequeue PriorityQueue IO Value Source # | |
Defined in ToySolver.Internal.Data.IndexedPriorityQueue dequeue :: PriorityQueue -> IO (Maybe Value) # dequeueBatch :: PriorityQueue -> IO [Value] # | |
Enqueue PriorityQueue IO Value Source # | |
Defined in ToySolver.Internal.Data.IndexedPriorityQueue enqueue :: PriorityQueue -> Value -> IO () # enqueueBatch :: PriorityQueue -> [Value] -> IO () # |
Constructors
newPriorityQueueBy :: (Value -> Value -> IO Bool) -> IO PriorityQueue Source #
Build a priority queue with a given less than operator.
class Monad m => NewFifo q (m :: Type -> Type) where #
Construct a new FIFO queue.
Instances
NewFifo PriorityQueue IO Source # | |
Defined in ToySolver.Internal.Data.IndexedPriorityQueue newFifo :: IO PriorityQueue # | |
Ord a => NewFifo (PriorityQueue a) IO Source # | |
Defined in ToySolver.Internal.Data.PriorityQueue newFifo :: IO (PriorityQueue a) # | |
PrimMonad m => NewFifo (SeqQueue m a) m Source # | |
Defined in ToySolver.Internal.Data.SeqQueue |
Operators
getElems :: PriorityQueue -> IO [Value] Source #
Return a list of all the elements of a priority queue. (not sorted)
clear :: PriorityQueue -> IO () Source #
Remove all elements from a priority queue.
clone :: PriorityQueue -> IO PriorityQueue Source #
Create a copy of a priority queue.
class Monad m => Enqueue q (m :: Type -> Type) a | q -> a where #
Put an item into a queue. May block while trying to do so.
No constraint is placed on the behavior of the queue except that
every item put in "really ought to" come out sometime before
dequeue
returns a Nothing
.
enqueueBatch :: q -> [a] -> m () #
Instances
Enqueue PriorityQueue IO Value Source # | |
Defined in ToySolver.Internal.Data.IndexedPriorityQueue enqueue :: PriorityQueue -> Value -> IO () # enqueueBatch :: PriorityQueue -> [Value] -> IO () # | |
Enqueue q m a => Enqueue (WQueue q) m a | |
Defined in Data.Queue | |
Enqueue (PriorityQueue a) IO a Source # | |
Defined in ToySolver.Internal.Data.PriorityQueue enqueue :: PriorityQueue a -> a -> IO () # enqueueBatch :: PriorityQueue a -> [a] -> IO () # | |
PrimMonad m => Enqueue (SeqQueue m a) m a Source # | |
Defined in ToySolver.Internal.Data.SeqQueue |
class Monad m => Dequeue q (m :: Type -> Type) a | q -> a where #
Pull an item out of a queue. Should not block. No ordering
constraints are implied other than that any item that went into
the queue "really ought to" come out before dequeue
returns
Nothing
.
dequeueBatch :: q -> m [a] #
Instances
Dequeue PriorityQueue IO Value Source # | |
Defined in ToySolver.Internal.Data.IndexedPriorityQueue dequeue :: PriorityQueue -> IO (Maybe Value) # dequeueBatch :: PriorityQueue -> IO [Value] # | |
Dequeue q m a => Dequeue (RQueue q) m a | |
Defined in Data.Queue | |
Dequeue (PriorityQueue a) IO a Source # | |
Defined in ToySolver.Internal.Data.PriorityQueue dequeue :: PriorityQueue a -> IO (Maybe a) # dequeueBatch :: PriorityQueue a -> IO [a] # | |
PrimMonad m => Dequeue (SeqQueue m a) m a Source # | |
Defined in ToySolver.Internal.Data.SeqQueue |
class Monad m => QueueSize q (m :: Type -> Type) where #
Instances
QueueSize PriorityQueue IO Source # | |
Defined in ToySolver.Internal.Data.IndexedPriorityQueue queueSize :: PriorityQueue -> IO Int # | |
QueueSize (PriorityQueue a) IO Source # | |
Defined in ToySolver.Internal.Data.PriorityQueue queueSize :: PriorityQueue a -> IO Int # | |
PrimMonad m => QueueSize (SeqQueue m a) m Source # | |
Defined in ToySolver.Internal.Data.SeqQueue |
rebuild :: PriorityQueue -> IO () Source #
getHeapArray :: PriorityQueue -> IO (IOUArray Index Value) Source #
Get the internal representation of a given priority queue.
getHeapVec :: PriorityQueue -> IO (UVec Value) Source #
Get the internal representation of a given priority queue.
Misc operations
resizeHeapCapacity :: PriorityQueue -> Int -> IO () Source #
Pre-allocate internal buffer for n
elements.
resizeTableCapacity :: PriorityQueue -> Int -> IO () Source #
Pre-allocate internal buffer for [0..n-1]
values.