Project

General

Profile

Statistics
| Revision:

root / proj / libs / classes / include / queue.h @ 317

History | View | Annotate | Download (1.48 KB)

1 277 up20180642
#ifndef QUEUE_H_INCLUDED
2
#define QUEUE_H_INCLUDED
3
4
struct queue;
5 316 up20180642
/**
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
 */
11 277 up20180642
typedef struct queue queue_t;
12
13 316 up20180642
/**
14
 * @brief Construct empty queue.
15
 * @return  Pointer to created queue
16
 */
17 277 up20180642
queue_t* (queue_ctor )(void);
18 316 up20180642
/**
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
 */
26 277 up20180642
int      (queue_dtor )(queue_t *q);
27 316 up20180642
/**
28
 * @brief Get size of the queue.
29
 * @param   q   Pointer to queue
30
 * @return      Size of the queue
31
 */
32 277 up20180642
size_t   (queue_size )(const queue_t *q);
33 316 up20180642
/**
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
 */
38 277 up20180642
int      (queue_empty)(const queue_t *q);
39 316 up20180642
/**
40
 * @brief Insert new value in the queue.
41
 * @param   q   Pointer to queue
42
 * @param   val Value to be inserted
43
 */
44 277 up20180642
void     (queue_push )(queue_t *q, void *val);
45 316 up20180642
/**
46
 * @brief Get next element in the queue.
47
 * @param   q   Pointer to queue
48
 * @return      Value at the beginning of the queue
49
 */
50 277 up20180642
void*    (queue_top  )(const queue_t *q);
51 316 up20180642
/**
52
 * @brief Erase next element of the queue.
53
 * @param   q   Pointer to queue
54
 */
55 277 up20180642
void     (queue_pop  )(queue_t *q);
56
57
#endif //QUEUE_H_INCLUDED