First: PriorityQueue.SortPred ~ {
one: REF Item ~ NARROW[x];
two: REF Item ~ NARROW[y];
RETURN[( one.position > two.position )];
};
DumpCardTab:
PROC [x: CardTab.Ref]
RETURNS [hook:
LIST
OF
REF Item ←
NIL] ~ {
len: INT ~ CardTab.GetSize[x];
pq: PriorityQueue.Ref ~ PriorityQueue.Predict[len, First];
TakeNote: CardTab.EachPairAction ~ {
guy: REF Item ~ NEW [Item ← [key, val]];
PriorityQueue.Insert[pq, guy];
};
[] ← CardTab.Pairs[x, TakeNote];
FOR i:
INT
IN [0..len)
DO
gal: REF Item ~ NARROW[PriorityQueue.Remove[pq]];
hook ← CONS[gal, hook];
ENDLOOP;
};
}.