The list functions discussed so far do not make use of the priority field
in a ListNode&. The SUB Enqueue is equivalent to the SUB Insert, except
it inserts nodes into a list sorting them according to their priority.
It keeps the higher-priority nodes towards the head of the list. All nodes
passed to this SUB must have their priority assigned prior to the call.
For example, "Enqueue list&, node&" inserts the node& behind the lowest
priority node with a priority greater than or equal to node&'s priority.
For Enqueue to work properly, the list must already be sort according to
priority, in fact you should use Enqueue from the beginning on to insert
new nodes into a priority sorted list. Because the highest priority node
is at the head of the list, the FUNCTION RemHead& will remove the
highest-priority node. Likewise, the FUNCTION RemTail& will remove
the lowest-priority node.
FIFO Is Used For The Same Priority.
-----------------------------------
If you add a node that has the same priority as another node in the
queue, Enqueue will use FIFO (or pipe) ordering. The new node is
inserted following the last node of equal priority.
There exists no further SUB to sort the nodes in opposite direction, the
head node will always be the highest- and the tail node the lowest-priority
node. If you need the opposite sorting order, then simply scan the list
from tail to head using the scanning FUNCTIONs GetTail& and GetPred&.
Back to List Functions