All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.stanford.nlp.util.ArrayIterable Maven / Gradle / Ivy

package edu.stanford.nlp.util;

import java.util.Iterator;

/**
 * @author Gabor Angeli (angeli at cs.stanford)
 */
public class ArrayIterable implements Iterable {
  public final E[] data;
  
  public ArrayIterable(E[] data){
    this.data = data;
  }

  public Iterator iterator() {
    return new Iterator(){
      int i=0;
      public boolean hasNext() {
        return i < data.length;
      }
      public E next() {
        i += 1;
        return data[i-1];
      }
      public void remove() {
        throw new RuntimeException("Cannot remove from this Iterator");
      }
    };
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy