Chris Muller uploaded a new version of Collections to project The Trunk: http://source.squeak.org/trunk/Collections-cmm.1059.mcz
==================== Summary ====================
Name: Collections-cmm.1059 Author: cmm Time: 18 February 2024, 5:19:05.159381 pm UUID: 982eb6aa-f237-4e79-a208-ae6b2f23cf1b Ancestors: Collections-mt.1058
- Let #peek: support a negative number of characters to peekBack:. - Let SharedQueue2 support #atEnd.
=============== Diff against Collections-mt.1058 ===============
Item was changed: ----- Method: PositionableStream>>peek: (in category 'accessing') ----- + peek: anInteger + ^ anInteger positive + ifTrue: [ self peekForward: anInteger ] + ifFalse: [ self peekBack: anInteger abs ]! - peek: anInteger - "Answer what would be returned if the message next: anInteger were sent to the receiver. If the receiver has less than anInteger more elements, only answer so many elements as available." - - | oldPosition result | - oldPosition := position. - result := self next: anInteger. - position := oldPosition. - ^ result!
Item was added: + ----- Method: PositionableStream>>peekBack: (in category 'accessing') ----- + peekBack: anInteger + "Answer anInteger characters previous to the current position, or all to the beginning, whichever is fewer." + ^ anInteger negative + ifTrue: [ self peek: anInteger negated ] + ifFalse: + [ | toSkip | toSkip := anInteger min: self position. + self + skip: toSkip negated ; + next: toSkip ]!
Item was added: + ----- Method: PositionableStream>>peekForward: (in category 'accessing') ----- + peekForward: anInteger + "Answer what would be returned if the message next: anInteger were sent to the receiver. If the receiver is at the end, answer an empty string." + | priorPos result | + priorPos := position. + result := self next: anInteger. + position := priorPos. + ^ result!
Item was added: + ----- Method: SharedQueue2>>atEnd (in category 'testing') ----- + atEnd + ^ monitor critical: [ items isEmpty ]!
packages@lists.squeakfoundation.org