
Is there a Haskell implementation of an efficient priority queue (probably heap-based) out there that I can use? I do not see it in the GHC libraries.

I recommend the Edison library, which has several heap implementations. http://www.eecs.tufts.edu/~rdocki01/edison.html Cheers, Spencer Janssen On Nov 26, 2006, at 3:58 PM, Ken Takusagawa wrote:
Is there a Haskell implementation of an efficient priority queue (probably heap-based) out there that I can use? I do not see it in the GHC libraries. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Ken Takusagawa wrote:
Is there a Haskell implementation of an efficient priority queue (probably heap-based) out there that I can use? I do not see it in the GHC libraries.
Unfortunately the base package contains only the specialized Data.Sequence and not the general annotated 2-3 finger trees, which could be easily instantiated to an efficient priority queue. I have a package lying around that I wrote 1 or 2 years ago that implements the (much more complicated) search tree version of the 2-3 finger trees. I just managed to compile it again. Can send you a tarball if you are interested. Ben

On Sun, Nov 26, 2006 at 04:58:13PM -0500, Ken Takusagawa wrote:
Is there a Haskell implementation of an efficient priority queue (probably heap-based) out there that I can use? I do not see it in the GHC libraries.
As already mentioned, there are several in Edison. If you want to roll your own, you can't get much simpler than Okasaki's lazy skew heaps, from "The Fun of Programming" (the Edison version is a specialized version of this): data Tree a = Null | Fork a (Tree a) (Tree a) isEmpty :: Tree a -> Bool isEmpty Null = True isEmpty _ = False minElem :: Tree a -> a minElem (Fork x a b) = x deleteMin :: Ord a => Tree a -> Tree a deleteMin (Fork x a b) = merge a b insert :: Ord a => a -> Tree a -> Tree a insert x a = merge (singleton x) a where singleton x = Fork x Null Null merge :: Ord a => Tree a -> Tree a -> Tree a merge a Null = a merge Null b = b merge a b | minElem a <= minElem b = join a b | otherwise = join b a where join (Fork x a b) c = Fork x b (merge a c)
participants (5)
-
Benjamin Franksen
-
Ken Takusagawa
-
mark@ixod.org
-
Ross Paterson
-
Spencer Janssen