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