Untitled

 avatar
user_5152005
plain_text
9 months ago
1.5 kB
2
Indexable
/* @@@LICENSE
 *
 * (c) Copyright 2023-2024 LG Electronics, Inc.
 *
 * Confidential computer software. Valid license from LG required for
 * possession, use or copying. Consistent with FAR 12.211 and 12.212,
 * Commercial Computer Software, Computer Software Documentation, and
 * Technical Data for Commercial Items are licensed to the U.S. Government
 * under vendor's standard commercial license.
 *
 * LICENSE@@@
 */

 /**
 * @file ring_buffer.h
 *
 * @brief this file contains private variables and public functions .
 */
 
#include<bits/stdc++.h>


using namespace std;	

class CircularBuffer {
private:
    vector<int> buffer; // buffer by std::buffer
    int head;			// point to the newest element about to push	
    int tail;           // point to the oldest element about was pushed
    int capacity;		// the total capacity of the buffer

public:
    // Constructor to intialize circular buffer's data
    // members
    CircularBuffer(int capacity);   


    // Function to add an element to the buffer
    void push_back(int element);
   

    // Function to remove an element from the buffer
    void pop_front();    

    // Function to check if the buffer is empty
    bool empty() const;

    // Function to check if the buffer is full
    bool full() const;

    // Function to get the size of the buffer
    int size() const;
    

    // Function to print the elements of the buffer
    void printBuffer() const;    
};
Editor is loading...
Leave a Comment