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/int-redblack-map.sml
 [smlnj] / smlnj-lib / branches / rt-transition / Util / int-redblack-map.sml

# Diff of /smlnj-lib/branches/rt-transition/Util/int-redblack-map.sml

revision 785, Thu Feb 22 14:27:01 2001 UTC revision 1193, Thu May 16 18:44:04 2002 UTC
# Line 375  Line 375
375            in            in
376              wrap intersect              wrap intersect
377            end            end
378
379        fun mergeWith mergeFn = let
380              fun merge (t1, t2, n, result) = (case (next t1, next t2)
381                     of ((E, _), (E, _)) => (n, result)
382                      | ((E, _), (T(_, _, yk, y, _), r2)) =>
383                          mergef(yk, NONE, SOME y, t1, r2, n, result)
384                      | ((T(_, _, xk, x, _), r1), (E, _)) =>
385                          mergef(xk, SOME x, NONE, r1, t2, n, result)
386                      | ((T(_, _, xk, x, _), r1), (T(_, _, yk, y, _), r2)) =>
387                          if (xk  < yk)
388                            then mergef(xk, SOME x, NONE, r1, t2, n, result)
389                          else if (xk = yk)
390                            then mergef(xk, SOME x, SOME y, r1, r2, n, result)
391                            else mergef(yk, NONE, SOME y, t1, r2, n, result)
392                    (* end case *))
393              and mergef (k, x1, x2, r1, r2, n, result) = (case mergeFn(x1, x2)
394                     of NONE => merge (r1, r2, n, result)
395                      | SOME y => merge (r1, r2, n+1, addItem(k, y, result))
396                    (* end case *))
397              in
398                wrap merge
399              end
400        fun mergeWithi mergeFn = let
401              fun merge (t1, t2, n, result) = (case (next t1, next t2)
402                     of ((E, _), (E, _)) => (n, result)
403                      | ((E, _), (T(_, _, yk, y, _), r2)) =>
404                          mergef(yk, NONE, SOME y, t1, r2, n, result)
405                      | ((T(_, _, xk, x, _), r1), (E, _)) =>
406                          mergef(xk, SOME x, NONE, r1, t2, n, result)
407                      | ((T(_, _, xk, x, _), r1), (T(_, _, yk, y, _), r2)) =>
408                          if (xk  < yk)
409                            then mergef(xk, SOME x, NONE, r1, t2, n, result)
410                          else if (xk = yk)
411                            then mergef(xk, SOME x, SOME y, r1, r2, n, result)
412                            else mergef(yk, NONE, SOME y, t1, r2, n, result)
413                    (* end case *))
414              and mergef (k, x1, x2, r1, r2, n, result) = (case mergeFn(k, x1, x2)
415                     of NONE => merge (r1, r2, n, result)
416                      | SOME y => merge (r1, r2, n+1, addItem(k, y, result))
417                    (* end case *))
418              in
419                wrap merge
420              end
421      end (* local *)      end (* local *)
422
423      fun app f = let      fun app f = let

Legend:
 Removed from v.785 changed lines Added in v.1193