public static IEnumerable <Tuple <KeyT, V> > toSeq(MinHeapPQ <V> pq) { for (; !pq.mt; pq.dltmin()) { yield return(pq.pkmn); } }
public static Tuple <Tuple <KeyT, V>, MinHeapPQ <V> > popMin(MinHeapPQ <V> pq) { var rslt = pq.pkmn; if (rslt == null) { return(null); } pq.dltmin(); return(new Tuple <Tuple <KeyT, V>, MinHeapPQ <V> >(rslt, pq)); }
public static MinHeapPQ <V> adjust(Func <KeyT, V, Tuple <KeyT, V> > f, MinHeapPQ <V> pq) { pq.adj(f); return(pq); }
public static MinHeapPQ <V> fromSeq(IEnumerable <Tuple <KeyT, V> > sq) { var pq = new MinHeapPQ <V>(); pq.bld(sq); return(pq); }
public static MinHeapPQ <V> deleteMin(MinHeapPQ <V> pq) { pq.dltmin(); return(pq); }
public static MinHeapPQ <V> merge(MinHeapPQ <V> pq1, MinHeapPQ <V> pq2) { return(fromSeq(pq1.sq().Concat(pq2.sq()))); }
public static MinHeapPQ <V> replaceMin(KeyT k, V v, MinHeapPQ <V> pq) { pq.rplcmin(k, v); return(pq); }
public static MinHeapPQ <V> push(KeyT k, V v, MinHeapPQ <V> pq) { pq.psh(k, v); return(pq); }
public static Tuple <KeyT, V> peekMin(MinHeapPQ <V> pq) { return(pq.pkmn); }
public static int size(MinHeapPQ <V> pq) { return(pq.sz); }
public static bool isEmpty(MinHeapPQ <V> pq) { return(pq.mt); }