queue

Name

queue -- Doubly-linked queue routines

Synopsis



#define     q_init                          (q)
#define     q_isempty                       (q)
#define     q_getfirst                      (q)
#define     q_getlast                       (q)
void        q_enqueue                       (QBLOCK *qb,
                                             QBLOCK *item);
void        q_dequeue                       (QBLOCK *element);
QBLOCK*     q_deqnext                       (QBLOCK *qb);
unsigned int q_map                          (QBLOCK *qb,
                                             unsigned int (*func) (QBLOCK *,unsigned int,unsigned int),
                                             unsigned int a,
                                             unsigned int b);
int         q_count                         (QBLOCK *qb);
int         q_find                          (QBLOCK *qb,
                                             QBLOCK *qe);

Description

This module contains routines to manipulate doubly-linked queues.

Details

q_init()

#define q_init(q) (q)->q_prev = (q), (q)->q_next = (q)

???

q : The queue


q_isempty()

#define q_isempty(q) ((q)->q_next == (q))

Used to determine whether the queue is empty

q : The queue


q_getfirst()

#define q_getfirst(q) ((q)->q_next)

Gets first element in the queue

q : The queue


q_getlast()

#define q_getlast(q) ((q)->q_prev)

Gets the previous element in the queue

q : The queue


q_enqueue ()

void        q_enqueue                       (QBLOCK *qb,
                                             QBLOCK *item);

Add item to a queue, not interlocked

qb : queue block
item : queue block


q_dequeue ()

void        q_dequeue                       (QBLOCK *element);

Remove an element from the queue, not interlocked

element : element to remove


q_deqnext ()

QBLOCK*     q_deqnext                       (QBLOCK *qb);

Dequeue next element from the specified queue, not interlocked

qb : queue block
Returns : next element, or NULL


q_map ()

unsigned int q_map                          (QBLOCK *qb,
                                             unsigned int (*func) (QBLOCK *,unsigned int,unsigned int),
                                             unsigned int a,
                                             unsigned int b);

"Map" a queue, calling the specified function for each element in the queue (not interlocked).

qb : queue block
func : function pointer
a : parameters for the function
b : parameters for the function
Returns : return value from function, or zero if entire queue was mapped.


q_count ()

int         q_count                         (QBLOCK *qb);

Counts the elements on a queue (not interlocked)

qb : queue block
Returns : number of elements


q_find ()

int         q_find                          (QBLOCK *qb,
                                             QBLOCK *qe);

Determines if a particular element is on a queue

qb : queue block
qe : queue element
Returns : 0 - not on queue, >0 - position on queue