Located in compilation unit of io.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv static <T> Tuple2 | deleteMin(Comparator<? super T> comparator, Seq<PriorityQueueBase.
fun deleteMin [] = raise EMPTY | deleteMin ts = val (Node (x,r,c), ts) = getMin ts val (ts',xs') = split ([],[],c) in fold insert xs' (meld (ts, ts')) end |
| pack-priv static <T> PriorityQueueBase. | findMin(Comparator<? super T> comparator, Seq<PriorityQueueBase.
Find the minimum root in the forest fun findMin [] = raise EMPTY * | findMin [t] = root t * | findMin (t :: ts) = * let val x = findMin ts * in if Elem.leq (root t, x) then root t else x end |
| private static <T> Seq | ins(Comparator<? super T> comparator, PriorityQueueBase.
fun ins (t, []) = [t] | ins (t, t' :: ts) = (∗ rank t ≤ rank t' ∗) if rank t < rank t' then t :: t' :: ts else ins (link (t, t'), ts) |
| pack-priv static <T> Seq | insert(Comparator<? super T> comparator, T element, Seq<PriorityQueueBase.
fun insert (x, ts as t1 :: t2 :: rest) = if rank t1 = rank t2 then skewLink(Node(x,0,[]),t1,t2) :: rest else Node (x,0,[]) :: ts | insert (x, ts) = Node (x,0,[]) :: ts |
| pack-priv static <T> Seq | meld(Comparator<? super T> comparator, Seq<PriorityQueueBase.
fun meld (ts, ts') = meldUniq (uniqify ts, uniqify ts') |
| private static <T> Seq | meldUnique(Comparator<? super T> comparator, Seq<PriorityQueueBase.
fun meldUniq ([], ts) = ts | meldUniq (ts, []) = ts | meldUniq (t1 :: ts1, t2 :: ts2) = if rank t1 < rank t2 then t1 :: meldUniq (ts1, t2 :: ts2) else if rank t2 < rank t1 then t2 :: meldUniq (t1 :: ts1, ts2) else ins (link (t1, t2), meldUniq (ts1, ts2)) |
| private static <T> Seq | rebuild(Comparator<? super T> comparator, Seq<PriorityQueueBase.
Separate the rank 0 trees from the rest, rebuild the 0 rank ones and merge them back fun split (ts,xs,[]) = (ts, xs) * | split (ts,xs,t :: c) = * if rank t = 0 then split (ts,root t :: xs,c) * else split (t :: ts,xs,c) |
| private static <T> Seq | uniqify(Comparator<? super T> comparator, Seq<PriorityQueueBase.
fun uniqify [] = [] * | uniqify (t :: ts) = ins (t, ts) (∗ eliminate initial duplicate ∗) |
| PriorityQueueBase | back to summary |
|---|---|
| pack-priv PriorityQueueBase() | |
| deleteMin | back to summary |
|---|---|
| pack-priv static <T> Tuple2 fun deleteMin [] = raise EMPTY | deleteMin ts = val (Node (x,r,c), ts) = getMin ts val (ts',xs') = split ([],[],c) in fold insert xs' (meld (ts, ts')) end | |
| findMin | back to summary |
|---|---|
| pack-priv static <T> PriorityQueueBase. Find the minimum root in the forest fun findMin [] = raise EMPTY * | findMin [t] = root t * | findMin (t :: ts) = * let val x = findMin ts * in if Elem.leq (root t, x) then root t else x end | |
| ins | back to summary |
|---|---|
| private static <T> Seq fun ins (t, []) = [t] | ins (t, t' :: ts) = (∗ rank t ≤ rank t' ∗) if rank t < rank t' then t :: t' :: ts else ins (link (t, t'), ts) | |
| insert | back to summary |
|---|---|
| pack-priv static <T> Seq fun insert (x, ts as t1 :: t2 :: rest) = if rank t1 = rank t2 then skewLink(Node(x,0,[]),t1,t2) :: rest else Node (x,0,[]) :: ts | insert (x, ts) = Node (x,0,[]) :: ts | |
| meld | back to summary |
|---|---|
| pack-priv static <T> Seq fun meld (ts, ts') = meldUniq (uniqify ts, uniqify ts') | |
| meldUnique | back to summary |
|---|---|
| private static <T> Seq fun meldUniq ([], ts) = ts | meldUniq (ts, []) = ts | meldUniq (t1 :: ts1, t2 :: ts2) = if rank t1 < rank t2 then t1 :: meldUniq (ts1, t2 :: ts2) else if rank t2 < rank t1 then t2 :: meldUniq (t1 :: ts1, ts2) else ins (link (t1, t2), meldUniq (ts1, ts2)) | |
| rebuild | back to summary |
|---|---|
| private static <T> Seq Separate the rank 0 trees from the rest, rebuild the 0 rank ones and merge them back fun split (ts,xs,[]) = (ts, xs) * | split (ts,xs,t :: c) = * if rank t = 0 then split (ts,root t :: xs,c) * else split (t :: ts,xs,c) | |
| uniqify | back to summary |
|---|---|
| private static <T> Seq fun uniqify [] = [] * | uniqify (t :: ts) = ins (t, ts) (∗ eliminate initial duplicate ∗) | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final Seq | |
| pack-priv final int | |
| pack-priv final T | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv Seq | |
| pack-priv PriorityQueueBase. | |
| pack-priv static <T> PriorityQueueBase. | |
| pack-priv PriorityQueueBase. | skewLink(Comparator<? super T> comparator, PriorityQueueBase.
|
| children | back to summary |
|---|---|
| pack-priv final Seq<PriorityQueueBase. | |
| rank | back to summary |
|---|---|
| pack-priv final int rank | |
| root | back to summary |
|---|---|
pack-priv final T root
| |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| Node | back to summary |
|---|---|
| private Node(T root, int rank, Seq<PriorityQueueBase. | |
| appendTo | back to summary |
|---|---|
| pack-priv Seq | |
| link | back to summary |
|---|---|
| pack-priv PriorityQueueBase. | |
| of | back to summary |
|---|---|
| pack-priv static <T> PriorityQueueBase. | |
| skewLink | back to summary |
|---|---|
| pack-priv PriorityQueueBase. | |