Ticket #53 (closed enhancement: fixed)

Opened 2 years ago

Last modified 2 years ago

Add move to mutable vectors

Reported by: LouisWasserman Owned by:
Priority: major Milestone:
Version: 0.7 Keywords:
Cc:

Description

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.

Attachments

move.patch (19.4 kB) - added by LouisWasserman 2 years ago.
Patch adding move to MVectors.

Change History

Changed 2 years ago by LouisWasserman

Patch adding move to MVectors.

Changed 2 years ago by rl

  • status changed from new to closed
  • resolution set to fixed

Applied, thanks!

Note: See TracTickets for help on using tickets.