@@ -327,11 +327,6 @@ module Data.Map.Internal (
327
327
, minViewWithKey
328
328
, maxViewWithKey
329
329
330
- -- * Debugging
331
- , showTree
332
- , showTreeWith
333
- , valid
334
-
335
330
-- Used by the strict version
336
331
, AreWeStrict (.. )
337
332
, atKeyImpl
@@ -340,7 +335,6 @@ module Data.Map.Internal (
340
335
#endif
341
336
, bin
342
337
, balance
343
- , balanced
344
338
, balanceL
345
339
, balanceR
346
340
, delta
@@ -380,13 +374,13 @@ import Prelude hiding (lookup, map, filter, foldr, foldl, null, splitAt, take, d
380
374
381
375
import qualified Data.Set.Internal as Set
382
376
import Data.Set.Internal (Set )
383
- import Data. Utils.PtrEquality (ptrEq )
384
- import Data. Utils.StrictFold
385
- import Data. Utils.StrictPair
386
- import Data. Utils.StrictMaybe
387
- import Data. Utils.BitQueue
377
+ import Utils.Containers.Internal .PtrEquality (ptrEq )
378
+ import Utils.Containers.Internal .StrictFold
379
+ import Utils.Containers.Internal .StrictPair
380
+ import Utils.Containers.Internal .StrictMaybe
381
+ import Utils.Containers.Internal .BitQueue
388
382
#if DEFINE_ALTERF_FALLBACK
389
- import Data. Utils.BitUtil (wordSize )
383
+ import Utils.Containers.Internal .BitUtil (wordSize )
390
384
#endif
391
385
392
386
#if __GLASGOW_HASKELL__
@@ -3961,148 +3955,12 @@ instance (Show k, Show a) => Show (Map k a) where
3961
3955
showsPrec d m = showParen (d > 10 ) $
3962
3956
showString " fromList " . shows (toList m)
3963
3957
3964
- -- | /O(n)/. Show the tree that implements the map. The tree is shown
3965
- -- in a compressed, hanging format. See 'showTreeWith'.
3966
- {-# DEPRECATED showTree "This function is being removed from the public API." #-}
3967
- showTree :: (Show k ,Show a ) => Map k a -> String
3968
- showTree m
3969
- = showTreeWith showElem True False m
3970
- where
3971
- showElem k x = show k ++ " :=" ++ show x
3972
-
3973
-
3974
- {- | /O(n)/. The expression (@'showTreeWith' showelem hang wide map@) shows
3975
- the tree that implements the map. Elements are shown using the @showElem@ function. If @hang@ is
3976
- 'True', a /hanging/ tree is shown otherwise a rotated tree is shown. If
3977
- @wide@ is 'True', an extra wide version is shown.
3978
-
3979
- > Map> let t = fromDistinctAscList [(x,()) | x <- [1..5]]
3980
- > Map> putStrLn $ showTreeWith (\k x -> show (k,x)) True False t
3981
- > (4,())
3982
- > +--(2,())
3983
- > | +--(1,())
3984
- > | +--(3,())
3985
- > +--(5,())
3986
- >
3987
- > Map> putStrLn $ showTreeWith (\k x -> show (k,x)) True True t
3988
- > (4,())
3989
- > |
3990
- > +--(2,())
3991
- > | |
3992
- > | +--(1,())
3993
- > | |
3994
- > | +--(3,())
3995
- > |
3996
- > +--(5,())
3997
- >
3998
- > Map> putStrLn $ showTreeWith (\k x -> show (k,x)) False True t
3999
- > +--(5,())
4000
- > |
4001
- > (4,())
4002
- > |
4003
- > | +--(3,())
4004
- > | |
4005
- > +--(2,())
4006
- > |
4007
- > +--(1,())
4008
-
4009
- -}
4010
- {-# DEPRECATED showTreeWith "This function is being removed from the public API." #-}
4011
- showTreeWith :: (k -> a -> String ) -> Bool -> Bool -> Map k a -> String
4012
- showTreeWith showelem hang wide t
4013
- | hang = (showsTreeHang showelem wide [] t) " "
4014
- | otherwise = (showsTree showelem wide [] [] t) " "
4015
-
4016
- showsTree :: (k -> a -> String ) -> Bool -> [String ] -> [String ] -> Map k a -> ShowS
4017
- showsTree showelem wide lbars rbars t
4018
- = case t of
4019
- Tip -> showsBars lbars . showString " |\n "
4020
- Bin _ kx x Tip Tip
4021
- -> showsBars lbars . showString (showelem kx x) . showString " \n "
4022
- Bin _ kx x l r
4023
- -> showsTree showelem wide (withBar rbars) (withEmpty rbars) r .
4024
- showWide wide rbars .
4025
- showsBars lbars . showString (showelem kx x) . showString " \n " .
4026
- showWide wide lbars .
4027
- showsTree showelem wide (withEmpty lbars) (withBar lbars) l
4028
-
4029
- showsTreeHang :: (k -> a -> String ) -> Bool -> [String ] -> Map k a -> ShowS
4030
- showsTreeHang showelem wide bars t
4031
- = case t of
4032
- Tip -> showsBars bars . showString " |\n "
4033
- Bin _ kx x Tip Tip
4034
- -> showsBars bars . showString (showelem kx x) . showString " \n "
4035
- Bin _ kx x l r
4036
- -> showsBars bars . showString (showelem kx x) . showString " \n " .
4037
- showWide wide bars .
4038
- showsTreeHang showelem wide (withBar bars) l .
4039
- showWide wide bars .
4040
- showsTreeHang showelem wide (withEmpty bars) r
4041
-
4042
- showWide :: Bool -> [String ] -> String -> String
4043
- showWide wide bars
4044
- | wide = showString (concat (reverse bars)) . showString " |\n "
4045
- | otherwise = id
4046
-
4047
- showsBars :: [String ] -> ShowS
4048
- showsBars bars
4049
- = case bars of
4050
- [] -> id
4051
- _ -> showString (concat (reverse (tail bars))) . showString node
4052
-
4053
- node :: String
4054
- node = " +--"
4055
-
4056
- withBar , withEmpty :: [String ] -> [String ]
4057
- withBar bars = " | " : bars
4058
- withEmpty bars = " " : bars
4059
-
4060
3958
{- -------------------------------------------------------------------
4061
3959
Typeable
4062
3960
--------------------------------------------------------------------}
4063
3961
4064
3962
INSTANCE_TYPEABLE2 (Map )
4065
3963
4066
- {- -------------------------------------------------------------------
4067
- Assertions
4068
- --------------------------------------------------------------------}
4069
- -- | /O(n)/. Test if the internal map structure is valid.
4070
- --
4071
- -- > valid (fromAscList [(3,"b"), (5,"a")]) == True
4072
- -- > valid (fromAscList [(5,"a"), (3,"b")]) == False
4073
-
4074
- valid :: Ord k => Map k a -> Bool
4075
- valid t
4076
- = balanced t && ordered t && validsize t
4077
-
4078
- ordered :: Ord a => Map a b -> Bool
4079
- ordered t
4080
- = bounded (const True ) (const True ) t
4081
- where
4082
- bounded lo hi t'
4083
- = case t' of
4084
- Tip -> True
4085
- Bin _ kx _ l r -> (lo kx) && (hi kx) && bounded lo (< kx) l && bounded (> kx) hi r
4086
-
4087
- -- | Exported only for "Debug.QuickCheck"
4088
- balanced :: Map k a -> Bool
4089
- balanced t
4090
- = case t of
4091
- Tip -> True
4092
- Bin _ _ _ l r -> (size l + size r <= 1 || (size l <= delta* size r && size r <= delta* size l)) &&
4093
- balanced l && balanced r
4094
-
4095
- validsize :: Map a b -> Bool
4096
- validsize t
4097
- = (realsize t == Just (size t))
4098
- where
4099
- realsize t'
4100
- = case t' of
4101
- Tip -> Just 0
4102
- Bin sz _ _ l r -> case (realsize l,realsize r) of
4103
- (Just n,Just m) | n+ m+ 1 == sz -> Just sz
4104
- _ -> Nothing
4105
-
4106
3964
{- -------------------------------------------------------------------
4107
3965
Utilities
4108
3966
--------------------------------------------------------------------}
0 commit comments