public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBuffer>
A double buffer can be created in either one of the following ways:
Allocate a new double array and create a buffer
based on it;Wrap an existing double array to create a new
buffer;ByteBuffer.asDoubleBuffer to
create a double buffer based on a byte buffer.| Modifier and Type | Method and Description |
|---|---|
static DoubleBuffer |
allocate(int capacity)
Creates a double buffer based on a newly allocated double array.
|
double[] |
array()
Returns the array that backs this buffer (optional operation).
|
int |
arrayOffset()
Returns the offset into the array returned by
array of the first
element of the buffer (optional operation). |
abstract DoubleBuffer |
asReadOnlyBuffer()
Returns a read-only buffer that shares its content with this buffer.
|
DoubleBuffer |
clear()
Clears this buffer.
|
abstract DoubleBuffer |
compact()
Compacts this double buffer.
|
int |
compareTo(DoubleBuffer otherBuffer)
Compare the remaining doubles of this buffer to another double buffer's
remaining doubles.
|
abstract DoubleBuffer |
duplicate()
Returns a duplicated buffer that shares its content with this buffer.
|
boolean |
equals(Object other)
Checks whether this double buffer is equal to another object.
|
DoubleBuffer |
flip()
Flips this buffer.
|
abstract double |
get()
Returns the double at the current position and increases the position by
1.
|
DoubleBuffer |
get(double[] dst)
Reads doubles from the current position into the specified double array
and increases the position by the number of doubles read.
|
DoubleBuffer |
get(double[] dst,
int dstOffset,
int doubleCount)
Reads doubles from the current position into the specified double array,
starting from the specified offset, and increases the position by the
number of doubles read.
|
abstract double |
get(int index)
Returns a double at the specified index; the position is not changed.
|
boolean |
hasArray()
Returns true if
array and arrayOffset won't throw. |
int |
hashCode()
Calculates this buffer's hash code from the remaining chars.
|
abstract boolean |
isDirect()
Indicates whether this buffer is direct.
|
DoubleBuffer |
limit(int newLimit)
Sets the limit of this buffer.
|
DoubleBuffer |
mark()
Marks the current position, so that the position may return to this point
later by calling
reset(). |
int |
mismatch(DoubleBuffer that)
Finds and returns the relative index of the first mismatch between this
buffer and a given buffer.
|
abstract ByteOrder |
order()
Returns the byte order used by this buffer when converting doubles
from/to bytes.
|
DoubleBuffer |
position(int newPosition)
Sets the position of this buffer.
|
abstract DoubleBuffer |
put(double d)
Writes the given double to the current position and increases the
position by 1.
|
DoubleBuffer |
put(double[] src)
Writes doubles from the given double array to the current position and
increases the position by the number of doubles written.
|
DoubleBuffer |
put(double[] src,
int srcOffset,
int doubleCount)
Writes doubles from the given double array, starting from the specified
offset, to the current position and increases the position by the number
of doubles written.
|
DoubleBuffer |
put(DoubleBuffer src)
Writes all the remaining doubles of the
src double buffer to this
buffer's current position, and increases both buffers' position by the
number of doubles copied. |
abstract DoubleBuffer |
put(int index,
double d)
Write a double to the specified index of this buffer and the position is
not changed.
|
DoubleBuffer |
reset()
Resets the position of this buffer to the
mark. |
DoubleBuffer |
rewind()
Rewinds this buffer.
|
abstract DoubleBuffer |
slice()
Returns a sliced buffer that shares its content with this buffer.
|
static DoubleBuffer |
wrap(double[] array)
Creates a new double buffer by wrapping the given double array.
|
static DoubleBuffer |
wrap(double[] array,
int start,
int doubleCount)
Creates a new double buffer by wrapping the given double array.
|
capacity, getElementSizeShift, hasRemaining, isReadOnly, limit, position, remaining, toStringpublic static DoubleBuffer allocate(int capacity)
capacity - the capacity of the new buffer.IllegalArgumentException - if capacity is less than zero.public static DoubleBuffer wrap(double[] array)
Calling this method has the same effect as
wrap(array, 0, array.length).
array - the double array which the new buffer will be based on.public static DoubleBuffer wrap(double[] array, int start, int doubleCount)
The new buffer's position will be start, limit will be
start + doubleCount, capacity will be the length of the array.
array - the double array which the new buffer will be based on.start - the start index, must not be negative and not greater than
array.length.doubleCount - the length, must not be negative and not greater than
array.length - start.IndexOutOfBoundsException - if either start or doubleCount is invalid.public final double[] array()
BufferSubclasses should override this method with a covariant return type to provide the exact type of the array.
Use hasArray to ensure this method won't throw.
(A separate call to isReadOnly is not necessary.)
public final int arrayOffset()
Bufferarray of the first
element of the buffer (optional operation). The backing array (if there is one)
is not necessarily the same size as the buffer, and position 0 in the buffer is
not necessarily the 0th element in the array. Use
buffer.array()[offset + buffer.arrayOffset() to access element offset
in buffer.
Use hasArray to ensure this method won't throw.
(A separate call to isReadOnly is not necessary.)
arrayOffset in class Bufferpublic abstract DoubleBuffer asReadOnlyBuffer()
The returned buffer is guaranteed to be a new instance, even if this buffer is read-only itself. The new buffer's position, limit, capacity and mark are the same as this buffer's.
The new buffer shares its content with this buffer, which means that this buffer's change of content will be visible to the new buffer. The two buffer's position, limit and mark are independent.
public final DoubleBuffer position(int newPosition)
If the mark is set and it is greater than the new position, then it is cleared.
public final DoubleBuffer limit(int newLimit)
If the current position in the buffer is in excess of
newLimit then, on returning from this call, it will have
been adjusted to be equivalent to newLimit. If the mark
is set and is greater than the new limit, then it is cleared.
public final DoubleBuffer mark()
reset().public final DoubleBuffer reset()
mark.public final DoubleBuffer clear()
While the content of this buffer is not changed, the following internal changes take place: the current position is reset back to the start of the buffer, the value of the buffer limit is made equal to the capacity and mark is cleared.
public final DoubleBuffer flip()
The limit is set to the current position, then the position is set to zero, and the mark is cleared.
The content of this buffer is not changed.
public final DoubleBuffer rewind()
The position is set to zero, and the mark is cleared. The content of this buffer is not changed.
public abstract DoubleBuffer compact()
The remaining doubles will be moved to the head of the buffer, staring
from position zero. Then the position is set to remaining(); the
limit is set to capacity; the mark is cleared.
ReadOnlyBufferException - if no changes may be made to the contents of this buffer.public int compareTo(DoubleBuffer otherBuffer)
compareTo in interface Comparable<DoubleBuffer>otherBuffer - another double buffer.other; 0 if this
equals to other; a positive value if this is greater
than other.ClassCastException - if other is not a double buffer.public int mismatch(DoubleBuffer that)
position of each buffer and will be in the range of
0 (inclusive) up to the smaller of the remaining
elements in each buffer (exclusive).
If the two buffers share a common prefix then the returned index is the length of the common prefix and it follows that there is a mismatch between the two buffers at that index within the respective buffers. If one buffer is a proper prefix of the other then the returned index is the smaller of the remaining elements in each buffer, and it follows that the index is only valid for the buffer with the larger number of remaining elements. Otherwise, there is no mismatch.
that - The byte buffer to be tested for a mismatch with this bufferpublic abstract DoubleBuffer duplicate()
The duplicated buffer's position, limit, capacity and mark are the same as this buffer's. The duplicated buffer's read-only property and byte order are the same as this buffer's, too.
The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the other. The two buffers' position, limit and mark are independent.
public boolean equals(Object other)
other is not a DoubleBuffer then false is returned.
Two double buffers are equal if their remaining doubles are equal. Position, limit, capacity and mark are not considered.
This method considers two doubles a and b to be equal
if a == b or if a and b are both NaN.
Unlike Double.equals(java.lang.Object), this method considers -0.0 and
+0.0 to be equal.
equals in class Objectother - the object to compare with this double buffer.true if this double buffer is equal to other,
false otherwise.Object.hashCode()public abstract double get()
BufferUnderflowException - if the position is equal or greater than limit.public DoubleBuffer get(double[] dst)
Calling this method has the same effect as
get(dst, 0, dst.length).
dst - the destination double array.BufferUnderflowException - if dst.length is greater than remaining().public DoubleBuffer get(double[] dst, int dstOffset, int doubleCount)
dst - the target double array.dstOffset - the offset of the double array, must not be negative and not
greater than dst.length.doubleCount - the number of doubles to read, must be no less than zero and
not greater than dst.length - dstOffset.IndexOutOfBoundsException - if either dstOffset or doubleCount is invalid.BufferUnderflowException - if doubleCount is greater than remaining().public abstract double get(int index)
index - the index, must not be negative and less than limit.IndexOutOfBoundsException - if index is invalid.public final boolean hasArray()
Bufferarray and arrayOffset won't throw. This method does not
return true for buffers not backed by arrays because the other methods would throw
UnsupportedOperationException, nor does it return true for buffers backed by
read-only arrays, because the other methods would throw ReadOnlyBufferException.public int hashCode()
hashCode in class ObjectObject.equals(java.lang.Object)public abstract boolean isDirect()
A double buffer is direct if it is based on a byte buffer and the byte buffer is direct.
public abstract ByteOrder order()
If this buffer is not based on a byte buffer, then this always returns the platform's native byte order.
public abstract DoubleBuffer put(double d)
d - the double to write.BufferOverflowException - if position is equal or greater than limit.ReadOnlyBufferException - if no changes may be made to the contents of this buffer.public final DoubleBuffer put(double[] src)
Calling this method has the same effect as
put(src, 0, src.length).
src - the source double array.BufferOverflowException - if remaining() is less than src.length.ReadOnlyBufferException - if no changes may be made to the contents of this buffer.public DoubleBuffer put(double[] src, int srcOffset, int doubleCount)
src - the source double array.srcOffset - the offset of double array, must not be negative and not
greater than src.length.doubleCount - the number of doubles to write, must be no less than zero and
not greater than src.length - srcOffset.BufferOverflowException - if remaining() is less than doubleCount.IndexOutOfBoundsException - if either srcOffset or doubleCount is invalid.ReadOnlyBufferException - if no changes may be made to the contents of this buffer.public DoubleBuffer put(DoubleBuffer src)
src double buffer to this
buffer's current position, and increases both buffers' position by the
number of doubles copied.src - the source double buffer.BufferOverflowException - if src.remaining() is greater than this buffer's
remaining().IllegalArgumentException - if src is this buffer.ReadOnlyBufferException - if no changes may be made to the contents of this buffer.public abstract DoubleBuffer put(int index, double d)
index - the index, must not be negative and less than the limit.d - the double to write.IndexOutOfBoundsException - if index is invalid.ReadOnlyBufferException - if no changes may be made to the contents of this buffer.public abstract DoubleBuffer slice()
The sliced buffer's capacity will be this buffer's remaining(),
and its zero position will correspond to this buffer's current position.
The new buffer's position will be 0, limit will be its capacity, and its
mark is cleared. The new buffer's read-only property and byte order are
the same as this buffer's.
The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the other. The two buffers' position, limit and mark are independent.