AssocTree

Plain source file: AssocTree.hs (Oct 11, 1999)

AssocTree is imported by: Case, CaseHelp, CaseLib, DbgDataTrans, DbgTrans, Derive, Export, Extract, FFITrans, FSLib, Fixity, Foreign, GcodeFix, GcodeMem, GcodeOpt1, GcodeOpt2, GcodeRel, IExtract, ImportState, Info, IntState, Main, NeedLib, Overlap, PreImport, Rename, RenameLib, Scc, TokenInt, Type, TypeCtx, TypeData, TypeSubst.

module AssocTree(AssocTree(..),initAT,reorderAT,addAT,lookupAT,Tree,updateAT,listAT) where

import Tree234

type AssocTree k v = Tree (k,v)

initAT = initTree

listAT t = treeMapList (:) t

reorderAT translate t = 
   foldl translate initAT (listAT t) 

cmp1 key (key',value) = compare key key'

cmp2 key _ (key',value) = compare key key'

addAT t comb key value = 
  treeAdd combine (cmp2 key) (key,value) t
 where
   combine (k1,v1) (k2,v2) = (k2,comb v1 v2)

lookupAT t key = 
   treeSearch Nothing ok (cmp1 key) t
  where
   ok (key,value) = Just value

updateAT t key upd = 
  treeUpdate update (cmp1 key) t
 where
   update (k1,v1) = (k1,upd v1)


Index

(HTML for this module was generated on May 15, 2003. About the conversion tool.)