equal
deleted
inserted
replaced
375 "grow the receiver i.e. cut off everything after newSize. |
375 "grow the receiver i.e. cut off everything after newSize. |
376 Warning: this may be a slow operation due to the use of become |
376 Warning: this may be a slow operation due to the use of become |
377 - you should write your collection classes to avoid the use of become. |
377 - you should write your collection classes to avoid the use of become. |
378 You have been warned." |
378 You have been warned." |
379 |
379 |
380 |newArray oldSize senderContext senderSenderContext| |
380 |newArray oldSize sender| |
381 |
381 |
382 oldSize := self size. |
382 oldSize := self size. |
383 (newSize ~~ oldSize) ifTrue:[ |
383 (newSize ~~ oldSize) ifTrue:[ |
384 InfoPrinting ifTrue:[ |
384 InfoPrinting ifTrue:[ |
385 "/ |
385 "/ |
387 "/ to use some collection which implements grow: more efficient |
387 "/ to use some collection which implements grow: more efficient |
388 "/ (i.e. use OrderedCollection instead of Array ..) |
388 "/ (i.e. use OrderedCollection instead of Array ..) |
389 "/ |
389 "/ |
390 'ArrayedCollection [info]: slow grow operation (' infoPrint. |
390 'ArrayedCollection [info]: slow grow operation (' infoPrint. |
391 self class name infoPrint. ') via ' infoPrint. |
391 self class name infoPrint. ') via ' infoPrint. |
392 senderContext := thisContext sender. |
392 sender := thisContext sender. |
393 [senderContext receiver == self] whileTrue:[ |
393 sender methodPrintString infoPrint. |
394 senderContext methodPrintString infoPrint. |
394 ' from ' infoPrint. sender sender methodPrintString infoPrintCR. |
395 senderSenderContext := senderContext sender. |
|
396 ' from ' infoPrint. senderSenderContext methodPrintString infoPrintCR. |
|
397 senderContext := senderSenderContext. |
|
398 ]. |
|
399 ]. |
395 ]. |
400 |
396 |
401 newArray := self species new:newSize. |
397 newArray := self species new:newSize. |
402 newArray replaceFrom:1 to:(newSize min:oldSize) with:self. |
398 newArray replaceFrom:1 to:(newSize min:oldSize) with:self. |
403 self become:newArray. |
399 self become:newArray. |
440 ! ! |
436 ! ! |
441 |
437 |
442 !ArrayedCollection class methodsFor:'documentation'! |
438 !ArrayedCollection class methodsFor:'documentation'! |
443 |
439 |
444 version |
440 version |
445 ^ '$Header: /cvs/stx/stx/libbasic/ArrayedCollection.st,v 1.51 2002-09-10 14:53:33 cg Exp $' |
441 ^ '$Header: /cvs/stx/stx/libbasic/ArrayedCollection.st,v 1.52 2002-09-10 15:29:35 cg Exp $' |
446 ! ! |
442 ! ! |