Sorry for ignoring the answers for so long, I was away from my PC for a few days.
I have looked at the code again, and it seems that when i follow the code through using breakpoints, the two ints do change values, but then they change to what they should be after the function ends, so it does seem that it is actually working correctly, and it must have been somewhere else causing my issues.
- in enqueue() you consider rearQ == size - 1 as full, however size-1 is a valid index for an array
- in dequeue() you say frontQ == rearQ is an empty queue, however you still dequeue that element
- Â¿does rearQ points to the last element or one past the last element?
- you could wrap around the array in order to use the space available after a dequeue operation
- Â¿why enqueue() and dequeue() don't make use of isEmpty() and instead define their own empty criteria?
First point : Yup I hadnt noticed that, I will need to rework it again.
- Im not sure where you mean with this one, the first frontQ == rearQ is dequeue, is to dequeue the last remaining element, then the second frontQ== rearQ is for when the last element is dequeued. At least thats my thinking behind it, it might not actually be working like that.
-rearQ points to the last element
- Is that the same as a circularArray, I have only last week learned that circular arrays were a thing, and I have implemented one into the queue, but I am trying to code both types as I am learning data structures, and want the practice
- I do not know, I will fix that though. Ive been learning for about a year now, and still making dumb mistakes like this.