SortedCollection.st
changeset 7554 7ea961a68e34
parent 7300 461bb09c5954
child 8180 7c346c8015f2
equal deleted inserted replaced
7553:35195bf85ad6 7554:7ea961a68e34
   297      Returns the argument, aCollection (sigh)."
   297      Returns the argument, aCollection (sigh)."
   298 
   298 
   299     |addedCollection|
   299     |addedCollection|
   300 
   300 
   301     (aCollection isSortedCollection
   301     (aCollection isSortedCollection
   302     and:[aCollection sortBlock == sortBlock]) ifTrue:[
   302      and:[aCollection sortBlock == sortBlock]) ifTrue:[
   303         addedCollection := aCollection
   303         addedCollection := aCollection
   304     ] ifFalse:[
   304     ] ifFalse:[
   305         addedCollection := Array withAll:(aCollection asArray).
   305         addedCollection := Array withAll:aCollection.
   306         addedCollection == aCollection ifTrue:[
       
   307             addedCollection := addedCollection shallowCopy
       
   308         ].
       
   309         addedCollection sort:sortBlock.
   306         addedCollection sort:sortBlock.
   310 
   307 
   311         "/ special case: I am empty - add them en-bloque.
   308         "/ special case: I am empty - add them en-bloque.
   312         "/ (but only if the argument is not a sortedCollection,
   309         "/ (but only if the argument is not a sortedCollection,
   313         "/  because quicksort degenerates to a veeery slow operation then)
   310         "/  because quicksort degenerates to a veeery slow operation then)
   835 ! !
   832 ! !
   836 
   833 
   837 !SortedCollection class methodsFor:'documentation'!
   834 !SortedCollection class methodsFor:'documentation'!
   838 
   835 
   839 version
   836 version
   840     ^ '$Header: /cvs/stx/stx/libbasic/SortedCollection.st,v 1.52 2003-05-19 10:57:44 cg Exp $'
   837     ^ '$Header: /cvs/stx/stx/libbasic/SortedCollection.st,v 1.53 2003-08-15 07:01:49 stefan Exp $'
   841 ! !
   838 ! !
   842 
   839 
   843 SortedCollection initialize!
   840 SortedCollection initialize!