insque()

Insert an element into a doubly linked queue

Synopsis:

#include <search.h>

void insque( void *elem,
             void *pred);

Since:

BlackBerry 10.0.0

Arguments:

elem
A pointer to the element you want to insert.
pred
A pointer to the previous element in the list, or NULL if you want to initialize the head of the list.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

This function is in libc.a, but not in libc.so (in order to save space).

Description:

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.

Classification:

POSIX 1003.1 XSI

Safety:  
Cancellation point No
Interrupt handler Yes
Signal handler Yes
Thread Yes

Last modified: 2014-06-24



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus