root / proj / libs / classes / include / queue.h @ 336
History | View | Annotate | Download (1.54 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 | 277 | up20180642 | typedef struct queue queue_t; |
16 | |||
17 | 316 | up20180642 | /**
|
18 | * @brief Construct empty queue.
|
||
19 | * @return Pointer to created queue
|
||
20 | */
|
||
21 | 277 | up20180642 | queue_t* (queue_ctor )(void);
|
22 | 316 | up20180642 | /**
|
23 | * @brief Destruct queue.
|
||
24 | *
|
||
25 | * A queue can only be destroyed once it is empty.
|
||
26 | * This is because a queue stores void*, whose memory most likely need to be free'd.
|
||
27 | * @param q Pointer to queue to be destroyed
|
||
28 | * @return SUCCESS if the destruction was successful, other value otherwise.
|
||
29 | */
|
||
30 | 277 | up20180642 | int (queue_dtor )(queue_t *q);
|
31 | 316 | up20180642 | /**
|
32 | * @brief Get size of the queue.
|
||
33 | * @param q Pointer to queue
|
||
34 | * @return Size of the queue
|
||
35 | */
|
||
36 | 277 | up20180642 | size_t (queue_size )(const queue_t *q);
|
37 | 316 | up20180642 | /**
|
38 | * @brief Know if queue is empty or not.
|
||
39 | * @param q Pointer to queue
|
||
40 | * @return true if the queue is empty (size is zero), false otherwise
|
||
41 | */
|
||
42 | 277 | up20180642 | int (queue_empty)(const queue_t *q); |
43 | 316 | up20180642 | /**
|
44 | * @brief Insert new value in the queue.
|
||
45 | * @param q Pointer to queue
|
||
46 | * @param val Value to be inserted
|
||
47 | */
|
||
48 | 277 | up20180642 | void (queue_push )(queue_t *q, void *val); |
49 | 316 | up20180642 | /**
|
50 | * @brief Get next element in the queue.
|
||
51 | * @param q Pointer to queue
|
||
52 | * @return Value at the beginning of the queue
|
||
53 | */
|
||
54 | 277 | up20180642 | void* (queue_top )(const queue_t *q); |
55 | 316 | up20180642 | /**
|
56 | * @brief Erase next element of the queue.
|
||
57 | * @param q Pointer to queue
|
||
58 | */
|
||
59 | 277 | up20180642 | void (queue_pop )(queue_t *q);
|
60 | |||
61 | 328 | up20180642 | /**
|
62 | * @}
|
||
63 | */
|
||
64 | |||
65 | 277 | up20180642 | #endif //QUEUE_H_INCLUDED |