Top Inners Constructors Methods
io.vavr.collection

pack-priv final Class PriorityQueueBase

Located in compilation unit of io.vavr.collection.PriorityQueue.

extends Object
Class Inheritance

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv static <T> Tuple2<T, Seq<PriorityQueueBase.Node<T>>>
deleteMin(Comparator<? super T> comparator, Seq<PriorityQueueBase.Node<T>> forest)

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.Node<T>
findMin(Comparator<? super T> comparator, Seq<PriorityQueueBase.Node<T>> forest)

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<PriorityQueueBase.Node<T>>
ins(Comparator<? super T> comparator, PriorityQueueBase.Node<T> tree, Seq<PriorityQueueBase.Node<T>> forest)

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<PriorityQueueBase.Node<T>>
insert(Comparator<? super T> comparator, T element, Seq<PriorityQueueBase.Node<T>> forest)

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<PriorityQueueBase.Node<T>>
meld(Comparator<? super T> comparator, Seq<PriorityQueueBase.Node<T>> source, Seq<PriorityQueueBase.Node<T>> target)

fun meld (ts, ts') = meldUniq (uniqify ts, uniqify ts')

private static <T> Seq<PriorityQueueBase.Node<T>>
meldUnique(Comparator<? super T> comparator, Seq<PriorityQueueBase.Node<T>> forest1, Seq<PriorityQueueBase.Node<T>> forest2)

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<PriorityQueueBase.Node<T>>
rebuild(Comparator<? super T> comparator, Seq<PriorityQueueBase.Node<T>> forest)

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<PriorityQueueBase.Node<T>>
uniqify(Comparator<? super T> comparator, Seq<PriorityQueueBase.Node<T>> forest)

fun uniqify [] = [] * | uniqify (t :: ts) = ins (t, ts) (∗ eliminate initial duplicate ∗)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

PriorityQueueBaseback to summary
pack-priv PriorityQueueBase()

Method Detail

deleteMinback to summary
pack-priv static <T> Tuple2<T, Seq<PriorityQueueBase.Node<T>>> deleteMin(Comparator<? super T> comparator, Seq<PriorityQueueBase.Node<T>> forest)

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

findMinback to summary
pack-priv static <T> PriorityQueueBase.Node<T> findMin(Comparator<? super T> comparator, Seq<PriorityQueueBase.Node<T>> forest)

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

insback to summary
private static <T> Seq<PriorityQueueBase.Node<T>> ins(Comparator<? super T> comparator, PriorityQueueBase.Node<T> tree, Seq<PriorityQueueBase.Node<T>> forest)

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)

insertback to summary
pack-priv static <T> Seq<PriorityQueueBase.Node<T>> insert(Comparator<? super T> comparator, T element, Seq<PriorityQueueBase.Node<T>> forest)

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

meldback to summary
pack-priv static <T> Seq<PriorityQueueBase.Node<T>> meld(Comparator<? super T> comparator, Seq<PriorityQueueBase.Node<T>> source, Seq<PriorityQueueBase.Node<T>> target)

fun meld (ts, ts') = meldUniq (uniqify ts, uniqify ts')

meldUniqueback to summary
private static <T> Seq<PriorityQueueBase.Node<T>> meldUnique(Comparator<? super T> comparator, Seq<PriorityQueueBase.Node<T>> forest1, Seq<PriorityQueueBase.Node<T>> forest2)

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))

rebuildback to summary
private static <T> Seq<PriorityQueueBase.Node<T>> rebuild(Comparator<? super T> comparator, Seq<PriorityQueueBase.Node<T>> forest)

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)

uniqifyback to summary
private static <T> Seq<PriorityQueueBase.Node<T>> uniqify(Comparator<? super T> comparator, Seq<PriorityQueueBase.Node<T>> forest)

fun uniqify [] = [] * | uniqify (t :: ts) = ins (t, ts) (∗ eliminate initial duplicate ∗)

io.vavr.collection back to summary

pack-priv final Class PriorityQueueBase.Node<T>

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable

Field Summary

Modifier and TypeField and Description
pack-priv final Seq<PriorityQueueBase.Node<T>>
pack-priv final int
pack-priv final T
private static final long

Constructor Summary

AccessConstructor and Description
private
Node(T root, int rank, Seq<PriorityQueueBase.Node<T>> children)

Method Summary

Modifier and TypeMethod and Description
pack-priv Seq<PriorityQueueBase.Node<T>>
pack-priv static <T> PriorityQueueBase.Node<T>
of(T value, int rank, Seq<PriorityQueueBase.Node<T>> children)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

childrenback to summary
pack-priv final Seq<PriorityQueueBase.Node<T>> children
rankback to summary
pack-priv final int rank
rootback to summary
pack-priv final T root
Annotations
@SuppressWarnings:serial
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

Nodeback to summary
private Node(T root, int rank, Seq<PriorityQueueBase.Node<T>> children)

Method Detail

appendToback to summary
pack-priv Seq<PriorityQueueBase.Node<T>> appendTo(Seq<PriorityQueueBase.Node<T>> forest)
ofback to summary
pack-priv static <T> PriorityQueueBase.Node<T> of(T value, int rank, Seq<PriorityQueueBase.Node<T>> children)