On Fri, Jan 1, 2010 at 7:19 PM, Gabi <bugspy...@gmail.com> wrote:
>
> I am asking because I need random access (nth ..) to huge sorted
> vectors - which are now actually huge sequences after the sort, with
> horrible O(n) random access time

Clojure's 'sort' actually copies your input collection into an
array, and then uses java.util.Arrays/sort to sort it in place.
It then wraps a seq around that array, which is good in that it
makes that array essentially immutable, but bad for indexed
lookup.  You might consider using java.util.Array/sort yourself,
then you could get very fast indexed lookups into the sorted
array using 'aget'.

A bit uglier, but ought to be quite fast.

It does raise the question of whether it would be good for
ArraySeqs to implement Indexed.  Then 'nth' would be fast on the
object that 'sort' returns.

--Chouser

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to