-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueue.h
More file actions
38 lines (28 loc) · 1.04 KB
/
queue.h
File metadata and controls
38 lines (28 loc) · 1.04 KB
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
36
37
#pragma once
/*
* queue.h -- public interface to the queue module
*/
/* the queue representation is hidden from users of the module */
typedef void queue_t;
/* create an empty queue */
queue_t* qopen(void);
/* deallocate a queue, frees everything in it */
void qclose(queue_t *qp);
/* put element at end of queue */
int qput(queue_t *qp, void *elementp);
/* get first element from queue */
void* qget(queue_t *qp);
/* apply a void function to every element of a queue */
void qapply(queue_t *qp, void (*fn)(void* elementp));
/* search a queue using a supplied boolean function, returns an element */
void* qsearch(queue_t *qp,
int (*searchfn)(void* elementp,const void* keyp),
const void* skeyp);
/* search a queue using a supplied boolean function, removes and
* returns the element
*/
void* qremove(queue_t *qp,
int (*searchfn)(void* elementp,const void* keyp),
const void* skeyp);
/* concatenatenates elements of q2 into q1, q2 is dealocated upon completion */
void qconcat(queue_t *q1p, queue_t *q2p);