New patches:
[optimize IntMap/IntSet findMin/findMax
sedillard@gmail.com**20081002152055] {
hunk ./Data/IntMap.hs 954
-findMin :: IntMap a -> a
-findMin = maybe (error "findMin: empty map has no minimal element") fst . minView
+findMin :: IntMap a -> (Int,a)
+findMin Nil = error $ "findMin: empty map has no minimal element"
+findMin (Tip k v) = (k,v)
+findMin (Bin _ m l r)
+ | m < 0 = find r
+ | otherwise = find l
+ where find (Tip k v) = (k,v)
+ find (Bin _ _ l _) = find l
+ find Nil = error "findMax Nil"
hunk ./Data/IntMap.hs 965
-findMax :: IntMap a -> a
-findMax = maybe (error "findMax: empty map has no maximal element") fst . maxView
+findMax :: IntMap a -> (Int,a)
+findMax Nil = error $ "findMax: empty map has no maximal element"
+findMax (Tip k v) = (k,v)
+findMax (Bin _ m l r)
+ | m < 0 = find l
+ | otherwise = find r
+ where find (Tip k v) = (k,v)
+ find (Bin _ _ _ r) = find r
+ find Nil = error "findMax Nil"
hunk ./Data/IntSet.hs 595
--- | /O(min(n,W))/. The minimal element of a set.
-findMin :: IntSet -> Int
-findMin = maybe (error "findMin: empty set has no minimal element") fst . minView
+
+-- | /O(min(n,W))/. The minimal element of the set.
+findMin Nil = error "findMin: empty set has no minimal element"
+findMin (Tip x) = x
+findMin (Bin _ m l r)
+ | m < 0 = find r
+ | otherwise = find l
+ where find (Tip x) = x
+ find (Bin _ _ l _) = find l
+ find Nil = error "findMin Nil"
hunk ./Data/IntSet.hs 607
-findMax :: IntSet -> Int
-findMax = maybe (error "findMax: empty set has no maximal element") fst . maxView
+findMax Nil = error "findMax: empty set has no maximal element"
+findMax (Tip x) = x
+findMax (Bin _ m l r)
+ | m < 0 = find l
+ | otherwise = find r
+ where find (Tip x) = x
+ find (Bin _ _ _ r) = find r
+ find Nil = error "findMax Nil"
+
}
Context:
[export Data.Map.toDescList, foldlWithKey, and foldrWithKey (trac ticket 2580)
qdunkan@gmail.com**20080922213200
toDescList was previously implemented, but not exported.
foldlWithKey was previously implemented, but not exported. It can be used to
implement toDescList.
foldrWithKey is already exported as foldWithKey, but foldrWithKey is explicitly
the mirror of foldlWithKey, and foldWithKey kept for compatibility.
]
[Bump version number to 0.2.0.0
Ian Lynagh **20080920160016]
[TAG 6.10 branch has been forked
Ian Lynagh **20080919123438]
Patch bundle hash:
e60b166778a102bd02a649488963e296492a6a80