Group PAG
/
PAG-CourseWork-NicksEdits
Minor fixes
Fork of Coursework by
Diff: Queue.cpp
- Revision:
- 43:4ddc392dd0cc
- Parent:
- 42:4e0a96b52e65
diff -r 4e0a96b52e65 -r 4ddc392dd0cc Queue.cpp --- a/Queue.cpp Wed May 03 13:30:38 2017 +0000 +++ b/Queue.cpp Thu May 04 12:55:16 2017 +0000 @@ -1,29 +1,51 @@ #include "Queue.h" - -void Queue::Queue(){ +Queue::Queue(int i){ + front = 0; + back = 0; + isFull = false; + storage = new Measure[i]; + } + +Queue::Queue(){ front = 0; back = 0; - count = 0; - } -static void Queue::add(Queue q, int i) { - if ((q.back == {size -1) && q.front == 0) || (q.back - q.front = 1)) { - // buffer is full, delete oldies - // put data in front - // front++ back ++ - } else { - q.back = q.back + 1; - q.data [q.back] = i; - } + isFull = false; + storage = new Measure[maxSize]; +} + +void Queue::push(Reading r){ + //if it is full then the front must move. if front is max then it must become 0 + if (isFull == true){ + if (front == maxSize-1){ + front = 0; + } + else{ + front = front +1; + } + } + back = back +1; + storage[back] = r; + //otherwise the queue is full + else{ + + } +} +void Queue::read(int nR){// where nR is the number to read, if REAL ALL is typed then the method will be called by something like queue.read(Queue.count). + if (front>back){ + for( int a = back; a >=0; a = a - 1 ) { + //print or cout? do until end of loop - think about how to loop over + } + } + for( int a = maxSize-1; a >front; a = a + 1 ) { + //print or cout? do until end of loop - think about how to loop over + } + + -static int Queue::remove(Queue q) { - if (q.back < 0) { - printf("Queue remove ERROR"); - return(-1); - } else { - int temporary = q.data[0]; - q.back = q.back -1; - return (temporary); - } -} +} +void Queue::deleteRecords(int nD){ //as above but nD is number to delete + + +} \ No newline at end of file