[Contents] [index] [Help] [Retrace] [browse <] [Browse >]

The list functions discussed so far do not make use of the priority field
in a node. the enqueue() function is equivalent to 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 function must have their priority and name assigned prior
to the call. Enqueue(header,mynode) inserts mynode behind the lowest
priority node with a priority greater than or equal to mynode's. For
Enqueue() to work properly, the list must already be sort according to
priority.  Because the highest priority node is at the head of the list,
the remhead() function will remove the highest-priority node.  likewise,
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 ordering.  the new node is inserted
    following the last node of equal priority.