[Squeak-fr] Re: SortedCollection>>copyWithoutIndex:

nicolas cellier ncellier at ifrance.com
Mer 21 Mai 15:17:18 UTC 2008


Très bien, tu devrais signaler le bug sur mantis http://bugs.squeak.org

Le plus simple serait de changer l'implémentation de:
SequenceableCOllection>>copyWithoutIndex: index
     ^self copyReplaceFrom: index to: index with: #()

Nicolas


Olivier Blanc a écrit :
> 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
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Squeak-fr mailing list
> Squeak-fr at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/squeak-fr



Plus d'informations sur la liste de diffusion Squeak-fr