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/smlnj-lib/Util/int-binary-map.sml
ViewVC logotype

Diff of /sml/branches/SMLNJ/src/smlnj-lib/Util/int-binary-map.sml

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

revision 288, Sat May 22 21:01:25 1999 UTC revision 289, Sat May 22 21:01:25 1999 UTC
# Line 66  Line 66 
66            right : 'a map            right : 'a map
67          }          }
68    
69        fun isEmpty E = true
70          | isEmpty _ = false
71    
72      fun numItems E = 0      fun numItems E = 0
73        | numItems (T{cnt,...}) = cnt        | numItems (T{cnt,...}) = cnt
74    
75      (* return the first item in the map (or NONE if it is empty) *)
76        fun first E = NONE
77          | first (T{value, left=E, ...}) = SOME value
78          | first (T{left, ...}) = first left
79    
80      (* return the first item in the map and its key (or NONE if it is empty) *)
81        fun firsti E = NONE
82          | firsti (T{key, value, left=E, ...}) = SOME(key, value)
83          | firsti (T{left, ...}) = firsti left
84    
85  local  local
86      fun N(k,v,E,E) = T{key=k,value=v,cnt=1,left=E,right=E}      fun N(k,v,E,E) = T{key=k,value=v,cnt=1,left=E,right=E}
87        | N(k,v,E,r as T n) = T{key=k,value=v,cnt=1+(#cnt n),left=E,right=r}        | N(k,v,E,r as T n) = T{key=k,value=v,cnt=1+(#cnt n),left=E,right=r}

Legend:
Removed from v.288  
changed lines
  Added in v.289

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