-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInnerCB.h~
60 lines (44 loc) · 1.4 KB
/
InnerCB.h~
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
50
51
52
53
54
55
56
57
58
59
60
// file: InnerCB.h
//
// UMBC CMSC 341 Fall 2018 Project 1
//
// Header file for Inner Circular Buffer.
// See project description for details.
//
#ifndef _INNERCB_H_
#define _INNERCB_H_
class InnerCB {
public:
// Constructor, default size is 10.
InnerCB(int n=10) ;
// Copy constructor
InnerCB(const InnerCB& other) ;
// Destructor
~InnerCB() ;
// Add item to circular buffer
void enqueue(int data) ;
// Remove item from circular buffer
int dequeue() ;
// True if no space left in buffer
bool isFull() ;
// True if buffer holds no items
bool isEmpty() ;
// return maximum number of items this buffer can hold
int capacity() ;
// return number of items currently held in the buffer
int size() ;
// overloaded assignment operator
const InnerCB& operator=(const InnerCB& rhs) ;
// debugging function. Prints out contents.
void dump() ;
// grading function used to examine private data members.
// Do not implement!
bool inspect (int* &buf, int &cap, int &size, int &start, int &end) ;
private :
int *m_buffer ; // pointer to dynamically allocate array for buffer
int m_capacity ; // length of the allocated space pointed by m_buffer
int m_size ; // # of items in the buffer
int m_start ; // index of the first (oldest) item in the buffer
int m_end ; // index of the last (newest) item in the buffer
} ;
#endif