Clojure: sequence back to vector

前端 未结 4 1050
Happy的楠姐
Happy的楠姐 2021-01-01 18:33

How can I cast a sequence back to vector after a sequence producing operation (like sort)? Does using (vec..) on a sequence that was a vector is costly?

One (bad?)

4条回答
  •  孤城傲影
    2021-01-01 19:26

    If you need to random access on the result of sort with huge vectors, then the time took by the call to vec should be far outweighed by time savings of doing so.

    If you profile and find that it is too slow, you'll probably have to use java arrays.

提交回复
热议问题