public class HeapMemory extends Object implements Memory
Memory.Util| Modifier and Type | Field and Description |
|---|---|
static long |
ARRAY_BASE_OFFSET |
static long |
MAX_SIZE |
| Constructor and Description |
|---|
HeapMemory(byte[] array,
HeapMemoryAllocator allocator) |
| Modifier and Type | Method and Description |
|---|---|
long |
address()
Returns the memory address.
|
long |
address(long offset)
Returns the memory address for the given offset.
|
static HeapMemory |
allocate(long size)
Allocates heap memory via
HeapMemoryAllocator. |
HeapMemoryAllocator |
allocator()
Returns the memory allocator that allocated this memory.
|
byte[] |
array()
Returns the underlying byte array.
|
void |
clear()
Clears the memory.
|
HeapMemory |
copy()
Copies the memory to a distinct memory address.
|
void |
free()
Frees the memory.
|
byte |
getByte(long offset)
Fetches a byte from the given memory offset.
|
char |
getChar(long offset)
Fetches a character from the given memory offset.
|
double |
getDouble(long offset)
Fetches a double from the given memory offset.
|
float |
getFloat(long offset)
Fetches a float from the given memory offset.
|
int |
getInt(long offset)
Fetches an integer from the given memory offset.
|
long |
getLong(long offset)
Fetches a long from the given memory offset.
|
short |
getShort(long offset)
Fetches a short from the given memory offset.
|
long |
offset()
Returns the array base offset.
|
void |
putByte(long offset,
byte b)
Stores a byte at the given memory offset.
|
void |
putChar(long offset,
char c)
Stores a character at the given memory offset.
|
void |
putDouble(long offset,
double d)
Stores a double at the given memory offset.
|
void |
putFloat(long offset,
float f)
Stores a float at the given memory offset.
|
void |
putInt(long offset,
int i)
Stores an integer at the given memory offset.
|
void |
putLong(long offset,
long l)
Stores a long at the given memory offset.
|
void |
putShort(long offset,
short s)
Stores a short at the given memory offset.
|
HeapMemory |
reset(byte[] array)
Resets the memory pointer.
|
long |
size()
Returns the memory count.
|
sun.misc.Unsafe |
unsafe()
Returns the native Unsafe memory object.
|
static HeapMemory |
wrap(byte[] bytes)
Wraps the given bytes in a
HeapMemory object. |
public static final long ARRAY_BASE_OFFSET
public static final long MAX_SIZE
public HeapMemory(byte[] array,
HeapMemoryAllocator allocator)
public static HeapMemory allocate(long size)
HeapMemoryAllocator.size - The count of the memory to allocate.IllegalArgumentException - If count is greater than the maximum allowed count for
an array on the Java heap - Integer.MAX_VALUE - 5public static HeapMemory wrap(byte[] bytes)
HeapMemory object.bytes - The bytes to wrap.public HeapMemoryAllocator allocator()
Memorypublic final long address()
Memorypublic HeapMemory reset(byte[] array)
array - The memory array.public final long address(long offset)
Memorypublic long size()
Memorypublic sun.misc.Unsafe unsafe()
public final byte[] array()
public final long offset()
public HeapMemory copy()
Memorypublic byte getByte(long offset)
Memorypublic char getChar(long offset)
Memorypublic short getShort(long offset)
Memorypublic int getInt(long offset)
Memorypublic long getLong(long offset)
Memorypublic float getFloat(long offset)
Memorypublic double getDouble(long offset)
Memorypublic void putByte(long offset,
byte b)
Memorypublic void putChar(long offset,
char c)
Memorypublic void putShort(long offset,
short s)
Memorypublic void putInt(long offset,
int i)
Memorypublic void putLong(long offset,
long l)
Memorypublic void putFloat(long offset,
float f)
Memorypublic void putDouble(long offset,
double d)
Memorypublic void clear()
MemoryCopyright © 2013–2015. All rights reserved.