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/redblack-map-fn.sml
ViewVC logotype

Diff of /sml/trunk/src/smlnj-lib/Util/redblack-map-fn.sml

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

revision 1192, Wed May 15 14:02:06 2002 UTC revision 1193, Thu May 16 18:44:04 2002 UTC
# Line 371  Line 371 
371            in            in
372              wrap intersect              wrap intersect
373            end            end
374    
375        fun mergeWith mergeFn = let
376              fun merge (t1, t2, n, result) = (case (next t1, next t2)
377                     of ((E, _), (E, _)) => (n, result)
378                      | ((E, _), (T(_, _, yk, y, _), r2)) =>
379                          mergef(yk, NONE, SOME y, t1, r2, n, result)
380                      | ((T(_, _, xk, x, _), r1), (E, _)) =>
381                          mergef(xk, SOME x, NONE, r1, t2, n, result)
382                      | ((T(_, _, xk, x, _), r1), (T(_, _, yk, y, _), r2)) => (
383                          case Key.compare(xk, yk)
384                           of LESS => mergef(xk, SOME x, NONE, r1, t2, n, result)
385                            | EQUAL => mergef(xk, SOME x, SOME y, r1, r2, n, result)
386                            | GREATER => mergef(yk, NONE, SOME y, t1, r2, n, result)
387                          (* end case *))
388                    (* end case *))
389              and mergef (k, x1, x2, r1, r2, n, result) = (case mergeFn(x1, x2)
390                     of NONE => merge (r1, r2, n, result)
391                      | SOME y => merge (r1, r2, n+1, addItem(k, y, result))
392                    (* end case *))
393              in
394                wrap merge
395              end
396        fun mergeWithi mergeFn = let
397              fun merge (t1, t2, n, result) = (case (next t1, next t2)
398                     of ((E, _), (E, _)) => (n, result)
399                      | ((E, _), (T(_, _, yk, y, _), r2)) =>
400                          mergef(yk, NONE, SOME y, t1, r2, n, result)
401                      | ((T(_, _, xk, x, _), r1), (E, _)) =>
402                          mergef(xk, SOME x, NONE, r1, t2, n, result)
403                      | ((T(_, _, xk, x, _), r1), (T(_, _, yk, y, _), r2)) => (
404                          case Key.compare(xk, yk)
405                           of LESS => mergef(xk, SOME x, NONE, r1, t2, n, result)
406                            | EQUAL => mergef(xk, SOME x, SOME y, r1, r2, n, result)
407                            | GREATER => mergef(yk, NONE, SOME y, t1, r2, n, result)
408                          (* end case *))
409                    (* end case *))
410              and mergef (k, x1, x2, r1, r2, n, result) = (case mergeFn(k, x1, x2)
411                     of NONE => merge (r1, r2, n, result)
412                      | SOME y => merge (r1, r2, n+1, addItem(k, y, result))
413                    (* end case *))
414              in
415                wrap merge
416              end
417      end (* local *)      end (* local *)
418    
419      fun app f = let      fun app f = let

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

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