0b22edf3fee95a36222e5cb73361d84e55a481c5
5 #include "cgds/Queue.h"
7 void _queue_init(Queue
* queue
, size_t dataSize
)
9 queue
->dataSize
= dataSize
;
10 _list_init(queue
->list
, dataSize
);
13 Queue
* _queue_new(size_t dataSize
)
15 Queue
* queue
= (Queue
*) safe_malloc(sizeof (Queue
));
16 queue
->list
= _list_new(dataSize
);
17 _queue_init(queue
, dataSize
);
21 Queue
* queue_copy(Queue
* queue
)
23 Queue
* queueCopy
= (Queue
*) safe_malloc(sizeof (Queue
));
24 queueCopy
->dataSize
= queue
->dataSize
;
25 List
* listCopy
= list_copy(queue
->list
);
26 queueCopy
->list
= listCopy
;
30 bool queue_empty(Queue
* queue
)
32 return list_empty(queue
->list
);
35 UInt
queue_size(Queue
* queue
)
37 return list_size(queue
->list
);
40 void _queue_push(Queue
* queue
, void* data
)
42 _list_insert_back(queue
->list
, data
);
45 void* _queue_peek(Queue
* queue
)
47 return _list_get(queue
->list
->head
);
50 void queue_pop(Queue
* queue
)
52 list_remove_front(queue
->list
);
55 void queue_clear(Queue
* queue
)
57 list_clear(queue
->list
);
60 void queue_destroy(Queue
* queue
)
62 list_destroy(queue
->list
);