Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 1.7.0.0

* 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))

Expand Down
17 changes: 0 additions & 17 deletions src/Data/PQueue/Prio/Internals.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ module Data.PQueue.Prio.Internals (
size,
singleton,
insert,
insertBehind,
insertEager,
union,
getMin,
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/Data/PQueue/Prio/Max.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ module Data.PQueue.Prio.Max (
empty,
singleton,
insert,
insertBehind,
union,
unions,
-- * Query
Expand Down
9 changes: 0 additions & 9 deletions src/Data/PQueue/Prio/Max/Internals.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ module Data.PQueue.Prio.Max.Internals (
empty,
singleton,
insert,
insertBehind,
union,
unions,
-- * Query
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/Data/PQueue/Prio/Min.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ module Data.PQueue.Prio.Min (
empty,
singleton,
insert,
insertBehind,
union,
unions,
-- * Query
Expand Down
Loading