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

xapi.collect.impl.ArrayIterable Maven / Gradle / Ivy

Go to download

Everything needed to run a comprehensive dev environment. Just type X_ and pick a service from autocomplete; new dev modules will be added as they are built. The only dev service not included in the uber jar is xapi-dev-maven, as it includes all runtime dependencies of maven, adding ~4 seconds to build time, and 6 megabytes to the final output jar size (without xapi-dev-maven, it's ~1MB).

The newest version!
package xapi.collect.impl;

import java.util.Iterator;

import xapi.except.NotImplemented;

public class ArrayIterable  implements Iterable {

  private final E[] array;

  private final class Itr implements Iterator {
    int pos = 0, end = array.length;
    @Override
    public boolean hasNext() {
      return pos < end;
    }
    @Override
    public E next() {
      return array[pos++];
    }
    @Override
    public void remove() {
      ArrayIterable.this.remove(array[pos-1]);
    }
  }

  public ArrayIterable(E[] array) {
    this.array = array;
  }

  @Override
  public Iterator iterator() {
    return new Itr();
  }

  protected void remove(E key) {
    throw new NotImplemented("ArrayIterable does not support remove");
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy