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

org.antlr.stringtemplate.language.ArrayWrappedInList Maven / Gradle / Ivy

There is a newer version: 1.3.3
Show newest version
package org.antlr.stringtemplate.language;

import java.util.ArrayList;
import java.util.Iterator;
import java.lang.reflect.Array;

/** Turn an array into a List; subclass ArrayList for easy development, but
 *  it really doesn't use super stuff for anything.  Ensure we create
 *  ArrayIterator for this List.
 */
public class ArrayWrappedInList extends ArrayList {
	protected Object array = null;
	/** Arrays are fixed size; precompute. */
	protected int n;

	public ArrayWrappedInList(Object array) {
		this.array = array;
		n = Array.getLength(array);
	}

	public Object get(int i) {
		return Array.get(array, i);
	}

	public int size() {
		return n;
	}

	public boolean isEmpty() {
		return n==0;
	}

	public Object[] toArray() {
		return (Object[])array;
	}

	public Iterator iterator() {
		return new ArrayIterator(array);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy