-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueue.h
More file actions
35 lines (29 loc) · 928 Bytes
/
queue.h
File metadata and controls
35 lines (29 loc) · 928 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef SIMPLE_SHELL_QUEUE_H
#define SIMPLE_SHELL_QUEUE_H
#include <stddef.h> /* size_t */
#include "alloc.h"
#include "singly_linked_list.h"
/**
* struct queue - a queue data structure.
* @length: number of items in the queue.
* @head: a pointer to the head of the queue.
* @tail: a pointer to the tail of the queue.
*/
struct queue
{
size_t length;
single_link_node *head;
single_link_node *tail;
};
typedef struct queue queue;
queue *queue_new(void);
void *queue_peek_head(const queue *const q);
void *queue_peek_tail(const queue *const q);
void queue_clear(queue *const q, delete_func *free_data);
void *queue_delete(queue *const nullable_ptr, delete_func *free_data);
single_link_node *enqueue(
queue *const q, void *const data, dup_func *copy_data);
void *dequeue(queue *const q);
void **queue_to_array(
const queue *const q, dup_func *copy_data, delete_func *free_data);
#endif /* SIMPLE_SHELL_QUEUE_H */