-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueue.h
More file actions
64 lines (55 loc) · 1.75 KB
/
Copy pathqueue.h
File metadata and controls
64 lines (55 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef QUEUE_H
#define QUEUE_H
#include "linked_list.h"
#define EXTRA_QUEUE_STRING_LENGTH 10
/*
*Queue outside floors, the values in the queue are generic
* element_queue = linked_list representing a queue
* start time = time when the button was pressed by the first person in queue
*/
typedef struct queue
{
linked_list_t *element_queue;
int start_time;
}
queue_t;
/*
*constructor of the queue, does not allocate dynamic memory for the queue but just
*for the linked_list element_queue
*returns a queue
*/
queue_t get_queue();
/*
*Adds an element to the queue
* queue = queue where the element is to be added
* element = element to be added to the queue
* current_time = time when the element joined the queue
* returns FAILED_EXECUTION if queue or element are NULL, CORRECT_EXECUTION otherwise
*/
int queue_element(queue_t *queue, void* element, int current_time);
/*
*dequeues the first element of the queue
* queue = queue where the first element has to be dequeued
* returns the first element of the queue, NULL if the queue is NULL or the queue is empty
*/
void *dequeue_element(queue_t *queue);
/*
*frees the memory allocated by the constructor, if queue is NULL an
*unexpected behaviour will occur
* queue = queue where the memory has to be freed
* free_val = function that frees the memory of one of the elements in the queue
*/
void free_queue(queue_t* queue, void free_val(void*));
/*
*Checks if the queue is empty
* queue = queue to be checked
* returns 1 if the queue is empty, 0 if it is not and FAILED_EXECUTION if queue = NULL
*/
int queue_is_empty(queue_t *queue);
/*
*Function that tells the length of the queue
* queue = queue to be checked
* returns the length of the queue or FAILED_EXECUTION if queue == NULL
*/
int queue_length(queue_t *queue);
#endif