Class CLongPointer
java.lang.Object
org.bytedeco.javacpp.Pointer
org.bytedeco.javacpp.CLongPointer
- All Implemented Interfaces:
AutoCloseable
The peer class to native pointers and arrays of
long.
All operations take into account the position and limit, when appropriate.
We need this class because platforms supported by Java do not all agree on the
size of the native C++ long type, unlike int and short.
-
Nested Class Summary
Nested classes/interfaces inherited from class Pointer
Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.DeallocatorReference, Pointer.DeallocatorThread, Pointer.NativeDeallocator, Pointer.ProxyDeallocator, Pointer.ReferenceCounter -
Field Summary
FieldsFields inherited from class Pointer
address, capacity, deallocatorThread, limit, maxBytes, maxPhysicalBytes, maxRetries, position -
Constructor Summary
ConstructorsConstructorDescriptionCLongPointer(long size) Allocates a nativelongarray of the given size.CLongPointer(long... array) Allocates enough memory for the array and copies it. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidallocateArray(long size) capacity(long capacity) Sets the capacity and returns this.longget()longget(long i) get(long[] array) get(long[] array, int offset, int length) Reads a portion of the native array into a Java array.getPointer(long i) ReturnsgetPointer(getClass(), i).limit(long limit) Sets the limit and returns this.position(long position) Sets the position and returns this.put(long l) put(long... array) put(long[] array, int offset, int length) Writes a portion of a Java array into the native array.put(long i, long l) Copies thelongvalue to the i-th element of a native array.Methods inherited from class Pointer
address, asBuffer, 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, sizeof, toString, totalBytes, totalCount, totalPhysicalBytes, withDeallocator, zero
-
Field Details
-
logger
-
-
Constructor Details
-
CLongPointer
public CLongPointer(long... array) Allocates enough memory for the array and copies it.- Parameters:
array- the array to copy- See Also:
-
CLongPointer
public CLongPointer(long size) Allocates a nativelongarray of the given size.- Parameters:
size- the number oflongelements to allocate
-
CLongPointer
public CLongPointer()- See Also:
-
CLongPointer
- See Also:
-
-
Method Details
-
allocateArray
private void allocateArray(long size) -
position
Description copied from class:PointerSets 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:PointerSets the limit and returns this. Used to limit the size of an operation on this object. -
capacity
Description copied from class:PointerSets the capacity and returns this. Should not be called more than once after allocation. -
getPointer
Description copied from class:PointerReturnsgetPointer(getClass(), i).- Overrides:
getPointerin classPointer
-
get
public long get()- Returns:
get(0)
-
get
- Returns:
- the i-th
longvalue of a native array
-
put
- Returns:
put(0, l)
-
put
Copies thelongvalue to the i-th element of a native array.- Parameters:
i- the index into the arrayl- thelongvalue 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
-