Proyecto ABInBev para la tarjeta Guaria 1/2.

Revision:
1:9e821e640117
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/VoicePlaylist/playlist.cpp	Fri Jul 01 12:45:55 2022 -0600
@@ -0,0 +1,105 @@
+/**
+ * @file playlist.cpp
+ * @author Felícito Manzano (felicito.manzano@detektor.com.sv)
+ * @brief 
+ * @version 0.1
+ * @date 2020-11-19
+ * 
+ * @copyright Copyright (c) 2020
+ * 
+ */
+
+#include "playlist.hpp"
+extern int      items_queue;
+
+// Constructor to initialize queue
+queue::queue(int size)
+{
+	arr = new int[size];
+	capacity = size;
+	front = 0;
+	rear = -1;
+	count = 0;
+}
+
+// Destructor to free memory allocated to the queue
+queue::~queue()
+{
+	delete[] arr;
+}
+
+// Utility function to remove front element from the queue
+void queue::dequeue()
+{
+	// check for queue underflow
+	if (isEmpty())
+	{
+		//cout << "UnderFlow\nProgram Terminated\n";
+		exit(EXIT_FAILURE);
+	}
+
+	//cout << "Removing " << arr[front] << '\n';
+
+	front = (front + 1) % capacity;
+	count--;
+	items_queue--;
+}
+
+// Utility function to add an item to the queue
+void queue::enqueue(int item)
+{
+	// check for queue overflow
+	if (isFull())
+	{
+//		cout << "OverFlow\nProgram Terminated\n";
+		exit(EXIT_FAILURE);
+	}
+
+	//cout << "Inserting " << item << '\n';
+
+	rear = (rear + 1) % capacity;
+	arr[rear] = item;
+	count++;
+	items_queue++;
+}
+
+// Utility function to return front element in the queue
+int queue::peek()
+{
+	if (isEmpty())
+	{
+		//cout << "UnderFlow\nProgram Terminated\n";
+		exit(EXIT_FAILURE);
+	}
+	return arr[front];
+}
+
+// Utility function to return the size of the queue
+int queue::size()
+{
+	return count;
+}
+
+// Funcion agregada para limpiar items directamente
+/*
+void queue::erase()
+{
+	memset(arr, '\0', sizeof(arr));
+	front = 0;
+	rear = -1;
+	count = 0;
+	
+}
+*/
+
+// Utility function to check if the queue is empty or not
+bool queue::isEmpty()
+{
+	return (size() == 0);
+}
+
+// Utility function to check if the queue is full or not
+bool queue::isFull()
+{
+	return (size() == capacity);
+}
\ No newline at end of file