From a646a997acc9cf6bba70c0af4452f6b33ecb009c Mon Sep 17 00:00:00 2001 From: konsumlamm Date: Thu, 4 Dec 2025 16:27:05 +0100 Subject: [PATCH 1/2] Remove `insertBehind` --- CHANGELOG.md | 2 ++ src/Data/PQueue/Prio/Internals.hs | 17 ----------------- src/Data/PQueue/Prio/Max.hs | 1 - src/Data/PQueue/Prio/Max/Internals.hs | 9 --------- src/Data/PQueue/Prio/Min.hs | 1 - 5 files changed, 2 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d79032..5d90532 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 1.7.0.0 +* Remove `insertBehind` + * Change `Read` and `Show` instances to use `fromList` ([#144](https://github.com/lspitzner/pqueue/issues/144)) diff --git a/src/Data/PQueue/Prio/Internals.hs b/src/Data/PQueue/Prio/Internals.hs index a6ce92c..bf89b48 100644 --- a/src/Data/PQueue/Prio/Internals.hs +++ b/src/Data/PQueue/Prio/Internals.hs @@ -17,7 +17,6 @@ module Data.PQueue.Prio.Internals ( size, singleton, insert, - insertBehind, insertEager, union, getMin, @@ -235,22 +234,6 @@ insertEager k a (MinPQ n k' a' ts) | k <= k' = MinPQ (n + 1) k a (insertEagerHeap k' a' ts) | otherwise = MinPQ (n + 1) k' a' (insertEagerHeap k a ts) --- | \(O(n)\) (an earlier implementation had \(O(1)\) but was buggy). --- Insert an element with the specified key into the priority queue, --- putting it behind elements whose key compares equal to the --- inserted one. -{-# DEPRECATED insertBehind "This function is not reliable." #-} -insertBehind :: Ord k => k -> a -> MinPQueue k a -> MinPQueue k a -insertBehind k v q = - let (smaller, larger) = spanKey (<= k) q - in foldr (uncurry insert) (insert k v larger) smaller - -spanKey :: Ord k => (k -> Bool) -> MinPQueue k a -> ([(k, a)], MinPQueue k a) -spanKey p q = case minViewWithKey q of - Just (t@(k, _), q') | p k -> - let (kas, q'') = spanKey p q' in (t : kas, q'') - _ -> ([], q) - -- | Amortized \(O(\log \min(n_1,n_2))\), worst-case \(O(\log \max(n_1,n_2))\). Returns the union -- of the two specified queues. union :: Ord k => MinPQueue k a -> MinPQueue k a -> MinPQueue k a diff --git a/src/Data/PQueue/Prio/Max.hs b/src/Data/PQueue/Prio/Max.hs index 1bc39d6..cb22c52 100644 --- a/src/Data/PQueue/Prio/Max.hs +++ b/src/Data/PQueue/Prio/Max.hs @@ -32,7 +32,6 @@ module Data.PQueue.Prio.Max ( empty, singleton, insert, - insertBehind, union, unions, -- * Query diff --git a/src/Data/PQueue/Prio/Max/Internals.hs b/src/Data/PQueue/Prio/Max/Internals.hs index 8d9d994..b23e0d6 100644 --- a/src/Data/PQueue/Prio/Max/Internals.hs +++ b/src/Data/PQueue/Prio/Max/Internals.hs @@ -20,7 +20,6 @@ module Data.PQueue.Prio.Max.Internals ( empty, singleton, insert, - insertBehind, union, unions, -- * Query @@ -218,14 +217,6 @@ singleton = coerce Q.singleton insert :: Ord k => k -> a -> MaxPQueue k a -> MaxPQueue k a insert = coerce Q.insert --- | \(O(n)\) (an earlier implementation had \(O(1)\) but was buggy). --- Insert an element with the specified key into the priority queue, --- putting it behind elements whose key compares equal to the --- inserted one. -{-# DEPRECATED insertBehind "This function is not reliable." #-} -insertBehind :: Ord k => k -> a -> MaxPQueue k a -> MaxPQueue k a -insertBehind = coerce Q.insertBehind - -- | Amortized \(O(\log \min(n_1,n_2))\), worst-case \(O(\log \max(n_1,n_2))\). Returns the union -- of the two specified queues. union :: Ord k => MaxPQueue k a -> MaxPQueue k a -> MaxPQueue k a diff --git a/src/Data/PQueue/Prio/Min.hs b/src/Data/PQueue/Prio/Min.hs index bf39e3e..38f5be8 100644 --- a/src/Data/PQueue/Prio/Min.hs +++ b/src/Data/PQueue/Prio/Min.hs @@ -42,7 +42,6 @@ module Data.PQueue.Prio.Min ( empty, singleton, insert, - insertBehind, union, unions, -- * Query From 112046285a2432a72bf427cb5a6eedddf131042b Mon Sep 17 00:00:00 2001 From: konsumlamm Date: Thu, 4 Dec 2025 16:40:26 +0100 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d90532..917ee38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 1.7.0.0 -* Remove `insertBehind` +* Remove `insertBehind` ([#145](https://github.com/lspitzner/pqueue/pull/145)) * Change `Read` and `Show` instances to use `fromList` ([#144](https://github.com/lspitzner/pqueue/issues/144))