[Squeak] been dazed by SortedCollection

Maurice Rabb m3rabb at stono.com
Mon Aug 31 18:16:27 UTC 1998

At 10:28 AM 8/31/98, Patrick Logan wrote:
>    The problem with the new versions is that we are forgeting special
>    the SortCollection protocol.
>    #addLast:       adds an element without resorting (sneaky)
>Why is #addLast allowed to be sneaky but #at:put: is disallowed

SortedCollections are never guaranteed to have any element at a particular
location, just in order.  If you insert an element at a location, the ideal
SortCollection will immediately resort itself to stay correct.  The element
will more than likely not still be at the location you put it in, making
#at:put: meaningless.  By this reasoning _all_ the inherited adding methods
are also meaningless except #add:.  To this end I have added:

SortCollection>>#addWithoutSorting: anObject
        ^super add: anObject

and changed #copyFrom:to: to use #addWithoutSorting: instead of
inappropriately using #addLast:.


  Maurice Rabb    773.281.6003    Stono Technologies, LLC    Chicago, USA

More information about the Squeak-dev mailing list