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/trunk/src/smlnj-lib/Util/splay-set-fn.sml
 [smlnj] / sml / trunk / src / smlnj-lib / Util / splay-set-fn.sml

# Diff of /sml/trunk/src/smlnj-lib/Util/splay-set-fn.sml

revision 815, Fri May 4 05:09:10 2001 UTC revision 816, Fri May 4 16:37:36 2001 UTC
# Line 283  Line 283
283              | filt (SplayObj{value,left,right},tree) = let              | filt (SplayObj{value,left,right},tree) = let
284                  val t' = filt(right,filt(left,tree))                  val t' = filt(right,filt(left,tree))
285                  in                  in
286                    if p value then insert(value,t')                    if p value then insert(value,t') else t'
else t'
287                  end                  end
288            in            in
289              case filt(!root,(0,SplayNil)) of              case filt(!root,(0,SplayNil)) of
# Line 292  Line 291
291              | (cnt,t) => SET{nobj=cnt,root=ref t}              | (cnt,t) => SET{nobj=cnt,root=ref t}
292            end            end
293
294        fun partition p EMPTY = (EMPTY, EMPTY)
295          | partition p (SET{root,...}) = let
296              fun filt (SplayNil, tree1, tree2) = (tree1, tree2)
297                | filt (SplayObj{value,left,right}, tree1, tree2) = let
298                    val (t1, t2) = filt(left, tree1, tree2)
299                    val (t1', t2') = filt(right, t1, t2)
300                    in
301                      if p value
302                        then (insert(value, t1'), t2')
303                        else (t1', insert(value, t2'))
304                    end
305              fun mk (0, _) = EMPTY
306                | mk (cnt, t) = SET{nobj=cnt, root=ref t}
307              val (t1, t2) = filt (!root, (0, SplayNil), (0, SplayNil))
308              in
309                (mk t1, mk t2)
310              end
311
312      fun exists p EMPTY = false      fun exists p EMPTY = false
313        | exists p (SET{root,...}) = let        | exists p (SET{root,...}) = let
314            fun ex SplayNil = false            fun ex SplayNil = false

Legend:
 Removed from v.815 changed lines Added in v.816