1 (* Copyright (C
) 1999-2006 Henry Cejtin
, Matthew Fluet
, Suresh
2 * Jagannathan
, and Stephen Weeks
.
4 * MLton is released under a BSD
-style license
.
5 * See the file MLton
-LICENSE for details
.
9 structure H
= BinaryHeap(structure O
= Int
13 val largest
= Int.maxInt
14 val smallest
= Int.minInt
)
16 val h
= new
[(1, "1"), (2, "2"), (3, "3")]
18 while not(isEmpty h
) do
24 structure IntegerHeap
= FibonacciHeap(structure Key
' = Integer
)
28 fun p h
= output h Integer
.output print
30 val h
= new
[(1, 1)] ;
32 val w
= isWellFormed h
;
36 fun i n
= insert h n n
;
42 val h
= new (ListUtil
.reverse (ListUtil
.map (ListUtil
.fromTo
1 10)
47 val w
= isWellFormed h
;
57 val l
= ListUtil
.map (ListUtil
.fromTo
1 7) (fn _
=> deleteMin h
) ;
67 ListUtil
.foreach (ListUtil
.fromTo
1 10) (fn i
=>
68 (insert
h (11 * i
) (11 * i
) ;
77 ListUtil
.foreach (ListUtil
.reverse (ListUtil
.fromTo
1 1100))
78 (fn i
=> (insert h i i
; ())) ;
80 ListUtil
.foreach (ListUtil
.fromTo
1 1098) (fn _
=> (deleteMin h
; ())) ;
88 val h
: int t
= new
[] ;
90 val elts
= ListUtil
.map (ListUtil
.fromTo
0 9) (fn x
=> insert h x x
) ;
94 fun dc i
= decreaseKey
h (ListUtil
.nth elts i
)
95 fun d i
= delete
h (ListUtil
.nth elts i
)
101 val a
= deleteMin h
;