Revision 316
documented list and queue
queue.h | ||
---|---|---|
2 | 2 |
#define QUEUE_H_INCLUDED |
3 | 3 |
|
4 | 4 |
struct queue; |
5 |
/** |
|
6 |
* @brief Queue. |
|
7 |
* |
|
8 |
* Can be used like a C++ std::queue. |
|
9 |
* A queue_t is an interface for a list_t that simulates a FIFO. |
|
10 |
*/ |
|
5 | 11 |
typedef struct queue queue_t; |
6 | 12 |
|
7 |
const size_t queue_max_size; |
|
8 |
|
|
13 |
/** |
|
14 |
* @brief Construct empty queue. |
|
15 |
* @return Pointer to created queue |
|
16 |
*/ |
|
9 | 17 |
queue_t* (queue_ctor )(void); |
18 |
/** |
|
19 |
* @brief Destruct queue. |
|
20 |
* |
|
21 |
* A queue can only be destroyed once it is empty. |
|
22 |
* This is because a queue stores void*, whose memory most likely need to be free'd. |
|
23 |
* @param q Pointer to queue to be destroyed |
|
24 |
* @return SUCCESS if the destruction was successful, other value otherwise. |
|
25 |
*/ |
|
10 | 26 |
int (queue_dtor )(queue_t *q); |
27 |
/** |
|
28 |
* @brief Get size of the queue. |
|
29 |
* @param q Pointer to queue |
|
30 |
* @return Size of the queue |
|
31 |
*/ |
|
11 | 32 |
size_t (queue_size )(const queue_t *q); |
33 |
/** |
|
34 |
* @brief Know if queue is empty or not. |
|
35 |
* @param q Pointer to queue |
|
36 |
* @return true if the queue is empty (size is zero), false otherwise |
|
37 |
*/ |
|
12 | 38 |
int (queue_empty)(const queue_t *q); |
39 |
/** |
|
40 |
* @brief Insert new value in the queue. |
|
41 |
* @param q Pointer to queue |
|
42 |
* @param val Value to be inserted |
|
43 |
*/ |
|
13 | 44 |
void (queue_push )(queue_t *q, void *val); |
45 |
/** |
|
46 |
* @brief Get next element in the queue. |
|
47 |
* @param q Pointer to queue |
|
48 |
* @return Value at the beginning of the queue |
|
49 |
*/ |
|
14 | 50 |
void* (queue_top )(const queue_t *q); |
51 |
/** |
|
52 |
* @brief Erase next element of the queue. |
|
53 |
* @param q Pointer to queue |
|
54 |
*/ |
|
15 | 55 |
void (queue_pop )(queue_t *q); |
16 | 56 |
|
17 | 57 |
#endif //QUEUE_H_INCLUDED |
Also available in: Unified diff