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/word-redblack-set.sml
ViewVC logotype

Diff of /smlnj-lib/branches/rt-transition/Util/word-redblack-set.sml

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

revision 2271, Sun Jan 28 13:46:49 2007 UTC revision 2272, Tue Jan 30 14:49:42 2007 UTC
# Line 271  Line 271 
271              link (E, t)              link (E, t)
272            end            end
273    
274      (* create a set from a list of items; this function works in linear time if the list
275       * is in increasing order.
276       *)
277        fun fromList [] = empty
278          | fromList (first::rest) = let
279              fun add (prev, x::xs, n, accum) = if (prev < x)
280                    then add(x, xs, n+1, addItem(x, accum))
281                    else (* list not in order, so fall back to addList code *)
282                        addList(SET(n, linkAll accum), x::xs)
283                | add (_, [], n, accum) = SET(n, linkAll accum)
284              in
285                add (first, rest, 1, addItem(first, ZERO))
286              end
287    
288    (* return the union of the two sets *)    (* return the union of the two sets *)
289      fun union (SET(_, s1), SET(_, s2)) = let      fun union (SET(_, s1), SET(_, s2)) = let
290            fun ins ((E, _), n, result) = (n, result)            fun ins ((E, _), n, result) = (n, result)

Legend:
Removed from v.2271  
changed lines
  Added in v.2272

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