ListEnumeration.java

jmud-0.11/src/util/list/ListEnumeration.java · 541 B

From the archive jmud-0_11.tgz

Download the archive   « Back to the archive contents

package util.list;

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

class ListEnumeration implements Enumeration {

  private ListLink cursor = null;

  public ListEnumeration(List aList) {
    cursor = aList.getHead();
  }

  public boolean hasMoreElements() {
    return cursor != null;
  }

  public Object nextElement() throws NoSuchElementException {
    if (!hasMoreElements())
      throw new NoSuchElementException();
    Object info = cursor.getInfo();
    cursor = cursor.getNext();
    return info;
  }
}

Site Stats

Snippets: 1791
Codebases: 571