Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
cola.cpp
00001 #include "cola.h" 00002 #include <stdlib.h> 00003 #include <stdint.h> 00004 #include <stddef.h> 00005 #include <stdbool.h> 00006 #include <assert.h> 00007 00008 00009 void Queue(int front, int rear, int MAX_SIZE) 00010 { 00011 MAX_SIZE = 5; 00012 front = -1; 00013 rear = -1; 00014 } 00015 00016 bool isFull(int front, int rear, int MAX_SIZE) 00017 { 00018 if(front == 0 && rear == MAX_SIZE - 1) 00019 { 00020 return true; 00021 } 00022 return false; 00023 } 00024 00025 bool isEmpty(int front) 00026 { 00027 if(front == -1) 00028 return true; 00029 else 00030 return false; 00031 } 00032 00033 char enQueue(int value, int front, int rear, int myqueue[], int MAX_SIZE) 00034 { 00035 char mensaje; 00036 00037 if(isFull(front, rear, MAX_SIZE)) 00038 mensaje = 'La cola esta llena!!'; 00039 else 00040 { 00041 if(front == -1) 00042 { 00043 front = 0; 00044 rear++; 00045 myqueue[rear] = value; 00046 mensaje = 'EL UID ingresado es: ', value; 00047 //cout << value << " "; 00048 } 00049 } 00050 return mensaje; 00051 } 00052 00053 int deQueue(int front, int rear, int myqueue[]) 00054 { 00055 int value; 00056 if(isEmpty(front)) 00057 { 00058 //cout << "La cola esta vacia, no es posible eliminar ningun UID!!" << endl; 00059 return(-1); 00060 } 00061 else 00062 { 00063 value = myqueue[front]; 00064 if(front >= rear) 00065 { //only one element in queue 00066 front = -1; 00067 rear = -1; 00068 } 00069 else 00070 { 00071 front++; 00072 } 00073 //cout << endl << " UID: " << value << " fue eliminado de la cola"; 00074 return(value); 00075 } 00076 } 00077 00078 /* Function to display elements of Queue */ 00079 char displayQueue(int front, int rear, int myqueue[]) 00080 { 00081 int i; 00082 char mensaje; 00083 if(isEmpty(front)) 00084 { 00085 mensaje = 'La cola esta vacia!!'; 00086 } 00087 else 00088 { 00089 for(i=front; i<=rear; i++) 00090 mensaje = 'Los UID de la cola son: ', myqueue[i], '\n'; 00091 } 00092 return mensaje; 00093 }
Generated on Tue Nov 21 2023 14:07:06 by
1.7.2