Insert an element into a doubly linked queue
#include <search.h> void insque( void *elem, void *pred);
- A pointer to the element you want to insert.
- A pointer to the previous element in the list, or NULL if you want to initialize the head of the list.
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The insque() function inserts the element pointed to by elem into a doubly linked queue immediately after the element pointed to by pred. The queue can be either circular or linear.
The first two members of the elements must be pointers to the same type of structure; the names of the members don't matter. The first member of the structure is a forward pointer to the next element in the queue, and the second is a backward pointer to the previous element. The application can define any additional members in the structure.
If the queue is linear, the queue is terminated with NULL pointers.
If the queue is to be used as a linear list, invoking insque( &element, NULL), where element is the initial element of the queue, initializes the forward and backward pointers of the element to NULL.
If you intend to use the queue as a circular list, initialize the forward pointer and the backward pointer of the initial element of the queue to the element's own address.
You can use remque() to remove elements from the queue.