Q:

Java For Loop in an Array

This question is probably best suited towards anyone with some insight into disk read scheduling.
I have the code:
for(int i = readqueue_tail; i<readqueue_head; i++) 

I then use i to access elements in a readqueue array, which goes up to 255. However, once the queue is filled, it starts filling again from 0 (as these requests will have been serviced it doesn't matter).
The issue I'm having is searching from the tail up to the readqueue_head as when the head loops round and goes past 0 again the loop condition fails. How would I go about fixing this?

A:

Other options is just use modulo.
int i = readqueue_tail;
while (i != readqueue_head)
{
    i = (i + 1) % 256;
}

