[Squeak-fr] SortedCollection>>copyWithoutIndex:
Olivier Blanc
olivier.blanc at laposte.net
Jeu 15 Mai 17:55:39 UTC 2008
Bonjour,
La classe SortedCollection implémente la méthode copyWithoutIndex: comme
suit :
copyWithoutIndex: index
"Return a copy containing all elements except the index-th."
| copy |
copy := self species ofSize: self size - 1.
copy replaceFrom: 1 to: index-1 with: self startingAt: 1.
copy replaceFrom: index to: copy size with: self startingAt: index+1.
^ copy
qui utilise la méthode
replaceFrom: start to: stop with: replacement startingAt: repStart
"This destructively replaces elements from start to stop in the
receiver
starting at index, repStart, in the sequenceable collection,
replacementCollection. Answer the receiver. No range checks are
performed."
| index repOff |
repOff := repStart - start.
index := start - 1.
[(index := index + 1) <= stop]
whileTrue: [self at: index put: (replacement at: repOff + index)]
Elle même utilise la méthode at:put qui ne doit pas être utilisée sur
une collection triée.... d'où le message d'erreur
at: anInteger put: anObject
self shouldNotImplement
J'utilise l'image sq3.10-7159web08.03.1
Je pense qu'un reject: sera plus simple.... Mais cependant, ce
cheminement, avec cette erreur, ne devrait pas être à mon sens.
Olivier
-------------- section suivante --------------
Une pièce jointe HTML a été enlevée...
URL: http://lists.squeakfoundation.org/pipermail/squeak-fr/attachments/20080515/ccb724e5/attachment.htm
Plus d'informations sur la liste de diffusion Squeak-fr