-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbounded_queue.h
More file actions
executable file
·49 lines (34 loc) · 1.13 KB
/
bounded_queue.h
File metadata and controls
executable file
·49 lines (34 loc) · 1.13 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
38
39
40
41
42
43
44
45
46
47
48
49
/*
Author: Marc Lee (Changhwan)
duckid: clee3
Title: CIS415 project2 bounded_queue header file
This is my own work
*/
#ifndef BOUNDED_QUEUE_H
#define BOUNDED_QUEUE_H
typedef struct bounded_queue BoundedQueue;
BoundedQueue *BB_MallocBoundedQueue(long size);
long long BB_TryEnqueue(BoundedQueue *queue,void *item);
/* if it is not empty
if id is valid
Id == tail
null what tail is indexing move tail to next id return success */
int BB_TryDequeue(BoundedQueue *queue,long long id);
/* Head points to the next if not empty: (Head -1) else -1 */
long long BB_GetFront(BoundedQueue *queue);
/* If not empty: Tail else -1 */
long long BB_GetBack(BoundedQueue *queue);
/* Head - Tail */
int BB_GetCount(BoundedQueue *queue);
/* Head > id >= Tail */
int BB_IsIdValid(BoundedQueue *queue,long long id);
/* if IsIdValid() index = ConvertIdtoIndex(id); return Buffer[index]
else null */
void *BB_GetItem(BoundedQueue *queue,long long id);
/* if Head - Tail == size */
int BB_IsFull(BoundedQueue *queue);
/* if Head == Tail */
int BB_IsEmpty(BoundedQueue *queue);
/* Cleanup and Free */
void BB_FreeBoundedQueue(BoundedQueue *queue);
#endif