SCM Repository
[smlnj] Diff of /sml/trunk/src/smlnj-lib/Util/left-priorityq-fn.sml
Diff of /sml/trunk/src/smlnj-lib/Util/left-priorityq-fn.sml
Parent Directory
|
Revision Log
|
Patch
51 |
fun fromList [] = empty |
fun fromList [] = empty |
52 |
| fromList [x] = Q (1, singleton x) |
| fromList [x] = Q (1, singleton x) |
53 |
| fromList l = let |
| fromList l = let |
54 |
|
fun init ([], n, items) = (n, items) |
55 |
|
| init (x::r, n, items) = init (r, n+1, singleton x :: items) |
56 |
fun merge ([], [h]) = h |
fun merge ([], [h]) = h |
57 |
| merge ([], hl) = merge (hl, []) |
| merge ([], hl) = merge (hl, []) |
58 |
| merge ([h], hl) = merge (h::hl, []) |
| merge ([h], hl) = merge (h::hl, []) |
59 |
| merge (h1::h2::r, l) = merge (r, mergeHeap(h1, h2) :: l) |
| merge (h1::h2::r, l) = merge (r, mergeHeap(h1, h2) :: l) |
60 |
|
val (len, hs) = init (l, 0, []) |
61 |
in |
in |
62 |
Q(List.length l, merge (List.map singleton l, [])) |
Q(len, merge (hs, [])) |
63 |
end |
end |
64 |
|
|
65 |
end; |
end; |
|
Legend:
Removed from v.1080 |
|
changed lines |
|
Added in v.1081 |
|
|