Package org.bytedeco.javacpp
Class IntPointer
java.lang.Object
org.bytedeco.javacpp.Pointer
org.bytedeco.javacpp.IntPointer
- All Implemented Interfaces:
AutoCloseable
The peer class to native pointers and arrays of
int
, also used for UTF-32.
All operations take into account the position and limit, when appropriate.-
Nested Class Summary
Nested classes/interfaces inherited from class org.bytedeco.javacpp.Pointer
Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.DeallocatorReference, Pointer.DeallocatorThread, Pointer.NativeDeallocator, Pointer.ProxyDeallocator, Pointer.ReferenceCounter
-
Field Summary
FieldsFields inherited from class org.bytedeco.javacpp.Pointer
address, capacity, deallocatorThread, limit, maxBytes, maxPhysicalBytes, maxRetries, position
-
Constructor Summary
ConstructorsConstructorDescriptionIntPointer
(int... array) Allocates enough memory for the array and copies it.IntPointer
(long size) Allocates a nativeint
array of the given size.IntPointer
(String s) Allocates enough memory for encoding the String in UTF-32 and copies it.IntPointer
(IntBuffer buffer) For direct buffers, callsPointer(Buffer)
, while for buffers backed with an array, allocates enough memory for the array and copies it. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
allocateArray
(long size) final IntBuffer
asBuffer()
Same asPointer.asByteBuffer()
, but can be overridden to return subclasses of Buffer.capacity
(long capacity) Sets the capacity and returns this.int
get()
get
(int[] array) get
(int[] array, int offset, int length) Reads a portion of the native array into a Java array.int
get
(long i) getPointer
(long i) ReturnsgetPointer(getClass(), i)
.Returns the String, assuming a null-terminated string iflimit <= position
.int[]
Returns the code points, assuming a null-terminated string iflimit <= position
.limit
(long limit) Sets the limit and returns this.position
(long position) Sets the position and returns this.put
(int j) put
(int... array) put
(int[] array, int offset, int length) Writes a portion of a Java array into the native array.put
(long i, int j) Copies theint
value to the i-th element of a native array.Copies the String code points into native memory, including a terminating null int.int
sizeof()
Returns 1 for Pointer or BytePointer elseLoader.sizeof(getClass())
or -1 on error.Methods inherited from class org.bytedeco.javacpp.Pointer
address, asByteBuffer, availablePhysicalBytes, calloc, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, getDirectBufferAddress, getPointer, getPointer, getPointer, hashCode, init, interruptDeallocatorThread, isNull, isNull, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetAddress, offsetof, offsetof, parseBytes, physicalBytes, physicalBytesInaccurate, position, put, realloc, referenceCount, releaseReference, retainReference, setNull, sizeof, toString, totalBytes, totalCount, totalPhysicalBytes, withDeallocator, zero
-
Field Details
-
logger
-
-
Constructor Details
-
IntPointer
Allocates enough memory for encoding the String in UTF-32 and copies it.- Parameters:
s
- the String to copy- See Also:
-
IntPointer
public IntPointer(int... array) Allocates enough memory for the array and copies it.- Parameters:
array
- the array to copy- See Also:
-
IntPointer
For direct buffers, callsPointer(Buffer)
, while for buffers backed with an array, allocates enough memory for the array and copies it.- Parameters:
buffer
- the Buffer to reference or copy- See Also:
-
IntPointer
public IntPointer(long size) Allocates a nativeint
array of the given size.- Parameters:
size
- the number ofint
elements to allocate
-
IntPointer
public IntPointer()- See Also:
-
IntPointer
- See Also:
-
-
Method Details
-
allocateArray
private void allocateArray(long size) -
position
Description copied from class:Pointer
Sets the position and returns this. That makes thearray.position(i)
statement sort of equivalent to thearray[i]
statement in C++. -
limit
Description copied from class:Pointer
Sets the limit and returns this. Used to limit the size of an operation on this object. -
capacity
Description copied from class:Pointer
Sets the capacity and returns this. Should not be called more than once after allocation. -
sizeof
public int sizeof()Description copied from class:Pointer
Returns 1 for Pointer or BytePointer elseLoader.sizeof(getClass())
or -1 on error. -
getPointer
Description copied from class:Pointer
ReturnsgetPointer(getClass(), i)
.- Overrides:
getPointer
in classPointer
-
getStringCodePoints
public int[] getStringCodePoints()Returns the code points, assuming a null-terminated string iflimit <= position
. -
getString
Returns the String, assuming a null-terminated string iflimit <= position
. -
putString
Copies the String code points into native memory, including a terminating null int. Sets the limit to just before the terminating null code point.- Parameters:
s
- the String to copy- Returns:
- this
- See Also:
-
get
public int get()- Returns:
get(0)
-
get
public int get(long i) - Returns:
- the i-th
int
value of a native array
-
put
- Returns:
put(0, j)
-
put
Copies theint
value to the i-th element of a native array.- Parameters:
i
- the index into the arrayj
- theint
value to copy- Returns:
- this
-
get
- Returns:
get(array, 0, array.length)
-
put
- Returns:
put(array, 0, array.length)
-
get
Reads a portion of the native array into a Java array.- Parameters:
array
- the array to write tooffset
- the offset into the array where to start writinglength
- the length of data to read and write- Returns:
- this
-
put
Writes a portion of a Java array into the native array.- Parameters:
array
- the array to read fromoffset
- the offset into the array where to start readinglength
- the length of data to read and write- Returns:
- this
-
asBuffer
Description copied from class:Pointer
Same asPointer.asByteBuffer()
, but can be overridden to return subclasses of Buffer.
-