VectorEnumeration.java

jmud-0.11/src/util/jgp/adaptor/VectorEnumeration.java · 568 B

From the archive jmud-0_11.tgz

Download the archive   « Back to the archive contents

package util.jgp.adaptor;

import java.util.NoSuchElementException;
import java.util.Enumeration;

import util.jgp.container.Vector;

public class VectorEnumeration implements Enumeration {

  private Vector vect   = null;
  private int    cursor = 0;

  public VectorEnumeration(Vector v) {
    vect = v;
  }

  public boolean hasMoreElements() {
    return cursor < vect.getSize();
  }

  public Object nextElement() throws NoSuchElementException {
    if (!hasMoreElements())
      throw new NoSuchElementException();

    return vect.getElementAt(cursor++);
  }
}

Site Stats

Snippets: 1791
Codebases: 571