Define a circular buffer data structure and test it.
Problem Description:
A circular buffer (also called a circular queue) is circular list of nodes where data items are added on one end of the buffer and removed from the other end. Because the nodes form a circular list, the list has no end or beginning: the tail node points to the head node, creating a ring of nodes. You may think of the nodes as containers or slots that are all initially empty but can be assigned a value in their data fieldinfo. Every time a new data item is inserted (inserting to a buffer is often referred asWriting), one slot is filled and the buffer has one less empty slot. Every time a data item is removed (referred to asReading), the buffer has one more empty slot. Since the list has no beginning and no end, a pointer (writeIndex) is used to mark the next empty slot to write to and a second pointer (readIndex) is used to mark the next node to read from. The readIndex/writeIndex must be properly updated with each read/write operation. The read and write operations must also check the buffer status (empty/full) before reading/writing. Watchthe following short video for a brief description of a circular buffer:(Links to an external site.)https://www.youtube.com/watch?v=39HHWATPcwY
Note also that because data is accessed in a First-In First-Out (FIFO) order, circular buffer is also referred as a circular queue.
Define a class that that implements the circular buffer data structure as described above:
2.Create a program to test your implementation of class circularBuffer. Use instructions listed in the comments in filetestCircularBuffer.cppto test your implementation.
Recommendation: You should implement and test class circularBuffer incrementally: start by creating function stubs for all class methods, then implement and test each method one by one. Always start by implementing the class constructor.
Deliverables:
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here