[vector] #53: Add move to mutable vectors

vector vector at projects.haskell.org
Fri Apr 15 04:20:22 BST 2011


#53: Add move to mutable vectors
---------------------------+------------------------------------------------
Reporter:  LouisWasserman  |       Owner:     
    Type:  enhancement     |      Status:  new
Priority:  major           |   Milestone:     
 Version:  0.7             |    Keywords:     
---------------------------+------------------------------------------------
 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.

-- 
Ticket URL: <http://trac.haskell.org/vector/ticket/53>
vector <http://trac.haskell.org/vector>
Package vector


More information about the vector mailing list