[squeak-dev] The Trunk: Collections-mt.878.mcz
commits at source.squeak.org
commits at source.squeak.org
Wed Mar 4 15:41:17 UTC 2020
Marcel Taeumel uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-mt.878.mcz
==================== Summary ====================
Name: Collections-mt.878
Author: mt
Time: 4 March 2020, 4:41:15.113366 pm
UUID: d29cf56c-33dd-6a43-a537-76c689e2ea95
Ancestors: Collections-ul.877
Make the collection protocol in Stream more explicit. Fix a typo.
=============== Diff against Collections-ul.877 ===============
Item was changed:
----- Method: Collection>>any:as: (in category 'accessing') -----
any: numberOfElements as: aClass
+ "Enumerate this collection and return the specified number of elements. Signals an error if this collection has not enough elements."
- "Enumerate this colleciton and return the specified number of elements. Signals an error if this collection has not enough elements."
| index result |
index := 0.
result := aClass new: numberOfElements.
result fillFrom: self with: [:each |
(index := index + 1) > numberOfElements
ifTrue: [^ result]
ifFalse: [each]].
index = numberOfElements
ifFalse: [self error: 'Not enough elements in this collection.'].
^ result!
Item was changed:
----- Method: Collection>>take: (in category 'accessing') -----
take: maxNumberOfElements
+ "Returns maxNumberOfElements as a new collection (using my #species) or less if the collection is not large enough."
- "Returns maxNumberOfElements as a new collection or less if the collection is not large enough."
^ self any: (maxNumberOfElements min: self size)!
Item was changed:
+ ----- Method: Stream>>any: (in category 'collections - accessing') -----
- ----- Method: Stream>>any: (in category 'accessing') -----
any: numberOfElements
"See Collection protocol."
^ self next: numberOfElements!
Item was changed:
+ ----- Method: Stream>>collect: (in category 'collections - enumerating') -----
- ----- Method: Stream>>collect: (in category 'enumerating') -----
collect: block
^ Generator on: [:g |
[self atEnd] whileFalse: [
g yield: (self next ifNotNil: [:object | block value: object])]]!
Item was changed:
+ ----- Method: Stream>>do: (in category 'collections - enumerating') -----
- ----- Method: Stream>>do: (in category 'enumerating') -----
do: aBlock
"Evaluate aBlock for each of the objects accessible by receiver."
[self atEnd]
whileFalse: [aBlock value: self next]!
Item was changed:
+ ----- Method: Stream>>gather: (in category 'collections - enumerating') -----
- ----- Method: Stream>>gather: (in category 'enumerating') -----
gather: block
^ Generator on: [:g |
[self atEnd] whileFalse: [
self next
ifNil: [g yield: nil]
ifNotNil: [:object |
(block value: object) do: [:ea |
g yield: ea]]]]!
Item was changed:
+ ----- Method: Stream>>reject: (in category 'collections - enumerating') -----
- ----- Method: Stream>>reject: (in category 'enumerating') -----
reject: aBlock
^ self select: [:element | (aBlock value: element) == false]!
Item was changed:
+ ----- Method: Stream>>select: (in category 'collections - enumerating') -----
- ----- Method: Stream>>select: (in category 'enumerating') -----
select: block
^ Generator on: [:g |
[self atEnd] whileFalse: [
self next
ifNil: [g yield: nil]
ifNotNil: [:object |
(block value: object)
ifTrue: [g yield: object]]]]!
Item was changed:
+ ----- Method: Stream>>select:thenCollect: (in category 'collections - enumerating') -----
- ----- Method: Stream>>select:thenCollect: (in category 'enumerating') -----
select: block thenCollect: anotherBlock
^ (self select: block) collect: anotherBlock!
Item was changed:
+ ----- Method: Stream>>take: (in category 'collections - accessing') -----
- ----- Method: Stream>>take: (in category 'accessing') -----
take: maxNumberOfElements
"See Collection protocol."
^ self any: maxNumberOfElements!
More information about the Squeak-dev
mailing list
|