Ticket #53 (closed enhancement: fixed)
Add move to mutable vectors
|Reported by:||LouisWasserman||Owned by:|
I was trying to implement timsort, a preposterously complicated but reportedly wicked fast sorting algorithm which is the standard for Python and which will be the default for JDK 7. However, it is significantly improved by the presence of a move operation, e.g. memmove, etc...as are several other sorting algorithms.
Therefore, I'd like to add a move operation for MVectors, equivalent to copying the source array into a buffer and then copying that back to the destination.
Obviously, this is just a literal memmove for Primitive, Storable, and (more or less) Unboxed, but since there's no built-in move for boxed arrays, that gets a little more interesting. For boxed Vectors, I wrote an implementation that special-cases n <= 2, but for the general case uses a temporary array of size at most n/2.
I've included my patch, which includes a small test suite. Though there isn't currently a test suite for any MVector operations, the implementation I used was sufficiently complicated that it *needed* testing.