[Q] LinkedList

Ron Jeffries ronjeffries at acm.org
Mon Mar 21 13:51:49 UTC 2005


On Monday, March 21, 2005, at 3:05:54 AM, Matej Kosik wrote:

>> LinkedList does not respond to
>>     second
>>     third
>>     ...
>>     at:
>> messages. Do you think that it makes sense? I would expect something
>> else. Is this a purpose or an omission?

> Actually, the LinkedList responds to those messages, but those methods
> fail with an error

>         LinkedLists are not indexable

> I think that all sequenceable collections should be indexable, even if
> in this particular case the implementation of this operation wouldn't
> have constant time complexity as it is in case of arrays.

> When such a functionality misses, and we still need to refer to 
> particular linked list elements, it results in a awkward code like:
> <example snipped>

On the one hand, it's nice to have all lists respond to anything
that more or less makes sense.

On the other, if what we want is indexable behavior, maybe we should
use an indexable structure, leaving linked lists for the sorts of
things they're good for, which are ideas such as stacks, queues,
sequential processing, and insertion/deletion.

Ron Jeffries
www.XProgramming.com
A man hears what he wants to hear, and disregards the rest. -- Paul Simon





More information about the Squeak-dev mailing list