|
Ordered collections: lists and sequencesA list is growable collection, implemented using a linked list. It is fast to add and remove objects at either end, but relatively slow to access objects in the middle. Adding and removing in the middle is not supported. Special list messages include addFirst:, addLast:, removeFirst and removeLast.A sequence is a growable collection, implemented using a vector. When the vector fills, a new, bigger vector is created and substituted. Hence, growing can be expensive when the vector is full. However, access and update is fast. Removing from the middle is slow, as elements have to be shifted to close up the gap. A sequence is analogous to a Smalltalk OrderedCollection. With the exception of messages like add:, addFirst: and removeFirst:, a sequence behaves similarly to a vector.
|