📄 mutablememory.java
字号:
copyNativeDataBlock(dataAddress+dataStoreOffset, source.dataAddress, source.highWaterMark);
dataStoreOffset += source.highWaterMark;
// if(dataStoreOffset > highWaterMark)
highWaterMark = dataStoreOffset;
return this;
}
/**
* Copies from a boolean.
* The data is copied starting at the current value of the dataStoreOffset.
* The dataStoreOffset is updated after the operation.
* @param data The data item to be copied.
* @throws NoRoomException This exception is thrown if an attempt is made to write outside
* the allocated area.
*/
public MutableMemory copyBoolean(boolean data) throws NoRoomException
{
if(dataStoreOffset+1 > allocatedSize) throw new NoRoomException();
setBoolean(dataAddress+dataStoreOffset, data);
dataStoreOffset += 1;
if(dataStoreOffset > highWaterMark)
highWaterMark = dataStoreOffset;
return this;
}
/**
* Copies from a char.
* @see #setBoolean(boolean)
*/
public MutableMemory copyChar(char data) throws NoRoomException
{
if(dataStoreOffset+2 > allocatedSize) throw new NoRoomException();
setChar(dataAddress+dataStoreOffset, data);
dataStoreOffset += 2;
if(dataStoreOffset > highWaterMark)
highWaterMark = dataStoreOffset;
return this;
}
/**
* Copies from a byte.
* @see #setBoolean(boolean)
*/
public MutableMemory copyByte(byte data) throws NoRoomException
{
if(dataStoreOffset+1 > allocatedSize) throw new NoRoomException();
setByte(dataAddress+dataStoreOffset, data);
dataStoreOffset += 1;
if(dataStoreOffset > highWaterMark)
highWaterMark = dataStoreOffset;
return this;
}
/**
* Copies from a short.
* @see #setBoolean(boolean)
*/
public MutableMemory copyShort(short data) throws NoRoomException
{
if(dataStoreOffset+2 > allocatedSize) throw new NoRoomException();
setShort(dataAddress+dataStoreOffset, data);
dataStoreOffset += 2;
if(dataStoreOffset > highWaterMark)
highWaterMark = dataStoreOffset;
return this;
}
/**
* Copies from an int.
* @see #setBoolean(boolean)
*/
public MutableMemory copyInt(int data) throws NoRoomException
{
if(dataStoreOffset+4 > allocatedSize) throw new NoRoomException();
setInt(dataAddress+dataStoreOffset, data);
dataStoreOffset += 4;
if(dataStoreOffset > highWaterMark)
highWaterMark = dataStoreOffset;
return this;
}
/**
* Copies from a long.
* @see #setBoolean(boolean)
*/
public MutableMemory copyLong(long data) throws NoRoomException
{
if(dataStoreOffset+8 > allocatedSize) throw new NoRoomException();
setLong(dataAddress+dataStoreOffset, data);
dataStoreOffset += 8;
if(dataStoreOffset > highWaterMark)
highWaterMark = dataStoreOffset;
return this;
}
/**
* Copies from a long.
* @see #setBoolean(boolean)
*/
public MutableMemory copyFloat(float data) throws NoRoomException
{
if(dataStoreOffset+4 > allocatedSize) throw new NoRoomException();
setFloat(dataAddress+dataStoreOffset, data);
dataStoreOffset += 4;
if(dataStoreOffset > highWaterMark)
highWaterMark = dataStoreOffset;
return this;
}
/**
* Copies from a double.
* @see #setBoolean(boolean)
*/
public MutableMemory copyDouble(double data) throws NoRoomException
{
if(dataStoreOffset+8 > allocatedSize) throw new NoRoomException();
setDouble(dataAddress+dataStoreOffset, data);
dataStoreOffset += 8;
if(dataStoreOffset > highWaterMark)
highWaterMark = dataStoreOffset;
return this;
}
/**
* Copies from a String.
* @see #setBoolean(boolean)
*/
public MutableMemory copyString(String data) throws NoRoomException
{
int length = data.length()+1;
if(dataStoreOffset+length > allocatedSize) throw new NoRoomException();
setString (dataAddress+dataStoreOffset, data);
dataStoreOffset += length;
if(dataStoreOffset > highWaterMark)
highWaterMark = dataStoreOffset;
return this;
}
/**
* Copies from a boolean data array.
* The data is copied starting at the current value of the dataStoreOffset.
* The dataStoreOffset is updated after the operation.
* @param array The data array to be copied.
* @param arrayOffset The offset (in elements) in the data array from where the copy should start.
* @param length The number of elements from the data array to be copied.
* @return A copy of reference to this.
*/
public MutableMemory copyFromBooleanArray(boolean[] array, int arrayOffset, int length) throws NoRoomException
{
int size = length*1;
if(dataStoreOffset+size > allocatedSize) throw new NoRoomException();
copyFromBooleanArray(dataAddress+dataStoreOffset, array, arrayOffset, length);
dataStoreOffset += size;
if(dataStoreOffset > highWaterMark)
highWaterMark = dataStoreOffset;
return this;
}
/**
* Copies from a char data array.
* @see #copyFromBooleanArray(boolean[], int, int)
*/
public MutableMemory copyFromCharArray (char[] array, int arrayOffset, int length) throws NoRoomException
{
int size = length*2;
if(dataStoreOffset+size > allocatedSize) throw new NoRoomException();
copyFromCharArray(dataAddress+dataStoreOffset, array, arrayOffset, length);
dataStoreOffset += size;
if(dataStoreOffset > highWaterMark)
highWaterMark = dataStoreOffset;
return this;
}
/**
* Copies from a byte data array.
* @see #copyFromBooleanArray(boolean[], int, int)
*/
public MutableMemory copyFromByteArray (byte[] array, int arrayOffset, int length) throws NoRoomException
{
int size = length*1;
if(dataStoreOffset+size > allocatedSize) throw new NoRoomException();
copyFromByteArray(dataAddress+dataStoreOffset, array, arrayOffset, length);
dataStoreOffset += size;
if(dataStoreOffset > highWaterMark)
highWaterMark = dataStoreOffset;
return this;
}
/**
* Copies from a short data array.
* @see #copyFromBooleanArray(boolean[], int, int)
*/
public MutableMemory copyFromShortArray (short[] array, int arrayOffset, int length) throws NoRoomException
{
int size = length*2;
if(dataStoreOffset+size > allocatedSize) throw new NoRoomException();
copyFromShortArray(dataAddress+dataStoreOffset, array, arrayOffset, length);
dataStoreOffset += size;
if(dataStoreOffset > highWaterMark)
highWaterMark = dataStoreOffset;
return this;
}
/**
* Copies from a int data array.
* @see #copyFromBooleanArray(boolean[], int, int)
*/
public MutableMemory copyFromIntArray (int[] array, int arrayOffset, int length) throws NoRoomException
{
int size = length*4;
if(dataStoreOffset+size > allocatedSize) throw new NoRoomException();
copyFromIntArray(dataAddress+dataStoreOffset, array, arrayOffset, length);
dataStoreOffset += size;
if(dataStoreOffset > highWaterMark)
highWaterMark = dataStoreOffset;
return this;
}
/**
* Copies from a long data array.
* @see #copyFromBooleanArray(boolean[], int, int)
*/
public MutableMemory copyFromLongArray (long[] array, int arrayOffset, int length) throws NoRoomException
{
int size = length*8;
if(dataStoreOffset+size > allocatedSize) throw new NoRoomException();
copyFromLongArray(dataAddress+dataStoreOffset, array, arrayOffset, length);
dataStoreOffset += size;
if(dataStoreOffset > highWaterMark)
highWaterMark = dataStoreOffset;
return this;
}
/**
* Copies from a float data array.
* @see #copyFromBooleanArray(boolean[], int, int)
*/
public MutableMemory copyFromFloatArray (float[] array, int arrayOffset, int length) throws NoRoomException
{
int size = length*4;
if(dataStoreOffset+size > allocatedSize) throw new NoRoomException();
copyFromFloatArray(dataAddress+dataStoreOffset, array, arrayOffset, length);
dataStoreOffset += size;
if(dataStoreOffset > highWaterMark)
highWaterMark = dataStoreOffset;
return this;
}
/**
* Copies from a double data array.
* @see #copyFromBooleanArray(boolean[], int, int)
*/
public MutableMemory copyFromDoubleArray (double[] array, int arrayOffset, int length) throws NoRoomException
{
int size = length*8;
if(dataStoreOffset+size > allocatedSize) throw new NoRoomException();
copyFromDoubleArray(dataAddress+dataStoreOffset, array, arrayOffset, length);
dataStoreOffset += size;
if(dataStoreOffset > highWaterMark)
highWaterMark = dataStoreOffset;
return this;
}
/**
* Copies from a boolean data array.
* The data is copied starting at the current value of the dataStoreOffset.
* The dataStoreOffset is updated after the operation.
* @param array The data array to be copied.
* @return A copy of reference to this.
*/
public MutableMemory copyFromBooleanArray(boolean[] array) throws NoRoomException { return copyFromBooleanArray(array, 0, array.length); }
/**
* Copies from a byte data array.
* @see #copyFromBooleanArray(boolean[])
*/
public MutableMemory copyFromByteArray(byte[] array) throws NoRoomException { return copyFromByteArray(array, 0, array.length); }
/**
* Copies from a byte data array.
* @see #copyFromBooleanArray(boolean[])
*/
public MutableMemory copyFromCharArray(char[] array) throws NoRoomException { return copyFromCharArray(array, 0, array.length); }
/**
* Copies from a byte data array.
* @see #copyFromBooleanArray(boolean[])
*/
public MutableMemory copyFromShortArray(short[] array) throws NoRoomException { return copyFromShortArray(array, 0, array.length); }
/**
* Copies from a byte data array.
* @see #copyFromBooleanArray(boolean[])
*/
public MutableMemory copyFromIntArray(int[] array) throws NoRoomException { return copyFromIntArray(array, 0, array.length); }
/**
* Copies from a byte data array.
* @see #copyFromBooleanArray(boolean[])
*/
public MutableMemory copyFromLongArray(long[] array) throws NoRoomException { return copyFromLongArray(array, 0, array.length); }
/**
* Copies from a byte data array.
* @see #copyFromBooleanArray(boolean[])
*/
public MutableMemory copyFromFloatArray(float[] array) throws NoRoomException { return copyFromFloatArray(array, 0, array.length); }
/**
* Copies from a byte data array.
* @see #copyFromBooleanArray(boolean[])
*/
public MutableMemory copyFromDoubleArray(double[] array) throws NoRoomException { return copyFromDoubleArray(array, 0, array.length); }
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -