Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/branches/SMLNJ/src/MLRISC/graphs/node-partition.sml
ViewVC logotype

Diff of /sml/branches/SMLNJ/src/MLRISC/graphs/node-partition.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 428, Wed Sep 8 09:47:00 1999 UTC revision 429, Wed Sep 8 09:47:00 1999 UTC
# Line 15  Line 15 
15     val ==    : 'n node_partition -> Graph.node_id * Graph.node_id -> bool     val ==    : 'n node_partition -> Graph.node_id * Graph.node_id -> bool
16     val union : 'n node_partition -> ('n Graph.node * 'n Graph.node ->     val union : 'n node_partition -> ('n Graph.node * 'n Graph.node ->
17                                          'n Graph.node) ->                                          'n Graph.node) ->
18                                          Graph.node_id * Graph.node_id -> bool                                          Graph.node_id * Graph.node_id -> unit
19     val union': 'n node_partition -> Graph.node_id * Graph.node_id -> bool     val union': 'n node_partition -> Graph.node_id * Graph.node_id -> unit
20    
21  end  end
22    
23  structure NodePartition :> NODE_PARTITION =  structure NodePartition :> NODE_PARTITION =
24  struct  struct
25    
26     structure U = UnionFindRef     structure U = URef
27     structure M = HashMap     structure H = HashTable
28     structure G = Graph     structure G = Graph
29    
30     type 'n node_partition = (G.node_id,'n G.node U.uref) M.map     type 'n node_partition = (G.node_id,'n G.node U.uref) H.hash_table
31    
32     fun node_partition (G.GRAPH G) =     fun node_partition (G.GRAPH G) =
33     let val P   = M.create { order = Int.compare,     let val P   = H.mkTable (Word.fromInt,op =) (#order G () * 2,G.NotFound)
34                              hash = fn i => i,         val ins = H.insert P
35                              exn = G.NotFound         val _   = #forall_nodes G (fn n as (i,_) => ins(i,U.uRef n))
                           } (#order G () * 2)  
        val ins = M.insert P  
        val _   = #forall_nodes G (fn n as (i,_) => ins(i,U.uref n))  
36     in  P     in  P
37     end     end
38    
39     fun !! P x          = U.!! (M.lookup P x)     fun !! P x          = U.!! (H.lookup P x)
40     fun == P (x,y)      = U.== (M.lookup P x, M.lookup P y)     fun == P (x,y)      = U.equal (H.lookup P x, H.lookup P y)
41     fun union P f (x,y) = U.union f (M.lookup P x, M.lookup P y)     fun union P f (x,y) = U.unify f (H.lookup P x, H.lookup P y)
42     fun union' P (x,y)  = U.union' (M.lookup P x, M.lookup P y)     fun union' P (x,y)  = U.union (H.lookup P x, H.lookup P y)
43  end  end
44    

Legend:
Removed from v.428  
changed lines
  Added in v.429

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0