Move towards displaying tree links in inventory
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
module Dodge.DoubleTree where
|
||||
|
||||
import Dodge.Data.DoubleTree
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
|
||||
ldtToDT :: LabelDoubleTree b a -> DoubleTree a
|
||||
ldtToDT (LDT x l r) = DT x (map (ldtToDT . snd) l) (map (ldtToDT . snd) r)
|
||||
@@ -18,6 +19,18 @@ dtIL nt (DT x l r) = map doindent (concat (headMap (dtIL DTBottomNode) (dtIL DTM
|
||||
where
|
||||
doindent (a,b,c) = (a,b+1,c)
|
||||
|
||||
dtToAdjacency :: (a -> Int) -> DoubleTree a -> IM.IntMap [Int]
|
||||
dtToAdjacency f (DT x l r) = IM.insert (f x) (map g l <> map g r)
|
||||
. IM.unions $ map (dtToAdjacency f) $ l <> r
|
||||
where
|
||||
g = f . _dtValue
|
||||
|
||||
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
|
||||
where
|
||||
g = f . _dtValue
|
||||
|
||||
ldtToIndentList :: LabelDoubleTree b a -> [(a,Int,LabelDoubleTreeNodeType b)]
|
||||
ldtToIndentList = ldtIL LDTRootNode
|
||||
|
||||
|
||||
Reference in New Issue
Block a user