File tree Expand file tree Collapse file tree 2 files changed +2
-48
lines changed Expand file tree Collapse file tree 2 files changed +2
-48
lines changed Original file line number Diff line number Diff line change @@ -316,6 +316,7 @@ import Data.IntMap.Internal
316
316
, isSubmapOf
317
317
, isSubmapOfBy
318
318
, lookup
319
+ , findWithDefault
319
320
, lookupLE
320
321
, lookupGE
321
322
, lookupLT
@@ -358,28 +359,6 @@ import Utils.Containers.Internal.BitUtil
358
359
import Utils.Containers.Internal.StrictPair
359
360
import qualified Data.Foldable as Foldable
360
361
361
- {- -------------------------------------------------------------------
362
- Query
363
- --------------------------------------------------------------------}
364
-
365
- -- | \(O(\min(n,W))\). The expression @('findWithDefault' def k map)@
366
- -- returns the value at key @k@ or returns @def@ when the key is not an
367
- -- element of the map.
368
- --
369
- -- > findWithDefault 'x' 1 (fromList [(5,'a'), (3,'b')]) == 'x'
370
- -- > findWithDefault 'x' 5 (fromList [(5,'a'), (3,'b')]) == 'a'
371
-
372
- -- See IntMap.Internal.Note: Local 'go' functions and capturing]
373
- findWithDefault :: a -> Key -> IntMap a -> a
374
- findWithDefault def ! k = go
375
- where
376
- go (Bin p l r) | nomatch k p = def
377
- | left k p = go l
378
- | otherwise = go r
379
- go (Tip kx x) | k == kx = x
380
- | otherwise = def
381
- go Nil = def
382
-
383
362
{- -------------------------------------------------------------------
384
363
Construction
385
364
--------------------------------------------------------------------}
Original file line number Diff line number Diff line change @@ -386,6 +386,7 @@ import Data.Map.Internal
386
386
, keysSet
387
387
, link
388
388
, lookup
389
+ , findWithDefault
389
390
, lookupGE
390
391
, lookupGT
391
392
, lookupIndex
@@ -473,32 +474,6 @@ import qualified Data.Foldable as Foldable
473
474
-- narrow conditions and at a relatively high cost. It does not seem
474
475
-- worth the price.
475
476
476
- {- -------------------------------------------------------------------
477
- Query
478
- --------------------------------------------------------------------}
479
-
480
- -- | \(O(\log n)\). The expression @('findWithDefault' def k map)@ returns
481
- -- the value at key @k@ or returns default value @def@
482
- -- when the key is not in the map.
483
- --
484
- -- > findWithDefault 'x' 1 (fromList [(5,'a'), (3,'b')]) == 'x'
485
- -- > findWithDefault 'x' 5 (fromList [(5,'a'), (3,'b')]) == 'a'
486
-
487
- -- See Map.Internal.Note: Local 'go' functions and capturing
488
- findWithDefault :: Ord k => a -> k -> Map k a -> a
489
- findWithDefault def k = k `seq` go
490
- where
491
- go Tip = def
492
- go (Bin _ kx x l r) = case compare k kx of
493
- LT -> go l
494
- GT -> go r
495
- EQ -> x
496
- #if __GLASGOW_HASKELL__
497
- {-# INLINABLE findWithDefault #-}
498
- #else
499
- {-# INLINE findWithDefault #-}
500
- #endif
501
-
502
477
{- -------------------------------------------------------------------
503
478
Construction
504
479
--------------------------------------------------------------------}
You can’t perform that action at this time.
0 commit comments