Class FloatBufferWrapper
FloatBuffer.
-
Constructor Summary
ConstructorsConstructorDescriptionFloatBufferWrapper(FloatBuffer floatBuffer) ConstructsFloatBufferWrapperon top ofFloatBuffer. -
Method Summary
Modifier and TypeMethodDescriptionstatic FloatBufferWrapperallocate(int capacity) Allocates a new float buffer.float[]array()Returns the float array that backs this buffer.intReturns the offset within this buffer's backing array of the first element of the buffer.Creates a new float buffer that shares this buffer's content.floatget()Relative get method.get(float[] dst) Relative bulk get method.floatget(int index) Absolute get method.ReturnsFloatBufferthat backs this buffer.intlimit()Returns this buffer's limit.limit(int newLimit) Sets this buffer's limit.position(int newPosition) Sets this buffer's position.put(float value) Relative put method.put(float[] src, int offset, int length) Relative bulk put method.intReturns the number of elements between the current position and the limit.rewind()Rewinds this buffer.slice()Creates a new float buffer whose content is a shared subsequence of this buffer's content.static FloatBufferWrapperwrap(float[] array) Wraps a float array into a buffer.
-
Constructor Details
-
FloatBufferWrapper
ConstructsFloatBufferWrapperon top ofFloatBuffer.- Parameters:
-
floatBuffer- buffer on top of whichFloatBufferWrapperwill be built
-
-
Method Details
-
getFloatBuffer
ReturnsFloatBufferthat backs this buffer.Modifications to this buffer's content will cause the returned buffer's content to be modified, and vice versa.
- Returns:
- the array that backs this buffer
-
array
public float[] array()Returns the float array that backs this buffer.Modifications to this buffer's content will cause the returned array's content to be modified, and vice versa.
- Returns:
- the array that backs this buffer
-
arrayOffset
public int arrayOffset()Returns the offset within this buffer's backing array of the first element of the buffer.If this buffer is backed by an array then buffer position corresponds to array index position.
- Returns:
- the offset within this buffer's array of the first element of the buffer
-
get
public float get()Relative get method. Reads the float at this buffer's current position, and then increments the position.- Returns:
- the float at the buffer's current position
-
get
public float get(int index) Absolute get method. Reads the float at the given index.- Parameters:
-
index- the index from which the float will be read - Returns:
- the float at the given index
-
get
Relative bulk get method.This method transfers floats from this buffer into the given destination array.
- Parameters:
-
dst- the destination array - Returns:
- this buffer
-
rewind
Rewinds this buffer. The position is set to zero.Invoke this method before a sequence of channel-write or get operations, assuming that the limit has already been set appropriately.
- Returns:
- this buffer
-
put
Relative put method.Writes the given float into this buffer at the current position, and then increments the position.
- Parameters:
-
value- the float to be written - Returns:
- this buffer
-
put
Relative bulk put method.This method transfers floats into this buffer from the given source array.
- Parameters:
-
src- the array from which floats are to be read -
offset- the offset within the array of the first float to be read; must be non-negative and no larger thanarray.length -
length- the number of floats to be read from the given array; must be non-negative and no larger thanarray.length - offset - Returns:
- this buffer
-
limit
public int limit()Returns this buffer's limit.- Returns:
- the limit of this buffer
-
limit
Sets this buffer's limit. If the position is larger than the new limit then it is set to the new limit.- Parameters:
-
newLimit- the new limit value; must be non-negative and no larger than this buffer's capacity - Returns:
- this buffer
-
duplicate
Creates a new float buffer that shares this buffer's content.The content of the new buffer will be that of this buffer. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position and limit will be independent.
The new buffer's capacity, limit, position and byte order will be identical to those of this buffer.
- Returns:
- the new float buffer
-
remaining
public int remaining()Returns the number of elements between the current position and the limit.- Returns:
- the number of elements remaining in this buffer
-
position
Sets this buffer's position.- Parameters:
-
newPosition- the new position value; must be non-negative and no larger than the current limit - Returns:
- this buffer
-
slice
Creates a new float buffer whose content is a shared subsequence of this buffer's content.The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position and limit values will be independent.
The new buffer's position will be zero, its capacity and its limit will be the number of floats remaining in this buffer and its byte order will be identical to that of this buffer.
- Returns:
- the new float buffer
-
wrap
Wraps a float array into a buffer.The new buffer will be backed by the given float array; that is, modifications to the buffer will cause the array to be modified and vice versa. The new buffer's capacity and limit will be
array.length, its position will be zero and its byte order will be thenative orderof the underlying hardware. Itsbacking arraywill be the given array, and itsarray offsetwill be zero.- Parameters:
-
array- the array that will back this buffer - Returns:
- the new float buffer
-
allocate
Allocates a new float buffer.The new buffer's position will be zero, its limit will be its capacity, its mark will be undefined, each of its elements will be initialized to zero, and its byte order will be the
native orderof the underlying hardware. It will have abacking array, and itsarray offsetwill be zero.- Parameters:
-
capacity- the new buffer's capacity, in floats - Returns:
- the new float buffer
-