Package railo.runtime.type.it

Source Code of railo.runtime.type.it.KeyIterator

package railo.runtime.type.it;

import java.util.Enumeration;
import java.util.Iterator;

import railo.runtime.type.Collection;
import railo.runtime.type.Collection.Key;

/**
* Iterator Implementation for a Object Array
*/
public final class KeyIterator implements Iterator<Collection.Key>,Enumeration<Collection.Key> {
 
  private Collection.Key[] arr;
  private int pos;

  /**
   * constructor for the class
   * @param arr Base Array
   */
  public KeyIterator(Collection.Key[] arr) {
   
    this.arr=arr==null?new Collection.Key[0]:arr;
    this.pos=0;
  }

  @Override
  public void remove() {
    throw new UnsupportedOperationException("this operation is not suppored");
  }

  @Override
  public boolean hasNext() {
    return (arr.length)>pos;
  }

  @Override
  public Collection.Key next() {
    Key key = arr[pos++];
    if(key==null) return null;
    return key;
  }

  public boolean hasMoreElements() {
    return hasNext();
  }

  public Collection.Key nextElement() {
    return next();
  }
}
TOP

Related Classes of railo.runtime.type.it.KeyIterator

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.