T
- target type of the pointer.public class CPointerMutable<T> extends CPointer<T>
CPointer
.
Mutable pointers allow in-place modification of the pointers address and thereby advanced pointer arithmetics (better runtime performance). Please note, that modifications to the address will not be reflected in the memory region this pointer originated from.
You receive a mutable variant of a pointer either by using
one of the copy constructors CPointerMutable(CPointer)
or CPointerMutable(CPointer, long)
or by calling
the method CPointer.mutable()
.
Read documentation of CPointer
first, to understand this
section.
CPointerMutable
inherits the methods of CPointer
.
Since references to objects of CPointerMutable
can be
assigned to CPointer
, the method plus(int)
has
to behave exactly like CPointer.plus(int)
and return a
new instance of CPointerMutable
.
The method add(int)
now provides the functionality of
plus(int)
with in-place modification, meaning the address
of the pointer object, on which the method was called, will be
changed afterwards.
Furthermore, mutable pointers support direct modification of their
address by use of the methods assign(long)
and
assign(CPointer)
.
targetSize, targetTypeList
__io__address, __io__arch_index, __io__block, __io__blockTable, __io__pointersize
Constructor and Description |
---|
CPointerMutable(CPointer<T> pointer)
Constructor to turn a pointer into a mutable pointer.
|
CPointerMutable(CPointer<T> pointer,
long address) |
Modifier and Type | Method and Description |
---|---|
CPointerMutable<T> |
add(int increment)
|
void |
assign(CPointer<T> address)
Equivalent to
|
void |
assign(long address)
Equivalent to
|
CPointerMutable<T> |
plus(int value)
|
long |
value()
Returns the value of the address.
|
__get, __set, cast, cast, cast, equals, fromArray, fromArray, fromArray, fromArray, fromArray, fromArray, fromArray, fromArray, fromArray, fromArray, fromArray, fromArray, fromInt64Array, fromInt64Array, get, getAddress, getCFacade, getScalar, hashCode, isNull, isPrimitive, isValid, mutable, set, setScalar, toArray, toArray, toArray, toArray, toArray, toArray, toArray, toArrayInt64, toByteArray, toCArrayFacade, toDoubleArray, toFloatArray, toInt64Array, toIntArray, toLongArray, toShortArray
__io__addressof, __io__addressof, __io__equals, __io__generic__copy, __io__generic__copy, __io__instanceof, __io__native__copy, __io__newInstance, __io__same__encoding, __io__sizeof, __io__sizeof, __io__subclassof
public CPointerMutable(CPointer<T> pointer)
pointer
- public CPointerMutable<T> add(int increment)
add(int)
is different to plus(int)
.
While add(int)
modifies the address in-place
plus(int)
returns a new instance with the result
of the addition.
Equivalent to
int* p; (p += increment);Value of the pointer will be changed in place.
increment
- public CPointerMutable<T> plus(int value) throws java.io.IOException
add(int)
is different to plus(int)
.
While add(int)
modifies the address in-place
plus(int)
returns new instance with the result
of the addition.
Allows (almost) equivalent handling as operator.
int *p, *a; a = p = .. ; a = (p+1)+1;same as
CPointerMutablewhere the post conditionp, a; p = a = .. ; p = (p.plus(1)).plus(1);
post condition: (p != a)holds.
public void assign(long address) throws java.io.IOException
int* p; int* a = ..; p = a;
address
- java.io.IOException
public void assign(CPointer<T> address) throws java.io.IOException
int* p; int* a = ..; p = a;
address
- java.io.IOException
public long value()