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

com.softicar.platform.common.container.array.IntArrayAdapter Maven / Gradle / Ivy

Go to download

The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.

There is a newer version: 50.0.0
Show newest version
package com.softicar.platform.common.container.array;

import java.util.AbstractList;
import java.util.Iterator;

/**
 * An adapter for integer arrays.
 * 
 * @author Oliver Richers
 */
public class IntArrayAdapter extends AbstractList {

	protected int[] array;

	protected IntArrayAdapter(int[] array) {

		this.array = array;
	}

	public static IntArrayAdapter get(int[] array) {

		return new IntArrayAdapter(array);
	}

	@Override
	public Integer get(int index) {

		return array[index];
	}

	@Override
	public int size() {

		return array.length;
	}

	@Override
	public Iterator iterator() {

		return new IntArrayIterator();
	}

	protected class IntArrayIterator implements Iterator {

		int index = 0;

		@Override
		public boolean hasNext() {

			return index < array.length;
		}

		@Override
		public Integer next() {

			return get(index++);
		}

		@Override
		public void remove() {

			throw new UnsupportedOperationException();
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy