Implementation of a queue as linked list.
More...
Go to the source code of this file.
Implementation of a queue as linked list.
- Author
- Rui Carlos Gonçalves
- Version
- 3.0.1
- Date
- 01/2014
Definition in file queue.c.
Creates a queue.
- Returns
NULL
if an error occurred
the new queue otherwise
Definition at line 12 of file queue.c.
int queueConsult |
( |
Queue |
queue, |
|
|
void ** |
value |
|
) |
| |
Provides the value at the head of a queue.
If the queue is empty, it will be put the value NULL
at value
.
- Attention
- This function puts at
value
a pointer to the value at the first position. Changes to this value will affect the element in the list.
- Parameters
-
queue | the queue |
value | pointer where the value at the last position will be put |
- Returns
- 0 if the queue was not empty
1 otherwise
Definition at line 95 of file queue.c.
void queueDelete |
( |
Queue |
queue | ) |
|
Deletes a queue.
- Attention
- This function only frees the memory used by the queue. It does not free the memory used by elements the queue contains.
- Parameters
-
queue | the queue to be deleted |
Definition at line 26 of file queue.c.
int queueInsert |
( |
Queue |
queue, |
|
|
void * |
value |
|
) |
| |
Inserts an element in a queue.
- Parameters
-
queue | the queue |
value | the value to be inserted |
- Returns
- 0 if the new value was inserted
1 if it was not possible to insert the new element
Definition at line 44 of file queue.c.
Creates an iterator from a queue.
- See Also
- Iterator
- Parameters
-
- Returns
NULL
if an error occurred
the iterator otherwise
Definition at line 131 of file queue.c.
int queueMap |
( |
Queue |
queue, |
|
|
void(*)(void *) |
fun |
|
) |
| |
Applies a function to the elements of a queue.
The function to be applied must be of type void fun(void*)
.
- Parameters
-
queue | the queue |
fun | the function to be applied |
- Returns
- 0 if the queue was not empty
1 otherwise
Definition at line 116 of file queue.c.
int queueRemove |
( |
Queue |
queue, |
|
|
void ** |
value |
|
) |
| |
Removes an element from a queue.
Provides the value of the removed element if the value of value
is not NULL
.
- Attention
- This function does not free the memory used by the removed element.
- Parameters
-
queue | the queue |
value | pointer where the removed value should be put (or NULL ) |
- Returns
- 0 if an element was removed
1 if the queue was empty
Definition at line 64 of file queue.c.
int queueSize |
( |
Queue |
queue | ) |
|
Returns the size of a queue.
- Parameters
-
- Returns
- the size of the queue
Definition at line 109 of file queue.c.