emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: can `shuffle-vector' be moved?


From: Ted Zlatanov
Subject: Re: can `shuffle-vector' be moved?
Date: Fri, 13 May 2011 09:38:59 -0500
User-agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.50 (gnu/linux)

On Fri, 13 May 2011 11:00:10 -0300 Stefan Monnier <address@hidden> wrote: 

>>> (loop
>>> for i from (1-  (length vector)) downto 1
>>> do (rotatef (aref vector i) (aref vector (random i)))))

>> Why is this limited to vectors? with elt it could work also with lists.

SM> Its algorithmic performance on lists would be poor (O(N²)).
SM> You want a different algorithm for lists.

I think the performance would not be bad if the list was put into a
vector, shuffled, then put back--just O(N) with twice the memory usage.
That could be a wrapper around the vector shuffle so it can handle
general sequences.

Ted




reply via email to

[Prev in Thread] Current Thread [Next in Thread]