summaryrefslogtreecommitdiff
path: root/libraries/base/GHC/Event/PSQ.hs
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/base/GHC/Event/PSQ.hs')
-rw-r--r--libraries/base/GHC/Event/PSQ.hs21
1 files changed, 3 insertions, 18 deletions
diff --git a/libraries/base/GHC/Event/PSQ.hs b/libraries/base/GHC/Event/PSQ.hs
index 976ffe16b3..6e13839491 100644
--- a/libraries/base/GHC/Event/PSQ.hs
+++ b/libraries/base/GHC/Event/PSQ.hs
@@ -28,7 +28,7 @@ module GHC.Event.PSQ
, singleton
-- * Insertion
- , insert
+ , unsafeInsertNew
-- * Delete/Update
, delete
@@ -36,7 +36,6 @@ module GHC.Event.PSQ
-- * Conversion
, toList
- , fromList
-- * Min
, findMin
@@ -58,7 +57,7 @@ import GHC.Types (Int)
{-
-- Use macros to define strictness of functions.
--- STRICT_x_OF_y denotes an y-ary function strict in the x-th parameter.
+-- STRICT_x_OF_y denotes a y-ary function strict in the x-th parameter.
-- We do not use BangPatterns, because they are not in any standard and we
-- want the compilers to be compiled by as many compilers as possible.
#define STRICT_1_OF_2(fn) fn arg _ | arg `seq` False = undefined
@@ -213,14 +212,7 @@ singleton = Tip
-- Insertion
------------------------------------------------------------------------------
--- | /O(min(n,W))/ Insert a new key, priority and value into the queue. If the key
--- is already present in the queue, the associated priority and value are
--- replaced with the supplied priority and value.
-insert :: Key -> Prio -> v -> IntPSQ v -> IntPSQ v
-insert k p x t0 = unsafeInsertNew k p x (delete k t0)
-
--- | Internal function to insert a key that is *not* present in the priority
--- queue.
+-- | /O(min(n,W))/ Insert a new key that is *not* present in the priority queue.
{-# INLINABLE unsafeInsertNew #-}
unsafeInsertNew :: Key -> Prio -> v -> IntPSQ v -> IntPSQ v
unsafeInsertNew k p x = go
@@ -340,13 +332,6 @@ binShrinkR k p x m l r = Bin k p x m l r
-- Lists
------------------------------------------------------------------------------
--- | /O(n*min(n,W))/ Build a queue from a list of (key, priority, value) tuples.
--- If the list contains more than one priority and value for the same key, the
--- last priority and value for the key is retained.
-{-# INLINABLE fromList #-}
-fromList :: [Elem v] -> IntPSQ v
-fromList = foldr (\(E k p x) im -> insert k p x im) empty
-
-- | /O(n)/ Convert a queue to a list of (key, priority, value) tuples. The
-- order of the list is not specified.
toList :: IntPSQ v -> [Elem v]