On Thursday, 9 July 2015 at 19:19:42 UTC, Walter Bright wrote:
On 7/9/2015 12:56 AM, deadalnix wrote:
Several of which actually use linked list for list and probably shouldn't
provide random access.

Yes. Consider:

    for (int i = 0; i < list.length; ++i)
          sum += list[i];

If indexing was allowed on a list, this would seem like perfectly reasonable code.

Yes, which is why it's so ridiculous that the List interface in Java provides indexing via the at function. Both ArrayList and LinkedList implement it, which is reasonable in the case of ArrayList and stupid in the case of LinkedList.

- Jonathan M Davis

Reply via email to