Queue

Committer:
williequesada
Date:
Tue Jun 04 19:36:36 2019 +0000
Revision:
0:0d3e46cf065b
pablo;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
williequesada 0:0d3e46cf065b 1 #include "Queue.h"
williequesada 0:0d3e46cf065b 2
williequesada 0:0d3e46cf065b 3 int PositionRead=0;
williequesada 0:0d3e46cf065b 4 int PositionPlace=0;
williequesada 0:0d3e46cf065b 5 char Queue[2000];
williequesada 0:0d3e46cf065b 6 char Output;
williequesada 0:0d3e46cf065b 7
williequesada 0:0d3e46cf065b 8 QUEUE::QUEUE()
williequesada 0:0d3e46cf065b 9 {
williequesada 0:0d3e46cf065b 10
williequesada 0:0d3e46cf065b 11 }
williequesada 0:0d3e46cf065b 12
williequesada 0:0d3e46cf065b 13 bool QUEUE::Put(char Input)
williequesada 0:0d3e46cf065b 14 {
williequesada 0:0d3e46cf065b 15 if(PositionPlace<1000){
williequesada 0:0d3e46cf065b 16 Queue[PositionPlace]=Input;
williequesada 0:0d3e46cf065b 17 PositionPlace++;
williequesada 0:0d3e46cf065b 18 return true;
williequesada 0:0d3e46cf065b 19 } else {
williequesada 0:0d3e46cf065b 20 return false;
williequesada 0:0d3e46cf065b 21 }
williequesada 0:0d3e46cf065b 22 }
williequesada 0:0d3e46cf065b 23
williequesada 0:0d3e46cf065b 24 bool QUEUE::Available()
williequesada 0:0d3e46cf065b 25 {
williequesada 0:0d3e46cf065b 26 if(PositionPlace>PositionRead){
williequesada 0:0d3e46cf065b 27 return true;
williequesada 0:0d3e46cf065b 28 } else {
williequesada 0:0d3e46cf065b 29 return false;
williequesada 0:0d3e46cf065b 30 }
williequesada 0:0d3e46cf065b 31 }
williequesada 0:0d3e46cf065b 32
williequesada 0:0d3e46cf065b 33 void QUEUE::Flush()
williequesada 0:0d3e46cf065b 34 {
williequesada 0:0d3e46cf065b 35 for(int i=0;i<1000;i++){
williequesada 0:0d3e46cf065b 36 Queue[i]=0x00;
williequesada 0:0d3e46cf065b 37 }
williequesada 0:0d3e46cf065b 38 PositionPlace=0;
williequesada 0:0d3e46cf065b 39 PositionRead=0;
williequesada 0:0d3e46cf065b 40 }
williequesada 0:0d3e46cf065b 41
williequesada 0:0d3e46cf065b 42 char QUEUE::Get()
williequesada 0:0d3e46cf065b 43 {
williequesada 0:0d3e46cf065b 44 if(PositionPlace>PositionRead){
williequesada 0:0d3e46cf065b 45 Output=Queue[PositionRead];
williequesada 0:0d3e46cf065b 46 PositionRead++;
williequesada 0:0d3e46cf065b 47 return Output;
williequesada 0:0d3e46cf065b 48 } else {
williequesada 0:0d3e46cf065b 49 return 0x00;
williequesada 0:0d3e46cf065b 50 }
williequesada 0:0d3e46cf065b 51 }
williequesada 0:0d3e46cf065b 52
williequesada 0:0d3e46cf065b 53 int QUEUE::Number()
williequesada 0:0d3e46cf065b 54 {
williequesada 0:0d3e46cf065b 55 return(PositionPlace-PositionRead);
williequesada 0:0d3e46cf065b 56 }
williequesada 0:0d3e46cf065b 57
williequesada 0:0d3e46cf065b 58
williequesada 0:0d3e46cf065b 59
williequesada 0:0d3e46cf065b 60
williequesada 0:0d3e46cf065b 61