public class HeapMemory extends Object implements Memory
Memory.Util| Modifier and Type | Field and Description |
|---|---|
static int |
ARRAY_BASE_OFFSET |
static int |
MAX_SIZE |
| Constructor and Description |
|---|
HeapMemory(byte[] array,
HeapMemoryAllocator allocator) |
| Modifier and Type | Method and Description |
|---|---|
long |
address()
Returns the memory address.
|
long |
address(int offset)
Returns the memory address for the given offset.
|
static HeapMemory |
allocate(int 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(int offset)
Fetches a byte from the given memory offset.
|
char |
getChar(int offset)
Fetches a character from the given memory offset.
|
double |
getDouble(int offset)
Fetches a double from the given memory offset.
|
float |
getFloat(int offset)
Fetches a float from the given memory offset.
|
int |
getInt(int offset)
Fetches an integer from the given memory offset.
|
long |
getLong(int offset)
Fetches a long from the given memory offset.
|
short |
getShort(int offset)
Fetches a short from the given memory offset.
|
int |
offset()
Returns the array base offset.
|
void |
putByte(int offset,
byte b)
Stores a byte at the given memory offset.
|
void |
putChar(int offset,
char c)
Stores a character at the given memory offset.
|
void |
putDouble(int offset,
double d)
Stores a double at the given memory offset.
|
void |
putFloat(int offset,
float f)
Stores a float at the given memory offset.
|
void |
putInt(int offset,
int i)
Stores an integer at the given memory offset.
|
void |
putLong(int offset,
long l)
Stores a long at the given memory offset.
|
void |
putShort(int offset,
short s)
Stores a short at the given memory offset.
|
HeapMemory |
reset(byte[] array)
Resets the memory pointer.
|
int |
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 int ARRAY_BASE_OFFSET
public static final int MAX_SIZE
public HeapMemory(byte[] array,
HeapMemoryAllocator allocator)
public static HeapMemory allocate(int 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(int offset)
Memorypublic int size()
Memorypublic sun.misc.Unsafe unsafe()
public final byte[] array()
public final int offset()
public HeapMemory copy()
Memorypublic byte getByte(int offset)
Memorypublic char getChar(int offset)
Memorypublic short getShort(int offset)
Memorypublic int getInt(int offset)
Memorypublic long getLong(int offset)
Memorypublic float getFloat(int offset)
Memorypublic double getDouble(int offset)
Memorypublic void putByte(int offset,
byte b)
Memorypublic void putChar(int offset,
char c)
Memorypublic void putShort(int offset,
short s)
Memorypublic void putInt(int offset,
int i)
Memorypublic void putLong(int offset,
long l)
Memorypublic void putFloat(int offset,
float f)
Memorypublic void putDouble(int offset,
double d)
Memorypublic void clear()
MemoryCopyright © 2013–2018. All rights reserved.