Generator Class

A custom iterator that yields its values one at a time. This is a great alternative to arrays or lists when dealing with large data. By yielding one entry at a time, this iterator can help avoid out of memory exceptions. Subclasses must define a method called {@link #run()} and may call {@link yield(T)} to return values one at a time. Example:
    Generator<String> generator = new Generator<String>() {

        @Override
        public void run() {

            BufferedReader br = file.getBufferedReader("UTF-8");

            String row;
            while ((row = br.readLine()) != null){
                yield(row);
            }

            br.close();
        }
    };  
Clients can iterate through the generated results using standard iterators or an enhanced for loop like this:
    for (String row : generator){
        System.out.println(row);
    }  

Constructors

There are no public constructors.

Public Methods

iterator( ) returns Iterator<T>
close( ) returns void