A Bridge Using the List Interface
Drivers offer good examples of the Bridge pattern, but you can apply Bridge in other situations, too. Whenever you separate an abstractiona class that relies on a set of abstract operationsfrom the implementation of its abstract operations, you have applied Bridge.
Consider the Queue class in use at Oozinoz. When using a list to model a conveyor, you have discovered that it is easy to get confused about which end of the list applies to which end of a conveyor. To avoid this confusion, Oozinoz developers always define the ends of the conveyor as the conveyor's tail and head and define that the belt moves from the tail toward the head. Placing material on the tail of a conveyor enqueues the material on the conveyor; removing material from the head dequeues the material from the conveyor. Figure 6.7 shows the Queue class. The add() method adds an object to the tail of a list, and a call to remove(0) removes the head of a list.
Figure 6.7: The Queue class defines operations that rely on an abstract List object.
Write the code for dequeue() and enqueue().
A solution appears on page 373.