Extend inv item location information to include "attached" items
This commit is contained in:
@@ -32,6 +32,14 @@ dtToAdjacency f (DT x l r) = IM.insert (f x) (map g l <> map g r)
|
||||
where
|
||||
g = f . _dtValue
|
||||
|
||||
dtToIntMapWithRoot :: (a -> Int) -> DoubleTree a -> IM.IntMap (Maybe Int, DoubleTree a)
|
||||
dtToIntMapWithRoot f t@(DT x l r) = IM.insert (f x) (Nothing, t) $
|
||||
foldMap (dtToRootIntMap' (f x) f) $ l <> r
|
||||
|
||||
dtToRootIntMap' :: Int -> (a -> Int) -> DoubleTree a -> IM.IntMap (Maybe Int, DoubleTree a)
|
||||
dtToRootIntMap' root f t@(DT x l r) = IM.insert (f x) (Just root, t) $
|
||||
foldMap (dtToRootIntMap' root f) $ l <> r
|
||||
|
||||
dtToUpDownAdj :: (a -> Int) -> DoubleTree a -> IM.IntMap ([Int],[Int])
|
||||
dtToUpDownAdj f (DT x l r) = IM.insert (f x) (map g l , map g r)
|
||||
. IM.unions $ map (dtToUpDownAdj f) $ l <> r
|
||||
|
||||
Reference in New Issue
Block a user