Methods Summary |
---|
java.lang.Object | _array()
if (hasArray()) {
return array();
}
return null;
|
int | _arrayOffset()
if (hasArray()) {
return arrayOffset();
}
return 0;
|
public static java.nio.LongBuffer | allocate(int capacity)Creates a long buffer based on a newly allocated long array.
if (capacity < 0) {
throw new IllegalArgumentException();
}
return BufferFactory.newLongBuffer(capacity);
|
public final long[] | array()Returns the long array which this buffer is based on, if there is one.
return protectedArray();
|
public final int | arrayOffset()Returns the offset of the long array which this buffer is based on, if
there is one.
The offset is the index of the array and corresponds to the zero position
of the buffer.
return protectedArrayOffset();
|
public abstract java.nio.LongBuffer | asReadOnlyBuffer()Returns a read-only buffer that shares its content with this buffer.
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 this
buffer's change of content will be visible to the new buffer. The two
buffer's position, limit and mark are independent.
|
public abstract java.nio.LongBuffer | compact()Compacts this long buffer.
The remaining longs will be moved to the head of the buffer, staring from
position zero. Then the position is set to {@code remaining()}; the
limit is set to capacity; the mark is cleared.
|
public int | compareTo(java.nio.LongBuffer otherBuffer)Compare the remaining longs of this buffer to another long buffer's
remaining longs.
int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining()
: otherBuffer.remaining();
int thisPos = position;
int otherPos = otherBuffer.position;
// BEGIN android-changed
long thisLong, otherLong;
while (compareRemaining > 0) {
thisLong = get(thisPos);
otherLong = otherBuffer.get(otherPos);
if (thisLong != otherLong) {
return thisLong < otherLong ? -1 : 1;
}
thisPos++;
otherPos++;
compareRemaining--;
}
// END android-changed
return remaining() - otherBuffer.remaining();
|
public abstract java.nio.LongBuffer | duplicate()Returns a duplicated buffer that shares its content with this buffer.
The duplicated buffer's position, limit, capacity and mark are the same
as this buffer. The duplicated buffer's read-only property and byte order
are 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 buffer's
position, limit and mark are independent.
|
public boolean | equals(java.lang.Object other)Checks whether this long buffer is equal to another object.
If {@code other} is not a long buffer then {@code false} is returned. Two
long buffers are equal if and only if their remaining longs are exactly
the same. Position, limit, capacity and mark are not considered.
if (!(other instanceof LongBuffer)) {
return false;
}
LongBuffer otherBuffer = (LongBuffer) other;
if (remaining() != otherBuffer.remaining()) {
return false;
}
int myPosition = position;
int otherPosition = otherBuffer.position;
boolean equalSoFar = true;
while (equalSoFar && (myPosition < limit)) {
equalSoFar = get(myPosition++) == otherBuffer.get(otherPosition++);
}
return equalSoFar;
|
public abstract long | get()Returns the long at the current position and increase the position by 1.
|
public java.nio.LongBuffer | get(long[] dest)Reads longs from the current position into the specified long array and
increases the position by the number of longs read.
Calling this method has the same effect as
{@code get(dest, 0, dest.length)}.
return get(dest, 0, dest.length);
|
public java.nio.LongBuffer | get(long[] dest, int off, int len)Reads longs from the current position into the specified long array,
starting from the specified offset, and increase the position by the
number of longs read.
int length = dest.length;
if (off < 0 || len < 0 || (long)len + (long)off > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
throw new BufferUnderflowException();
}
for (int i = off; i < off + len; i++) {
dest[i] = get();
}
return this;
|
public abstract long | get(int index)Returns the long at the specified index; the position is not changed.
|
public final boolean | hasArray()Indicates whether this buffer is based on a long array and is read/write.
return protectedHasArray();
|
public int | hashCode()Calculates this buffer's hash code from the remaining chars. The
position, limit, capacity and mark don't affect the hash code.
int myPosition = position;
int hash = 0;
long l;
while (myPosition < limit) {
l = get(myPosition++);
hash = hash + ((int) l) ^ ((int) (l >> 32));
}
return hash;
|
public abstract boolean | isDirect()Indicates whether this buffer is direct. A direct buffer will try its
best to take advantage of native memory APIs and it may not stay in the
Java heap, so it is not affected by garbage collection.
A long buffer is direct if it is based on a byte buffer and the byte
buffer is direct.
|
public abstract java.nio.ByteOrder | order()Returns the byte order used by this buffer when converting longs from/to
bytes.
If this buffer is not based on a byte buffer, then always return the
platform's native byte order.
|
abstract long[] | protectedArray()Child class implements this method to realize {@code array()}.
|
abstract int | protectedArrayOffset()Child class implements this method to realize {@code arrayOffset()}.
|
abstract boolean | protectedHasArray()Child class implements this method to realize {@code hasArray()}.
|
public abstract java.nio.LongBuffer | put(long l)Writes the given long to the current position and increases the position
by 1.
|
public final java.nio.LongBuffer | put(long[] src)Writes longs from the given long array to the current position and
increases the position by the number of longs written.
Calling this method has the same effect as
{@code put(src, 0, src.length)}.
return put(src, 0, src.length);
|
public java.nio.LongBuffer | put(long[] src, int off, int len)Writes longs from the given long array, starting from the specified
offset, to the current position and increases the position by the number
of longs written.
int length = src.length;
if (off < 0 || len < 0 || (long)len + (long)off > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
throw new BufferOverflowException();
}
for (int i = off; i < off + len; i++) {
put(src[i]);
}
return this;
|
public java.nio.LongBuffer | put(java.nio.LongBuffer src)Writes all the remaining longs of the {@code src} long buffer to this
buffer's current position, and increases both buffers' position by the
number of longs copied.
if (src == this) {
throw new IllegalArgumentException();
}
if (src.remaining() > remaining()) {
throw new BufferOverflowException();
}
long[] contents = new long[src.remaining()];
src.get(contents);
put(contents);
return this;
|
public abstract java.nio.LongBuffer | put(int index, long l)Writes a long to the specified index of this buffer; the position is not
changed.
|
public abstract java.nio.LongBuffer | slice()Returns a sliced buffer that shares its content with this buffer.
The sliced buffer's capacity will be this buffer's {@code 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
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 buffer's
position, limit and mark are independent.
|
public java.lang.String | toString()Returns a string representing the state of this long buffer.
StringBuffer buf = new StringBuffer();
buf.append(getClass().getName());
buf.append(", status: capacity="); //$NON-NLS-1$
buf.append(capacity());
buf.append(" position="); //$NON-NLS-1$
buf.append(position());
buf.append(" limit="); //$NON-NLS-1$
buf.append(limit());
return buf.toString();
|
public static java.nio.LongBuffer | wrap(long[] array)Creates a new long buffer by wrapping the given long array.
Calling this method has the same effect as
{@code wrap(array, 0, array.length)}.
return wrap(array, 0, array.length);
|
public static java.nio.LongBuffer | wrap(long[] array, int start, int len)Creates a new long buffer by wrapping the given long array.
The new buffer's position will be {@code start}, limit will be
{@code start + len}, capacity will be the length of the array.
if (array == null) {
throw new NullPointerException();
}
if (start < 0 || len < 0 || (long)len + (long)start > array.length) {
throw new IndexOutOfBoundsException();
}
LongBuffer buf = BufferFactory.newLongBuffer(array);
buf.position = start;
buf.limit = start + len;
return buf;
|