@@ -1828,7 +1828,6 @@ splitRoot orig =
1828
1828
-- @since 0.5.11
1829
1829
1830
1830
powerSet :: Set a -> Set (Set a )
1831
- powerSet xs | null xs = singleton xs
1832
1831
powerSet xs =
1833
1832
let ! w = length xs
1834
1833
! u = A. listArray (0 , w- 1 ) $ toList xs
@@ -1850,6 +1849,7 @@ generateA :: A.Ix i => (i,i) -> (i -> a) -> A.Array i a
1850
1849
generateA bnd f = A. listArray bnd $ fmap f $ A. range bnd
1851
1850
1852
1851
forw :: Int -> Int -> Int
1852
+ forw 0 _ = 0
1853
1853
forw ! width ! n = fr_go_branch (bit $ width- 1 ) n 0
1854
1854
1855
1855
fr_go_branch :: Int -> Int -> Int -> Int
@@ -1867,16 +1867,14 @@ data StrictTriple = ST !Int !Int !Int
1867
1867
-- index of middle bit, bitmask for lower half
1868
1868
splitBits :: Int -> StrictTriple
1869
1869
splitBits m =
1870
- let go 0 ! x = x; go k ! x = go (k- 1 ) (clearLowest x)
1871
- ! up_med = go (div (popCount m) 2 ) m
1872
- ! lo = xor m up_med
1873
- ! up = clearLowest up_med
1874
- ! med = xor up_med up
1870
+ let clearLowest ! x = x .&. (x- 1 )
1871
+ go 0 ! x = x; go k ! x = go (k- 1 ) (clearLowest x)
1872
+ up_med = go (div (popCount m) 2 ) m
1873
+ lo = xor m up_med
1874
+ up = clearLowest up_med
1875
+ med = xor up_med up
1875
1876
in ST up (countTrailingZeros med) lo
1876
1877
1877
- clearLowest :: Int -> Int
1878
- clearLowest m = m .&. (m- 1 )
1879
-
1880
1878
-- Proof of complexity: step executes n times. At the ith step,
1881
1879
-- "insertMin x `mapMonotonic` pxs" takes O(2^i log i) time since pxs has size
1882
1880
-- 2^i - 1 and we insertMin into its elements which are sets of size <= i.
0 commit comments