-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaperCircularArray.h
More file actions
37 lines (31 loc) · 1.25 KB
/
paperCircularArray.h
File metadata and controls
37 lines (31 loc) · 1.25 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
/*
* Program: paperCircularArray.h
* Purpose: This is intended to show a basic circular array (buffer) and how it functions.
* This was originally coded as part of an extra credit assignment and it really helped me learn more about
* data structures and how memory is handled in C programs.
*
* Edits: This header file was created after the fact to bring the program in line with the standards that I learned
* after coding this program.
*/
/*
* This value can be edited to allow for almost any size of buffer, since modulo operations to ensure the CircularArray data
* stays within the bounds of the size dictated here
*/
#define ARRAY_MAX_SIZE 5 // Defines the maximum size of the circular buffer
// The struct used as the buffer(CircularArray)
typedef struct CircularArray
{
int array[ARRAY_MAX_SIZE];
int elementCount;
int read;
int write;
} CircularArray;
// Function prototypes
CircularArray* initializeCircularArray();
bool isEmpty(CircularArray* arrayToCheck);
bool isFull(CircularArray* arrayToCheck);
void insertValueIntoArray(CircularArray* arrayToAddTo, int newValue);
int dequeueFromArray(CircularArray* arrayToDequeue);
void printCircularArray(CircularArray* arrayToPrint);
void searchCircularArray(CircularArray* arrayToSearch, int valueToFind);