<snip> 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 >altogether? >
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
I am dazed and confused! Why would you want to add to a sorted collection without sorting? It seems to me to be a canidate for the more general collection class. So again why have an addLast: method in the SortCollection class??
Jon
------------------------------------------------------------------------- | Jon M. DeLaurier | vox : 250.656.6176 | | 2209 Bradford Av | | | Sidney, B.C. V8L2C8 | | | Canada | email: jdelaurier@vanisle.net | ------------------------------------------------------------------------- | It is always darkest just before it gets black. (Dave Broadfoot 1996) | -------------------------------------------------------------------------