Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (1.57 KB)

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