@@ -98,7 +98,7 @@ import Data.Semigroup (Semigroup((<>)))
9898import qualified Data.List as List
9999
100100import qualified BinomialQueue.Min as MinQ
101- import Data.PQueue.Internals.Down
101+ import Data.Ord ( Down ( .. ))
102102
103103#ifdef __GLASGOW_HASKELL__
104104import GHC.Exts (build )
@@ -115,7 +115,7 @@ findMax = fromMaybe (error "Error: findMax called on empty queue") . getMax
115115
116116-- | \(O(1)\). The top (maximum) element of the queue, if there is one.
117117getMax :: Ord a => MaxQueue a -> Maybe a
118- getMax (MaxQueue q) = unDown <$> MinQ. getMin q
118+ getMax (MaxQueue q) = getDown <$> MinQ. getMin q
119119
120120-- | \(O(\log n)\). Deletes the maximum element. If the queue is empty, does nothing.
121121deleteMax :: Ord a => MaxQueue a -> MaxQueue a
@@ -142,19 +142,19 @@ q !! n = (List.!!) (toDescList q) n
142142-- | 'takeWhile', applied to a predicate @p@ and a queue @queue@, returns the
143143-- longest prefix (possibly empty) of @queue@ of elements that satisfy @p@.
144144takeWhile :: Ord a => (a -> Bool ) -> MaxQueue a -> [a ]
145- takeWhile p = fmap unDown . MinQ. takeWhile (p . unDown ) . unMaxQueue
145+ takeWhile p = fmap getDown . MinQ. takeWhile (p . getDown ) . unMaxQueue
146146
147147-- | 'dropWhile' @p queue@ returns the queue remaining after 'takeWhile' @p queue@.
148148dropWhile :: Ord a => (a -> Bool ) -> MaxQueue a -> MaxQueue a
149- dropWhile p = MaxQueue . MinQ. dropWhile (p . unDown ) . unMaxQueue
149+ dropWhile p = MaxQueue . MinQ. dropWhile (p . getDown ) . unMaxQueue
150150
151151-- | 'span', applied to a predicate @p@ and a queue @queue@, returns a tuple where
152152-- first element is longest prefix (possibly empty) of @queue@ of elements that
153153-- satisfy @p@ and second element is the remainder of the queue.
154154span :: Ord a => (a -> Bool ) -> MaxQueue a -> ([a ], MaxQueue a )
155155span p (MaxQueue queue)
156- | (front, rear) <- MinQ. span (p . unDown ) queue
157- = (fmap unDown front, MaxQueue rear)
156+ | (front, rear) <- MinQ. span (p . getDown ) queue
157+ = (fmap getDown front, MaxQueue rear)
158158
159159-- | 'break', applied to a predicate @p@ and a queue @queue@, returns a tuple where
160160-- first element is longest prefix (possibly empty) of @queue@ of elements that
@@ -177,19 +177,19 @@ drop n (MaxQueue queue) = MaxQueue (MinQ.drop n queue)
177177splitAt :: Ord a => Int -> MaxQueue a -> ([a ], MaxQueue a )
178178splitAt n (MaxQueue queue)
179179 | (l, r) <- MinQ. splitAt n queue
180- = (fmap unDown l, MaxQueue r)
180+ = (fmap getDown l, MaxQueue r)
181181
182182-- | \(O(n)\). Returns the queue with all elements not satisfying @p@ removed.
183183filter :: Ord a => (a -> Bool ) -> MaxQueue a -> MaxQueue a
184- filter p = MaxQueue . MinQ. filter (p . unDown ) . unMaxQueue
184+ filter p = MaxQueue . MinQ. filter (p . getDown ) . unMaxQueue
185185
186186-- | \(O(n)\). Returns a pair where the first queue contains all elements satisfying @p@, and the second queue
187187-- contains all elements not satisfying @p@.
188188partition :: Ord a => (a -> Bool ) -> MaxQueue a -> (MaxQueue a , MaxQueue a )
189189partition p = go . unMaxQueue
190190 where
191191 go queue
192- | (l, r) <- MinQ. partition (p . unDown ) queue
192+ | (l, r) <- MinQ. partition (p . getDown ) queue
193193 = (MaxQueue l, MaxQueue r)
194194
195195-- | \(O(n)\). Creates a new priority queue containing the images of the elements of this queue.
@@ -202,13 +202,13 @@ map f = MaxQueue . MinQ.map (fmap f) . unMaxQueue
202202--
203203-- If the order of the elements is irrelevant, consider using 'toListU'.
204204toList :: Ord a => MaxQueue a -> [a ]
205- toList = fmap unDown . MinQ. toAscList . unMaxQueue
205+ toList = fmap getDown . MinQ. toAscList . unMaxQueue
206206
207207toAscList :: Ord a => MaxQueue a -> [a ]
208- toAscList = fmap unDown . MinQ. toDescList . unMaxQueue
208+ toAscList = fmap getDown . MinQ. toDescList . unMaxQueue
209209
210210toDescList :: Ord a => MaxQueue a -> [a ]
211- toDescList = fmap unDown . MinQ. toAscList . unMaxQueue
211+ toDescList = fmap getDown . MinQ. toAscList . unMaxQueue
212212
213213-- | \(O(n \log n)\). Performs a right fold on the elements of a priority queue in descending order.
214214foldrDesc :: Ord a => (a -> b -> b ) -> b -> MaxQueue a -> b
@@ -245,7 +245,7 @@ elemsU = toListU
245245
246246-- | Convert to a list in an arbitrary order.
247247toListU :: MaxQueue a -> [a ]
248- toListU = fmap unDown . MinQ. toListU . unMaxQueue
248+ toListU = fmap getDown . MinQ. toListU . unMaxQueue
249249
250250-- | Get the number of elements in a 'MaxQueue'.
251251size :: MaxQueue a -> Int
@@ -255,7 +255,7 @@ empty :: MaxQueue a
255255empty = MaxQueue MinQ. empty
256256
257257foldMapU :: Monoid m => (a -> m ) -> MaxQueue a -> m
258- foldMapU f = MinQ. foldMapU (f . unDown ) . unMaxQueue
258+ foldMapU f = MinQ. foldMapU (f . getDown ) . unMaxQueue
259259
260260seqSpine :: MaxQueue a -> b -> b
261261seqSpine = MinQ. seqSpine . unMaxQueue
@@ -267,7 +267,7 @@ foldlU' :: (b -> a -> b) -> b -> MaxQueue a -> b
267267foldlU' f b = MinQ. foldlU' (\ acc (Down a) -> f acc a) b . unMaxQueue
268268
269269foldrU :: (a -> b -> b ) -> b -> MaxQueue a -> b
270- foldrU c n = MinQ. foldrU (c . unDown ) n . unMaxQueue
270+ foldrU c n = MinQ. foldrU (c . getDown ) n . unMaxQueue
271271
272272null :: MaxQueue a -> Bool
273273null = MinQ. null . unMaxQueue
@@ -276,13 +276,13 @@ singleton :: a -> MaxQueue a
276276singleton = MaxQueue . MinQ. singleton . Down
277277
278278mapMaybe :: Ord b => (a -> Maybe b ) -> MaxQueue a -> MaxQueue b
279- mapMaybe f = MaxQueue . MinQ. mapMaybe (fmap Down . f . unDown ) . unMaxQueue
279+ mapMaybe f = MaxQueue . MinQ. mapMaybe (fmap Down . f . getDown ) . unMaxQueue
280280
281281insert :: Ord a => a -> MaxQueue a -> MaxQueue a
282282insert a (MaxQueue q) = MaxQueue (MinQ. insert (Down a) q)
283283
284284mapEither :: (Ord b , Ord c ) => (a -> Either b c ) -> MaxQueue a -> (MaxQueue b , MaxQueue c )
285- mapEither f (MaxQueue q) = case MinQ. mapEither (bimap Down Down . f . unDown ) q of
285+ mapEither f (MaxQueue q) = case MinQ. mapEither (bimap Down Down . f . getDown ) q of
286286 (l, r) -> (MaxQueue l, MaxQueue r)
287287
288288union :: Ord a => MaxQueue a -> MaxQueue a -> MaxQueue a
0 commit comments