Data Structures and Algorithms
with Object-Oriented Design Patterns in Java
.
.
.
Use the Array class given in Chapter
to keep track of the contents of the bag.
,
this time using the LinkedList class given in Chapter
.public interface Iterator
{
void init ();
boolean test ();
void inc ();
Object current ();
}
Given an iterator i from some container c,
the contents of c can be printed like this:
for (i.init(); i.test(); i.inc())
System.out.println (i.current());
Devise a wrapper class to encapsulate an enumeration
and provide the functionality of an iterator.
Copyright © 1998 by Bruno R. Preiss, P.Eng. All rights reserved.