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

org.psjava.ds.array.MutableSubArray Maven / Gradle / Ivy

There is a newer version: 0.1.19
Show newest version
package org.psjava.ds.array;

import java.util.Iterator;

import org.psjava.util.IterableToString;

public class MutableSubArray {
	// TODO impl equals

	public static  MutableArray wrap(final MutableArray original, final int start, final int end) {
		return new MutableArray() {
			@Override
			public T get(int index) {
				return original.get(start + index);
			}
			@Override
			public void set(int index, T value) {
				original.set(start + index, value);				
			}
			@Override
			public boolean isEmpty() {
				return size() == 0;
			}
			@Override
			public Iterator iterator() {
				return ArrayIterator.create(this);
			}
			@Override
			public int size() {
				return end - start;
			}

			@Override
			public String toString() {
				return IterableToString.toString(this);
			}
		};
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy