intersection

intersection :: IntMap a -> IntMap b -> IntMap a
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
O(n+m). The (left-biased) intersection of two maps (based on keys). > intersection (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "a"
intersection :: IntSet -> IntSet -> IntSet
containers Data.IntSet
O(n+m). The intersection of two sets.
intersection :: Ord a => Set a -> Set a -> Set a
containers Data.Set
O(n+m). The intersection of two sets. The implementation uses an efficient hedge algorithm comparable with hedge-union. Elements of the result come from the first set, so for example > import qualified Data.Set as S > data AB = A | B deriving Show > instance Ord AB > instance Eq AB > main = print (S.singleton A `S.intersection` S.singleton B, > S.singleton B `S.intersection` S.singleton A) prints (fromList [A],fromList [B]).
intersection :: Ord k => Map k a -> Map k b -> Map k a
containers Data.Map.Lazy, containers Data.Map.Strict
O(n+m). Intersection of two maps. Return data in the first map for the keys existing in both maps. (intersection m1 m2 == intersectionWith const m1 m2). The implementation uses an efficient hedge algorithm comparable with hedge-union. > intersection (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "a"
intersectionWith :: (a -> b -> c) -> IntMap a -> IntMap b -> IntMap c
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
O(n+m). The intersection with a combining function. > intersectionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "aA"
intersectionWith :: Ord k => (a -> b -> c) -> Map k a -> Map k b -> Map k c
containers Data.Map.Lazy, containers Data.Map.Strict
O(n+m). Intersection with a combining function. The implementation uses an efficient hedge algorithm comparable with hedge-union. > intersectionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "aA"
intersectionWithKey :: (Key -> a -> b -> c) -> IntMap a -> IntMap b -> IntMap c
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
O(n+m). The intersection with a combining function. > let f k al ar = (show k) ++ ":" ++ al ++ "|" ++ ar > intersectionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "5:a|A"
intersectionWithKey :: Ord k => (k -> a -> b -> c) -> Map k a -> Map k b -> Map k c
containers Data.Map.Lazy, containers Data.Map.Strict
O(n+m). Intersection with a combining function. The implementation uses an efficient hedge algorithm comparable with hedge-union. > let f k al ar = (show k) ++ ":" ++ al ++ "|" ++ ar > intersectionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "5:a|A"