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

persistence.PersistentArray Maven / Gradle / Ivy

The newest version!
package persistence;

public final class PersistentArray extends PersistentObject implements Array {
	public PersistentArray() {
	}

	@SuppressWarnings("unchecked")
	public PersistentArray(final Store store, C component[]) {
		this(store, (Class)component.getClass().getComponentType(), component.length);
		copy(component, 0, this, 0, component.length);
	}

	public PersistentArray(final Store store, final Class componentType, final int length) {
		super(store, new ArrayClass<>(store, componentType, length));
	}

	@SuppressWarnings("unchecked")
	private ArrayClass arrayClass() {
		return (ArrayClass)clazz;
	}

	public int length() {
		return arrayClass().getLength();
	}

	public char typeCode() {
		return arrayClass().getTypeCode();
	}

	public C get(int index) {
		return get(arrayClass().getField(index));
	}

	public void set(int index, C value) {
		set(arrayClass().getField(index),value);
	}

	public static  void copy(Array src, int src_position, Array dst, int dst_position, int length) {
		if(src_position=0;i--) dst.set(dst_position+i,src.get(src_position+i));
		else for(int i=0;i void copy(C src[], int src_position, Array dst, int dst_position, int length) {
		if(src_position=0;i--) dst.set(dst_position+i,src[src_position+i]);
		else for(int i=0;i void copy(Array src, int src_position, C dst[], int dst_position, int length) {
		if(src_position=0;i--) dst[dst_position+i]=src.get(src_position+i);
		else for(int i=0;i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy