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/FLINT/src/comp-lib/intstrmap.sml
ViewVC logotype

Diff of /sml/branches/FLINT/src/comp-lib/intstrmap.sml

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

revision 410, Fri Sep 3 00:25:03 1999 UTC revision 411, Fri Sep 3 00:25:03 1999 UTC
# Line 5  Line 5 
5    infix 9 sub    infix 9 sub
6    val itow = Word.fromInt    val itow = Word.fromInt
7    val wtoi = Word.toIntX    val wtoi = Word.toIntX
8    datatype 'a bucket = NIL | B of (int * string * 'a * 'a bucket)    datatype 'a bucket = NIL | B of (word * string * 'a * 'a bucket)
9    datatype 'a intstrmap =    datatype 'a intstrmap =
10      H of {table: 'a bucket array ref,elems: int ref,exn: exn,name: string option}      H of {table: 'a bucket array ref,elems: int ref,exn: exn,name: string option}
11    fun bucketapp f =    fun bucketapp f =
# Line 23  Line 23 
23    fun new(size, exn) =    fun new(size, exn) =
24        H {table=ref(array(roundsize size,NIL)),elems=ref 0,exn=exn,name=NONE}        H {table=ref(array(roundsize size,NIL)),elems=ref 0,exn=exn,name=NONE}
25    val elems = fn (H{elems,...}) => !elems    val elems = fn (H{elems,...}) => !elems
26    fun index(a, i) = wtoi (Word.andb(itow i, itow(Array.length a - 1)))    fun index(a, i) = wtoi (Word.andb(i, itow(Array.length a - 1)))
27    fun map (H{table,exn,...}) =    fun map (H{table,exn,...}) =
28        let fun find(i,s,NIL) = raise exn        let fun find(i,s,NIL) = raise exn
29              | find(i,s,B(i',s',j,r)) = if i=i' andalso s=s' then j else find(i,s,r)              | find(i,s,B(i',s',j,r)) = if i=i' andalso s=s' then j else find(i,s,r)
# Line 47  Line 47 
47    fun add (m as H{table as ref a, elems, name, ...}) (v as (i,s,j)) =    fun add (m as H{table as ref a, elems, name, ...}) (v as (i,s,j)) =
48        let val size = Array.length a        let val size = Array.length a
49         in if !elems <> size         in if !elems <> size
50            then let val index = wtoi (Word.andb(itow i, itow(size-1)))            then let val index = wtoi (Word.andb(i, itow(size-1)))
51                     fun f(B(i',s',j',r)) =                     fun f(B(i',s',j',r)) =
52                           if i=i' andalso s=s' then B(i,s,j,r) else B(i',s',j',f r)                           if i=i' andalso s=s' then B(i,s,j,r) else B(i',s',j',f r)
53                       | f x = (elems := !elems+1; B(i,s,j,x))                       | f x = (elems := !elems+1; B(i,s,j,x))
# Line 58  Line 58 
58                     val new = array(newsize,NIL)                     val new = array(newsize,NIL)
59                     fun bucket n =                     fun bucket n =
60                         let fun add'(a,b,B(i,s,j,r)) =                         let fun add'(a,b,B(i,s,j,r)) =
61                                 if wtoi (Word.andb(itow i, itow newsize1)) = n                                 if wtoi (Word.andb(i, itow newsize1)) = n
62                                 then add'(B(i,s,j,a),b,r)                                 then add'(B(i,s,j,a),b,r)
63                                 else add'(a,B(i,s,j,b),r)                                 else add'(a,B(i,s,j,b),r)
64                               | add'(a,b,NIL) =                               | add'(a,b,NIL) =
# Line 92  Line 92 
92  end  end
93    
94  (*  (*
95   * $Log$   * $Log: intstrmap.sml,v $
96     * Revision 1.1.1.1  1998/04/08 18:39:14  george
97     * Version 110.5
98     *
99   *)   *)

Legend:
Removed from v.410  
changed lines
  Added in v.411

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