5.1 Introduction

In C++, OEChem introduces a special iterator class, OEIter, that is use to iterate over all the different collection of objects. In C++, OEIter is a template class, allowing it to be specialized for the actual object type wrapped by the iterator.

In the Java wrappers, we have included specific derived versions of OEIter for each object that can be wrapped. This iterators include:

This chapter will cover the basic use of OEIter's, and each different type will be used in context in subsequent chapters.

In an attempt to make these Java versions of OEIter behave like Java iterators and also to allow the complete flexibility provided by the C++ class, OEIter's in Java provide a Java-like and C-like syntax for iteration in a for loop. Both have uses, but it is important not to mix the two syntaxes in the same loop.

For all of these examples, we will use iteration of the atoms in a molecule. This subject will also be covered in much more detail in chapter .