TDoubleArrayList.toNativeArray(double[] dest, int offset, int len) has a bug. The documentation and implementation are incompatible.
The documentation should make clear that "offset" is in the dest array AND NOT the offset in the TDoubleArrayList. Or you may want to make the code match the documentation and have "offset" be the starting location in the TDoubleArrayList.
Another option is to deprecate this version and offer a function with an offset for each of the dest and TDoubleArrayList. This might be clearest for users.
This bug report probably applies to other T<primitive>ArrayLists.
Any questions, my name is Mike and I'm available at mike_nahas@yahoo.com.
@version $Id: TDoubleArrayList.java,v 1.18 2005/03/26 18:04:42 ericdf Exp $
/
* Copies a slice of the list into a native array.
* @param dest the array to copy into.
* @param offset the offset of the first value to copy
* @param len the number of values to copy.
/
public void toNativeArray(double[] dest, int offset, int len) {
if (len == 0) {
return; // nothing to copy
}
if (offset < 0 || offset >= _pos) {
throw new ArrayIndexOutOfBoundsException(offset);
}
System.arraycopy(_data, 0, dest, offset, len);
}
This bug also causes
public double[] toNativeArray(int offset, int len)
to fail. :( However, fixing the above version to match the documentation will fix both.
Mike
Fixed in the 3.x branch. Waiting to hear from Mike if a fix is needed for the 2.x branch.
Closing for the moment. Mike, if you need it in 2.x, feel free to comment on the bug and I'll reopen.