Java Reference
In-Depth Information
if (!isEmpty())
front = queue[frontIndex];
return front;
} // end getFront
This operation is O(1).
FIGURE 11-8
A seven-location circular array that contains at most six entries
of a queue
(a)
0
1
2
3
4
5
6
0
frontIndex
6
backIndex
Empty queue
(b)
0
1
2
3
4
5
6
0
frontIndex
0
backIndex
(c)
0
1
2
3
4
5
6
0
frontIndex
5
backIndex
Full queue
(d)
0
1
2
3
4
5
6
1
frontIndex
5
backIndex
(e)
0
1
2
3
4
5
6
1
frontIndex
backIndex
6
Full queue
(f)
0
1
2
3
4
5
6
2
frontIndex
6
backIndex
(g)
0
1
2
3
4
5
6
2
frontIndex
backIndex
0
Full queue
(h)
0
1
2
3
4
5
6
3
frontIndex
backIndex
0
(i)
0
1
2
3
4
5
6
0
frontIndex
0
backIndex
(j)
0
1
2
3
4
5
6
1
frontIndex
backIndex
0
Empty queue
 
Search WWH ::




Custom Search