/** Reads doubles from the current position into the specified double array and increases the position by the number of doubles * read. * <p> * Calling this method has the same effect as {@code get(dest, 0, dest.length)}. * </p> * * @param dest the destination double array. * @return this buffer. * @exception BufferUnderflowException if {@code dest.length} is greater than {@code remaining()}. * @since Android 1.0 */ public DoubleBuffer get (double[] dest) { return get(dest, 0, dest.length); }
/** Reads doubles from the current position into the specified double array and increases the position by the number of doubles * read. * <p> * Calling this method has the same effect as {@code get(dest, 0, dest.length)}. * </p> * * @param dest the destination double array. * @return this buffer. * @exception BufferUnderflowException if {@code dest.length} is greater than {@code remaining()}. * @since Android 1.0 */ public DoubleBuffer get (double[] dest) { return get(dest, 0, dest.length); }
@Override public DoubleIndexer get(long i, long j, double[] d, int offset, int length) { for (int n = 0; n < length; n++) { d[offset + n] = buffer.get((int)i * (int)strides[0] + (int)j * (int)strides[1] + n); } return this; } @Override public double get(long i, long j, long k) {
@Override public DoubleIndexer get(long i, double[] d, int offset, int length) { for (int n = 0; n < length; n++) { d[offset + n] = buffer.get((int)i * (int)strides[0] + n); } return this; } @Override public double get(long i, long j) {
@Override public double get(long i) { return buffer.get((int)i); } @Override public DoubleIndexer get(long i, double[] d, int offset, int length) {
@Override public double get(long i, long j) { return buffer.get((int)i * (int)strides[0] + (int)j); } @Override public DoubleIndexer get(long i, long j, double[] d, int offset, int length) {
@Override public double 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 doubleBuffer.get(bufferIndex); } };
@Override public double get(int index) { return buffer.get(buffer.position() + index); }
@Override public double get(int index) { // division + remainder is optimized by the compiler so keep those together final int bufferNum = index / sizePer; final int bufferIndex = index % sizePer; if (bufferNum != currBufferNum) { loadBuffer(bufferNum); } return doubleBuffer.get(bufferIndex); }
/** Checks whether this double buffer is equal to another object. * <p> * If {@code other} is not a double buffer then {@code false} is returned. Two double buffers are equal if and only if their * remaining doubles are exactly the same. Position, limit, capacity and mark are not considered. * </p> * * @param other the object to compare with this double buffer. * @return {@code true} if this double buffer is equal to {@code other}, {@code false} otherwise. * @since Android 1.0 */ public boolean equals (Object other) { if (!(other instanceof DoubleBuffer)) { return false; } DoubleBuffer otherBuffer = (DoubleBuffer)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 double buffer is equal to another object. * <p> * If {@code other} is not a double buffer then {@code false} is returned. Two double buffers are equal if and only if their * remaining doubles are exactly the same. Position, limit, capacity and mark are not considered. * </p> * * @param other the object to compare with this double buffer. * @return {@code true} if this double buffer is equal to {@code other}, {@code false} otherwise. * @since Android 1.0 */ public boolean equals (Object other) { if (!(other instanceof DoubleBuffer)) { return false; } DoubleBuffer otherBuffer = (DoubleBuffer)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 DoubleIndexer get(long[] indices, double[] d, int offset, int length) { for (int n = 0; n < length; n++) { d[offset + n] = buffer.get((int)index(indices) + n); } return this; }
@Override public double get(long... indices) { return buffer.get((int)index(indices)); } @Override public DoubleIndexer get(long[] indices, double[] d, int offset, int length) {
/** 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. * * @param dest the target double array. * @param off the offset of the double array, must not be negative and not greater than {@code dest.length}. * @param len the number of doubles 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 DoubleBuffer get (double[] dest, int off, int len) { int length = dest.length; if (off < 0 || len < 0 || (long)off + (long)len > length) { throw new IndexOutOfBoundsException(); } if (len > remaining()) { throw new BufferUnderflowException(); } for (int i = off; i < off + len; i++) { dest[i] = get(); } return this; }
/** 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. * * @param dest the target double array. * @param off the offset of the double array, must not be negative and not greater than {@code dest.length}. * @param len the number of doubles 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 DoubleBuffer get (double[] dest, int off, int len) { int length = dest.length; if (off < 0 || len < 0 || (long)off + (long)len > 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 doubles of this buffer to another double buffer's remaining doubles. * * @param otherBuffer another double buffer. * @return a negative value if this is less than {@code other}; 0 if this equals to {@code other}; a positive value if this is * greater than {@code other}. * @exception ClassCastException if {@code other} is not a double buffer. * @since Android 1.0 */ public int compareTo (DoubleBuffer otherBuffer) { int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining() : otherBuffer.remaining(); int thisPos = position; int otherPos = otherBuffer.position; // BEGIN android-changed double thisDouble, otherDouble; while (compareRemaining > 0) { thisDouble = get(thisPos); otherDouble = otherBuffer.get(otherPos); // checks for double and NaN inequality if ((thisDouble != otherDouble) && ((thisDouble == thisDouble) || (otherDouble == otherDouble))) { return thisDouble < otherDouble ? -1 : 1; } thisPos++; otherPos++; compareRemaining--; } // END android-changed return remaining() - otherBuffer.remaining(); }
/** Compare the remaining doubles of this buffer to another double buffer's remaining doubles. * * @param otherBuffer another double buffer. * @return a negative value if this is less than {@code other}; 0 if this equals to {@code other}; a positive value if this is * greater than {@code other}. * @exception ClassCastException if {@code other} is not a double buffer. * @since Android 1.0 */ public int compareTo (DoubleBuffer otherBuffer) { int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining() : otherBuffer.remaining(); int thisPos = position; int otherPos = otherBuffer.position; // BEGIN android-changed double thisDouble, otherDouble; while (compareRemaining > 0) { thisDouble = get(thisPos); otherDouble = otherBuffer.get(otherPos); // checks for double and NaN inequality if ((thisDouble != otherDouble) && ((thisDouble == thisDouble) || (otherDouble == otherDouble))) { return thisDouble < otherDouble ? -1 : 1; } thisPos++; otherPos++; compareRemaining--; } // END android-changed return remaining() - otherBuffer.remaining(); }
/** Writes all the remaining doubles of the {@code src} double buffer to this buffer's current position, and increases both * buffers' position by the number of doubles copied. * * @param src the source double 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 DoubleBuffer put (DoubleBuffer src) { if (src == this) { throw new IllegalArgumentException(); } if (src.remaining() > remaining()) { throw new BufferOverflowException(); } double[] doubles = new double[src.remaining()]; src.get(doubles); put(doubles); return this; }
/** Writes all the remaining doubles of the {@code src} double buffer to this buffer's current position, and increases both * buffers' position by the number of doubles copied. * * @param src the source double 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 DoubleBuffer put (DoubleBuffer src) { if (src == this) { throw new IllegalArgumentException(); } if (src.remaining() > remaining()) { throw new BufferOverflowException(); } double[] doubles = new double[src.remaining()]; src.get(doubles); put(doubles); return this; }