Java Reference
In-Depth Information
figure 16.26
The enqueue operation
for the linked list-
based implementation
back
...
(a) Before
back
...
x
(b) After
1 /**
2 * Get the least recently inserted item in the queue.
3 * Does not alter the queue.
4 * @return the least recently inserted item in the queue.
5 * @throws UnderflowException if the queue is empty.
6 */
7 public AnyType getFront( )
8 {
9 if( isEmpty( ) )
10 throw new UnderflowException( "ListQueue getFront" );
11 return front.element;
12 }
13
14 /**
15 * Make the queue logically empty.
16 */
17 public void makeEmpty( )
18 {
19 front = null;
20 back = null;
21 }
22
23 /**
24 * Test if the queue is logically empty.
25 */
26 public boolean isEmpty( )
27 {
28 return front == null;
29 }
figure 16.27
Supporting routines
for the ListQueue
class
 
 
Search WWH ::




Custom Search