| Description | Queue data structure |
| Header file | LQueue.h |
| Author | Camil Demetrescu |
| Created | Dec 28, 2002 |
| Last updated | Sep 26, 2003 |
Constants |
|
LQueue_ID LQueue_EMPTY_QUEUE LQueue_BASE_TYPE_MISMATCH |
Types |
|
LQueue |
Functions |
|
LQueue* LQueue_New (LType_TType inType) |
| Function | Arguments | Description | Returns | Throws |
| New |
LType_TType inType |
Creates object containing an empty queue with items of type inType. Caller is responsible of dellocating the created object using LQueue_Delete. |
LQueue* pointer to newly created object |
- |
| Delete | LQueue** ThisA | Releases object *ThisA. *ThisA is set to NULL. | - | - |
IsEmpty |
LQueue* This | Returns TRUE if the data structure is empty, and FALSE otherwise. | Bool | - |
EnqueueI1 |
LQueue* This i1 inVal |
Inserts value inVal of the specified type into the data structure. The item type of the queue must be the same as the type of the inserted element. | - |
BASE_TYPE_MISMATCH if the item type of the queue is not compatible with the operation. |
EnqueueUI1 |
LQueue* This ui1 inVal |
|||
EnqueueI2 |
LQueue* This i2 inVal |
|||
EnqueueUI2 |
LQueue* This ui2 inVal |
|||
EnqueueI4 |
LQueue* This i4 inVal |
|||
EnqueueUI4 |
LQueue* This ui4 inVal |
|||
EnqueueF4 |
LQueue* This f4 inVal |
|||
EnqueueF8 |
LQueue* This f8 inVal |
|||
EnqueueBool |
LQueue* This Bool inVal |
|||
EnqueuePtr |
LQueue* This void* inVal |
|||
EnqueueItem |
LQueue* This void* inItem |
Inserts item into the data structure. | - | - |
DequeueI1 |
LQueue* This |
Extracts the oldest-inserted value of the
specified type from the data structure. The queue must not be empty. |
i1 |
BASE_TYPE_MISMATCH if the item type of the queue is not compatible with the operation. EMPTY_QUEUE if the queue is empty. |
DequeueUI1 |
LQueue* This |
ui1 |
||
DequeueI2 |
LQueue* This |
i2 |
||
DequeueUI2 |
LQueue* This |
ui2 |
||
DequeueI4 |
LQueue* This |
i4 |
||
DequeueUI4 |
LQueue* This |
ui4 |
||
DequeueF4 |
LQueue* This |
f4 |
||
DequeueF8 |
LQueue* This |
f8 |
||
DequeueBool |
LQueue* This |
Bool |
||
DequeuePtr |
LQueue* This |
void* |
||
DequeueItem |
LQueue* This void* outItem |
Extracts the oldest-inserted value from the data structure, copying it to buffer outItem. | - | - |
| GetUsedMem | LQueue* This | Returns the memory usage (in bytes) of the data structure. | ui4 | - |
| GetBaseType | LQueue* This | Returns the type of items. | LType_TType | - |
#include "LQueue.h"
#include "LException.h"
#include "LDebug.h"
int main() {
ui4 i;
LQueue* theQueue = NULL;
LException* theExcep;
Try {
/* create new queue */
theQueue = LQueue_New(LType_UI4);
/* enqueue values */
for (i=100; i>0; --i)
LQueue_EnqueueUI4(theQueue, i);
/* extract all values from queue */
while (!LQueue_IsEmpty(theQueue)) {
ui4 theVal = LQueue_DequeueUI4(theQueue);
LDebug_Print("Extracted value: %lu\n", theVal);
}
}
Catch(theExcep) {
LException_Dump(theExcep);
}
if (theQueue != NULL) LQueue_Delete(&theQueue);
return 0;
}