Search code examples
javadata-structurescollectionssortedlist

Is there an indexable sorted list in the Java.util package?


I'm looking for a data structure in the java.util package. I need it to meet the following requirements:

  • The number of elements is (theoretically) unbounded.
  • The elements are sorted in an ascending order.
  • You can get the nth element (fast).
  • You can remove the nth element (fast).

I expected to find an indexable skip list, but I didn't. Do they have any data structure which meets the requirements I'v stated?


Solution

  • There exists no simple data structure that fulfills all your criteria.

    The only one that I know which does fulfills them all would be an indexable skip list. Hoewever,I don't know of any readily available Java implementations.