Queue

Dependents:   Queue_Funcional

Files at this revision

API Documentation at this revision

Comitter:
williequesada
Date:
Tue Jun 04 16:54:25 2019 +0000
Commit message:
pablo

Changed in this revision

Queue.cpp Show annotated file Show diff for this revision Revisions of this file
Queue.h Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 6753b35bf817 Queue.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Queue.cpp	Tue Jun 04 16:54:25 2019 +0000
@@ -0,0 +1,61 @@
+#include "Queue.h"
+
+int     PositionRead=0;
+int     PositionPlace=0;
+char    Queue[2000];
+char    Output;
+ 
+QUEUE::QUEUE()
+{
+    
+}
+ 
+bool QUEUE::Put(char Input)
+{
+    if(PositionPlace<1000){
+        Queue[PositionPlace]=Input;
+        PositionPlace++;
+        return true;
+    } else {
+        return false;
+    }
+}
+
+bool QUEUE::Available()
+{
+    if(PositionPlace>PositionRead){
+        return true;
+    } else {
+        return false;
+    }
+}
+
+void QUEUE::Flush()
+{
+    for(int i=0;i<1000;i++){
+        Queue[i]=0x00;
+    }
+    PositionPlace=0;
+    PositionRead=0;  
+}
+ 
+char QUEUE::Get()
+{
+    if(PositionPlace>PositionRead){
+        Output=Queue[PositionRead];  
+        PositionRead++;  
+        return Output; 
+    } else {
+        return 0x00;
+    }
+}
+
+int QUEUE::Number()
+{
+    return(PositionPlace-PositionRead);
+}
+ 
+
+
+ 
+ 
\ No newline at end of file
diff -r 000000000000 -r 6753b35bf817 Queue.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Queue.h	Tue Jun 04 16:54:25 2019 +0000
@@ -0,0 +1,16 @@
+#ifndef MBED_QUEUE_H
+#define MBED_QUEUE_H
+ 
+#include "mbed.h"
+ 
+class QUEUE {
+public:
+    QUEUE();
+    
+    bool Put(char Input);      
+    void Flush();
+    char Get();  
+    int  Number(); 
+    bool Available();
+};
+#endif