/** Reads longs from the current position into the specified long array and increases the position by the number of longs read. * <p> * Calling this method has the same effect as {@code get(dest, 0, dest.length)}. * </p> * * @param dest the destination long array. * @return this buffer. * @exception BufferUnderflowException if {@code dest.length} is greater than {@code remaining()}. * @since Android 1.0 */ public LongBuffer get (long[] dest) { return get(dest, 0, dest.length); }
/** Reads longs from the current position into the specified long array and increases the position by the number of longs read. * <p> * Calling this method has the same effect as {@code get(dest, 0, dest.length)}. * </p> * * @param dest the destination long array. * @return this buffer. * @exception BufferUnderflowException if {@code dest.length} is greater than {@code remaining()}. * @since Android 1.0 */ public LongBuffer get (long[] dest) { return get(dest, 0, dest.length); }
/** Calculates this buffer's hash code from the remaining chars. The position, limit, capacity and mark don't affect the hash * code. * * @return the hash code calculated from the remaining longs. * @since Android 1.0 */ public int hashCode () { int myPosition = position; int hash = 0; long l; while (myPosition < limit) { l = get(myPosition++); hash = hash + ((int)l) ^ ((int)(l >> 32)); } return hash; }
/** Calculates this buffer's hash code from the remaining chars. The position, limit, capacity and mark don't affect the hash * code. * * @return the hash code calculated from the remaining longs. * @since Android 1.0 */ public int hashCode () { int myPosition = position; int hash = 0; long l; while (myPosition < limit) { l = get(myPosition++); hash = hash + ((int)l) ^ ((int)(l >> 32)); } return hash; }
@Override public LongIndexer get(long i, long[] l, int offset, int length) { for (int n = 0; n < length; n++) { l[offset + n] = buffer.get((int)i * (int)strides[0] + n); } return this; } @Override public long get(long i, long j) {
@Override public LongIndexer get(long i, long j, long[] l, int offset, int length) { for (int n = 0; n < length; n++) { l[offset + n] = buffer.get((int)i * (int)strides[0] + (int)j * (int)strides[1] + n); } return this; } @Override public long get(long i, long j, long k) {
@Override public long read(int index) { return buffer.get(buffer.position() + index); }
@Override public Object get(ByteBuffer buf, int position) { long[] bins = new long[breaks.length + 1]; ByteBuffer mutationBuffer = buf.duplicate(); mutationBuffer.position(position); mutationBuffer.asLongBuffer().get(bins); float min = mutationBuffer.getFloat(position + minOffset); float max = mutationBuffer.getFloat(position + maxOffset); return new Histogram(breaks, bins, min, max); }
@Override public long get(int index) { // optimize division and remainder for powers of 2 final int bufferNum = index >> div; if (bufferNum != currBufferNum) { loadBuffer(bufferNum); } final int bufferIndex = index & rem; return longBuffer.get(bufferIndex); }
/** Checks whether this long buffer is equal to another object. * <p> * 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. * </p> * * @param other the object to compare with this long buffer. * @return {@code true} if this long buffer is equal to {@code other}, {@code false} otherwise. * @since Android 1.0 */ public boolean equals (Object other) { 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; }
/** Checks whether this long buffer is equal to another object. * <p> * 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. * </p> * * @param other the object to compare with this long buffer. * @return {@code true} if this long buffer is equal to {@code other}, {@code false} otherwise. * @since Android 1.0 */ public boolean equals (Object other) { 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; }
@Override public LongIndexer get(long[] indices, long[] l, int offset, int length) { for (int n = 0; n < length; n++) { l[offset + n] = buffer.get((int)index(indices) + n); } return this; }
/** * Take all of the remaining longs from the buffer and return them in an array. * * @param buffer the buffer to read * @return the longs */ public static long[] take(LongBuffer buffer) { final long[] longs = new long[buffer.remaining()]; buffer.get(longs); return longs; }
/** 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. * * @param dest the target long array. * @param off the offset of the long array, must not be negative and not greater than {@code dest.length}. * @param len the number of longs to read, must be no less than zero and not greater than {@code dest.length - off}. * @return this buffer. * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. * @exception BufferUnderflowException if {@code len} is greater than {@code remaining()}. * @since Android 1.0 */ public LongBuffer get (long[] dest, int off, int len) { 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; }
/** 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. * * @param dest the target long array. * @param off the offset of the long array, must not be negative and not greater than {@code dest.length}. * @param len the number of longs to read, must be no less than zero and not greater than {@code dest.length - off}. * @return this buffer. * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. * @exception BufferUnderflowException if {@code len} is greater than {@code remaining()}. * @since Android 1.0 */ public LongBuffer get (long[] dest, int off, int len) { 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; }
/** Compare the remaining longs of this buffer to another long buffer's remaining longs. * * @param otherBuffer another long buffer. * @return a negative value if this is less than {@code otherBuffer}; 0 if this equals to {@code otherBuffer}; a positive value * if this is greater than {@code otherBuffer} * @exception ClassCastException if {@code otherBuffer} is not a long buffer. * @since Android 1.0 */ public int compareTo (LongBuffer otherBuffer) { 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(); }
/** Compare the remaining longs of this buffer to another long buffer's remaining longs. * * @param otherBuffer another long buffer. * @return a negative value if this is less than {@code otherBuffer}; 0 if this equals to {@code otherBuffer}; a positive value * if this is greater than {@code otherBuffer} * @exception ClassCastException if {@code otherBuffer} is not a long buffer. * @since Android 1.0 */ public int compareTo (LongBuffer otherBuffer) { 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(); }
/** 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. * * @param src the source long buffer. * @return this buffer. * @exception BufferOverflowException if {@code src.remaining()} is greater than this buffer's {@code remaining()}. * @exception IllegalArgumentException if {@code src} is this buffer. * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. * @since Android 1.0 */ public LongBuffer put (LongBuffer src) { 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; }
/** 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. * * @param src the source long buffer. * @return this buffer. * @exception BufferOverflowException if {@code src.remaining()} is greater than this buffer's {@code remaining()}. * @exception IllegalArgumentException if {@code src} is this buffer. * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. * @since Android 1.0 */ public LongBuffer put (LongBuffer src) { 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; }