Uploaded image for project: 'Clojure'
  1. CLJ-1794

Sorting vector yields non-indexed ArraySeq

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects versions: None
    • Fix versions: None
    • Labels:
    • Approval:
      Triaged
    • Patch:
      Code

      Description

      Sorting a vector gives back an ArraySeq with O(n) gets instead of O(log N) gets. This means it can be more efficient to take a vector, sort, then turn it back into a vector.

      Cause: sort works by copying the collection to be sorted into an array, calls Arrays/sort to sort it, and then returns a seq on the sorted array. The seq returned is an ArraySeq and doesn't implement Indexed.

      Alternatives:

      1. Make ArraySeq (and primitive specializations thereof) implement Indexed, providing constant time lookup by index.
      2. Specialize sorting for different collection types
      3. ???

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              alexmiller Alex Miller
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: