-
Notifications
You must be signed in to change notification settings - Fork 0
/
myqueue.h
88 lines (68 loc) · 2.18 KB
/
myqueue.h
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/********************************************************************************
* File Name: myqueue.h
* Author: Qinrui Yan
* Organizaion: KU_Leuven-GroupT
* Date: 2015-06-01
* E-mail: castoryan1991@gmail.com
* Description: Header file of implementing data structure of circular queue
*******************************************************************************/
/*===============================================================================
Include files and Definitions(defines, typedefs, ...)
================================================================================*/
#ifndef MYQUEUE_
#define MYQUEUE_
#include "data_type.h"
typedef struct queue queue_t;
/*
** The default queue size is 5
*/
#ifndef QUEUE_SIZE
#define QUEUE_SIZE 5
#endif
/*
** Make some changes here to define the type of element that will be stored in the queue
*/
// typedef struct sensor_data_element sensor_data_element_t;
// typedef sensor_data_element_t *sensor_data_element_ptr_t;
typedef sensor_data_element_ptr_t element_t;
//typedef int element_t;
/*------------------------end of Include files and Definitions---------------------------*/
/*
** Creates (memory allocation!) and initializes the queue and prepares it for usage
** Return a pointer to the newly created queue
** Returns NULL if queue creation failed
*/
queue_t* queue_create();
/*
** Add an element to the queue
** Does nothing if queue is full
*/
void queue_enqueue(queue_t* queue, element_t element);
/*
** Delete the queue from memory; set queue to NULL
** The queue can no longer be used unless queue_create is called again
*/
void queue_free(queue_t** queue);
/*
** Return the number of elements in the queue
*/
int queue_size(queue_t* queue);
/*
** Return if the queue is full
*/
int queue_isfull(queue_t* queue);
/*
** Return a pointer to the top element in the queue
** Returns NULL if queue is empty
*/
element_t* queue_top(queue_t* queue);
/*
** Remove the top element from the queue
** Does nothing if queue is empty
*/
void queue_dequeue(queue_t* queue);
/*
** Print all elements in the queue, starting from the front element
*/
void queue_print(queue_t *queue);
#endif //MYQUEUE_