@@ -1859,9 +1859,10 @@ intersectionArrayBy f !b1 !b2 !ary1 !ary2
1859
1859
testBit x = x .&. m /= 0
1860
1860
b' = b .&. complement m
1861
1861
(len, bFinal) <- go 0 0 0 bCombined bIntersect
1862
+ l <- A. read mary 0
1862
1863
case len of
1863
1864
0 -> pure Empty
1864
- 1 -> A. read mary 0
1865
+ 1 | isLeafOrCollision l -> pure l
1865
1866
_ -> bitmapIndexedOrFull bFinal <$> (A. unsafeFreeze =<< A. shrink mary len)
1866
1867
where
1867
1868
bCombined = b1 .|. b2
@@ -1915,6 +1916,49 @@ searchSwap toFind start = go start toFind start
1915
1916
else go i0 k (i + 1 ) mary
1916
1917
{-# INLINE searchSwap #-}
1917
1918
1919
+ type WhenMissingKey k x y = k -> x -> Maybe y
1920
+
1921
+ type WhenMissingTree k x y = HashMap k x -> HashMap k y
1922
+
1923
+ type WhenMatched k x y z = k -> x -> y -> Maybe z
1924
+
1925
+ type MergeLeaf k x y z = Hash -> Hash -> Leaf k x -> Leaf k y -> HashMap k z
1926
+
1927
+ type MergeCollision k x y z = Hash -> Hash -> A. Array (Leaf k x ) -> A. Array (Leaf k y ) -> HashMap k z
1928
+
1929
+ type MergeBitmap k x y z = Bitmap -> Bitmap -> A. Array (HashMap k x ) -> A. Array (HashMap k y ) -> HashMap k z
1930
+
1931
+ -- what a monstrosity
1932
+ mergeMonstrosity ::
1933
+ MergeLeaf k x y z ->
1934
+ MergeCollision k x y z ->
1935
+ WhenMissingKey k x z ->
1936
+ WhenMissingTree k x z ->
1937
+ WhenMissingKey k y z ->
1938
+ WhenMissingTree k y z ->
1939
+ WhenMatched k x y z ->
1940
+ HashMap k x ->
1941
+ HashMap k y ->
1942
+ HashMap k z
1943
+ mergeMonstrosity
1944
+ mergeLeaf
1945
+ mergeCollision
1946
+ missK1
1947
+ missT1
1948
+ missK2
1949
+ missT2
1950
+ match = go 0
1951
+ where
1952
+ go ! _ t1 Empty = missT1 t1
1953
+ go _ Empty t2 = missT2 t2
1954
+ go _ (Leaf h1 l1) (Leaf h2 l2) = mergeLeaf h1 h2 l1 l2
1955
+ go _ (Collision h1 ls1) (Collision h2 ls2) = mergeCollision h1 h2 ls1 ls2
1956
+ go _ (BitmapIndexed b1 ary1) (BitmapIndexed b2 ary2) = mergeBitmap b1 b2 ary1 ary2
1957
+ {-# INLINE mergeMonstrosity #-}
1958
+
1959
+ mergeBitmap :: Bitmap -> Bitmap -> A. Array (HashMap k x ) -> A. Array (HashMap k y ) -> HashMap k z
1960
+ mergeBitmap b1 b2 ary1 ary2 = undefined
1961
+ {-# INLINE mergeBitmap #-}
1918
1962
1919
1963
------------------------------------------------------------------------
1920
1964
-- * Folds
0 commit comments