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 /smlnj-lib/branches/rt-transition/Util/splay-map-fn.sml
ViewVC logotype

Diff of /smlnj-lib/branches/rt-transition/Util/splay-map-fn.sml

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

revision 29, Thu Mar 12 01:05:59 1998 UTC revision 289, Sat May 22 21:01:25 1999 UTC
# Line 11  Line 11 
11      structure Key = K      structure Key = K
12      open SplayTree      open SplayTree
13    
14      datatype 'a map =      datatype 'a map
15          EMPTY        = EMPTY
16        | MAP of {        | MAP of {
17          root : (K.ord_key * 'a) splay ref,          root : (K.ord_key * 'a) splay ref,
18          nobj : int          nobj : int
# Line 22  Line 22 
22    
23      val empty = EMPTY      val empty = EMPTY
24    
25        fun isEmpty EMPTY = true
26          | isEmpty _ = false
27    
28      (* return the first item in the map (or NONE if it is empty) *)
29        fun first EMPTY = NONE
30          | first (MAP{root, ...}) = let
31              fun f (SplayObj{value=(_, value), left=SplayNil, ...}) = SOME value
32                | f (SplayObj{left, ...}) = f left
33              in
34                f (!root)
35              end
36    
37      (* return the first item in the map and its key (or NONE if it is empty) *)
38        fun firsti EMPTY = NONE
39          | firsti (MAP{root, ...}) = let
40              fun f (SplayObj{value=(key, value), left=SplayNil, ...}) = SOME(key, value)
41                | f (SplayObj{left, ...}) = f left
42              in
43                f (!root)
44              end
45    
46          (* Insert an item.          (* Insert an item.
47           *)           *)
48      fun insert (EMPTY,key,v) =      fun insert (EMPTY,key,v) =

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

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