Queue.c

Operations on the queue structure.

Summary
Queue.cOperations on the queue structure.
QueueInitAllocate the queue array
queueInit
queueCopyPerform a copy of a queue.
queueExitFree a queue structure.
queueAddAdd an element in a queue, following one double value as key.
queueAdd2Add an element in a queue, following one double value and an integer value as keys.
queueGetGet next element of the queue and remove it from the queue.
queueSizeCompute the size of a queue.
queueClear
queueReadRead the next element that ‘ll be given by queueGet but not suppress it from the queue
compwith2keysCompare 2 elements following their two keys.
compWith2keys
queueGet2Get next element of the queue and remove it from the queue.
queuePossesCheck if an element belongs to a queue.
queueInitPrint a queue entries to standar error output.
queuePrint

QueueInit

Allocate the queue array

Parameters

qThe queue to initialize
sizeThe initial size of the queue.

Return

NO_ERRIf all goes well.

queueInit

int queueInit(Queue *q,
INT size)

queueCopy

Perform a copy of a queue.

Parameters

dstDestination of the copy.
srcSource of the copy.

Returns

The copy address or NULL if the destination or the source is NULL.

queueExit

void queueExit(Queue *q)

Free a queue structure.

Parameters

qThe queue to free.

queueAdd

void queueAdd(Queue *q,
INT elt,
double key)

Add an element in a queue, following one double value as key.

The element has to be a positive integer.

Parameters

qthe queue to fill.
eltthe element to add.
keyThe key associated to the element.

queueAdd2

void queueAdd2(Queue *q,
INT elt,
double key,
INT key2)

Add an element in a queue, following one double value and an integer value as keys.

The element has to be a positive integer.

Parameters

qthe queue to fill.
eltthe element to add.
keyThe double key associated to the element.
key2The integer key associated to the element.

queueGet

INT queueGet(Queue *q)

Get next element of the queue and remove it from the queue.

Parameters

qThe queue from which user wants an element.

Returns

The element if it was found, or -1 if it wasn’t.

queueSize

INT queueSize(Queue *q)

Compute the size of a queue.

Parameters

qthe queue.

Returns

The size of the queue.

queueClear

void queueClear(Queue *q)

queueRead

INT queueRead(Queue *q)

Read the next element that ‘ll be given by queueGet but not suppress it from the queue

Parameters

qThe queue.

Returns

The next element.

compwith2keys

Compare 2 elements following their two keys.

Parameters

qcompare two elements
elt1index of the first element in the queue.
elt2index of the second element in the queue.

compWith2keys

INT compWith2keys(Queue *q,
INT elt1,
INT elt2)

queueGet2

INT queueGet2(Queue *q,
double *key,
INT *key2)

Get next element of the queue and remove it from the queue.

Parameters

qThe queue.
keyThe first key (double) of the element.
key2The second key (integer) of the element.

Returns

The element, or -1 if not found.

queuePosses

int queuePossess(Queue *q,
INT elt)

Check if an element belongs to a queue.

Parameters

qThe queue.
eltThe searched element.

Returns

API_YESif the element was found.
API_NOif the element was not found.

queueInit

Print a queue entries to standar error output.

Parameters

qThe queue.

queuePrint

void queuePrint(Queue *q)
int queueInit(Queue *q,
INT size)
void queueExit(Queue *q)
Free a queue structure.
void queueAdd(Queue *q,
INT elt,
double key)
Add an element in a queue, following one double value as key.
void queueAdd2(Queue *q,
INT elt,
double key,
INT key2)
Add an element in a queue, following one double value and an integer value as keys.
INT queueGet(Queue *q)
Get next element of the queue and remove it from the queue.
INT queueSize(Queue *q)
Compute the size of a queue.
void queueClear(Queue *q)
INT queueRead(Queue *q)
Read the next element that ‘ll be given by queueGet but not suppress it from the queue
INT compWith2keys(Queue *q,
INT elt1,
INT elt2)
INT queueGet2(Queue *q,
double *key,
INT *key2)
Get next element of the queue and remove it from the queue.
int queuePossess(Queue *q,
INT elt)
Check if an element belongs to a queue.
void queuePrint(Queue *q)
Close