Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.902.mcz ==================== Summary ==================== Name: Collections-ul.902 Author: ul Time: 12 July 2020, 4:13:31.850218 pm UUID: 75865200-256c-40b8-9303-ec9a473c16cf Ancestors: Collections-ul.901 OrderedCollection changes: - override #allButFirstDo: and #allButLastDo: the same way #do: is done to achive better performance - use #to:do: instead of #whileTrue: in all methods iterating over the internal indices =============== Diff against Collections-ul.901 =============== Item was added: + ----- Method: OrderedCollection>>allButFirstDo: (in category 'enumerating') ----- + allButFirstDo: aBlock + "Override the superclass for performance reasons." + + firstIndex + 1 to: lastIndex do: [ :index | + aBlock value: (array at: index) ]! Item was added: + ----- Method: OrderedCollection>>allButLastDo: (in category 'enumerating') ----- + allButLastDo: aBlock + "Override the superclass for performance reasons." + + firstIndex to: lastIndex - 1 do: [ :index | + aBlock value: (array at: index) ]! Item was changed: ----- Method: OrderedCollection>>do: (in category 'enumerating') ----- do: aBlock "Override the superclass for performance reasons." + + firstIndex to: lastIndex do: [ :index | + aBlock value: (array at: index) ]! - | index | - index := firstIndex. - [index <= lastIndex] - whileTrue: - [aBlock value: (array at: index). - index := index + 1]! Item was changed: ----- Method: OrderedCollection>>find: (in category 'private') ----- find: oldObject " This method answers an index in the range firstIndex .. lastIndex, which is meant for internal use only. Never use this method in your code, the methods for public use are: #indexOf: #indexOf:ifAbsent: " + firstIndex to: lastIndex do: [ :index | + (array at: index) = oldObject ifTrue: [ ^index ] ]. - | index | - index := firstIndex. - [index <= lastIndex] - whileTrue: - [(array at: index) = oldObject ifTrue: [^ index]. - index := index + 1]. self errorNotFound: oldObject! Item was changed: ----- Method: OrderedCollection>>remove:ifAbsent: (in category 'removing') ----- remove: oldObject ifAbsent: absentBlock + firstIndex to: lastIndex do: [ :index | + (array at: index) = oldObject ifTrue: [ + self removeIndex: index. + ^oldObject ] ]. + ^absentBlock value! - | index | - index := firstIndex. - [index <= lastIndex] - whileTrue: - [oldObject = (array at: index) - ifTrue: - [self removeIndex: index. - ^ oldObject] - ifFalse: [index := index + 1]]. - ^ absentBlock value! Item was changed: ----- Method: OrderedCollection>>reverseDo: (in category 'enumerating') ----- reverseDo: aBlock "Override the superclass for performance reasons." + + lastIndex to: firstIndex by: -1 do: [ :index | + aBlock value: (array at: index) ]! - | index | - index := lastIndex. - [index >= firstIndex] - whileTrue: - [aBlock value: (array at: index). - index := index - 1]! |
Free forum by Nabble | Edit this page |