-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueue.c
More file actions
37 lines (26 loc) · 722 Bytes
/
queue.c
File metadata and controls
37 lines (26 loc) · 722 Bytes
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
#include "linearcontainer.h"
struct _Queue
{
LinearContainer* linear_container;
};
Queue* queue_create(LinearContainer* container)
{
Queue* thiz = NULL;
return_val_if_fail(container != NULL, NULL);
thiz = (Queue*)malloc(sizeof(Queue));
if(thiz != NULL)
{
thiz->linear_container = container;
}
return thiz;
}
int queue_head(Queue* thiz, void** data)
{
return_val_if_fail(thiz != NULL && data != NULL, RET_INVALID_PARAMS);
return linear_container_get_by_index(thiz->linear_container, 0, data);
}
int queue_push(Queue* thiz, void* data)
{
return_val_if_fail(thiz != NULL, RET_INVALID_PARAMS);
return linear_container_append(thiz->linear_container, data);
}