[squeak-dev] The Trunk: Collections-eem.1025.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Nov 23 14:43:13 UTC 2022


Eliot Miranda uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-eem.1025.mcz

==================== Summary ====================

Name: Collections-eem.1025
Author: eem
Time: 23 November 2022, 6:43:09.849872 am
UUID: b326199c-16c6-4df6-9f70-fc55b0718f20
Ancestors: Collections-eem.1024

Respond to Marcel's excellent suggestion. Rename SequenceableCollection>>subStrings: to subsequences: and implement String>>subStrings: upon it.

=============== Diff against Collections-eem.1024 ===============

Item was removed:
- ----- Method: SequenceableCollection>>subStrings: (in category 'converting') -----
- subStrings: separatorsOrElement
- 	"Answer an array containing the substrings in the receiver separated 
- 	 by the elements of separatorsOrElement, if it is a Collection, or a
- 	 singleton separator object, if it is not."
- 
- 	| result size thing subsequenceStart |
- 	result := OrderedCollection new.
- 	size := self size.
- 	separatorsOrElement isCollection
- 		ifTrue:
- 			[1 to: size do:
- 				[:i|
- 				thing := self at: i.
- 				(separatorsOrElement includes: thing)
- 					ifTrue:
- 						[subsequenceStart ifNotNil:
- 							[result addLast: (self copyFrom: subsequenceStart to: i - 1)].
- 						 subsequenceStart := nil]
- 					ifFalse:
- 						[subsequenceStart ifNil: [subsequenceStart := i]]]]
- 		ifFalse:
- 			[1 to: size do:
- 				[:i|
- 				thing := self at: i.
- 				separatorsOrElement = thing
- 					ifTrue:
- 						[subsequenceStart ifNotNil:
- 							[result addLast: (self copyFrom: subsequenceStart to: i - 1)].
- 						 subsequenceStart := nil]
- 					ifFalse:
- 						[subsequenceStart ifNil: [subsequenceStart := i]]]].
- 	subsequenceStart ifNotNil:
- 		[result addLast: (self copyFrom: subsequenceStart to: size)].
- 	^result asArray
- 
- 	"'Now is the time for all good people to come to the aid of the cause of world peace.  It is just fine, even desirable, to love your country, if that means wanting it to play a beneficial role in the course of world events and be the best possible example of a good society.  But if it means wanting dominion over the rest of the world, it is not love but defensiveness or self-glorification, and will lead only to oblivion.' subStrings: Character space"
- 
- 	"'Now is the time for all good people to come to the aid of the cause of world peace.  It is just fine, even desirable, to love your country, if that means wanting it to play a beneficial role in the course of world events and be the best possible example of a good society.  But if it means wanting dominion over the rest of the world, it is not love but defensiveness or self-glorification, and will lead only to oblivion.' subStrings: ' ,.-'"!

Item was added:
+ ----- Method: SequenceableCollection>>subsequences: (in category 'converting') -----
+ subsequences: separatorsOrElement
+ 	"Answer an array containing the subsequences in the receiver separated 
+ 	 by the elements of separatorsOrElement, if it is a Collection, or a
+ 	 single separator object, if it is not."
+ 
+ 	| result size thing subsequenceStart |
+ 	result := OrderedCollection new.
+ 	size := self size.
+ 	separatorsOrElement isCollection
+ 		ifTrue:
+ 			[1 to: size do:
+ 				[:i|
+ 				thing := self at: i.
+ 				(separatorsOrElement includes: thing)
+ 					ifTrue:
+ 						[subsequenceStart ifNotNil:
+ 							[result addLast: (self copyFrom: subsequenceStart to: i - 1)].
+ 						 subsequenceStart := nil]
+ 					ifFalse:
+ 						[subsequenceStart ifNil: [subsequenceStart := i]]]]
+ 		ifFalse:
+ 			[1 to: size do:
+ 				[:i|
+ 				thing := self at: i.
+ 				separatorsOrElement = thing
+ 					ifTrue:
+ 						[subsequenceStart ifNotNil:
+ 							[result addLast: (self copyFrom: subsequenceStart to: i - 1)].
+ 						 subsequenceStart := nil]
+ 					ifFalse:
+ 						[subsequenceStart ifNil: [subsequenceStart := i]]]].
+ 	subsequenceStart ifNotNil:
+ 		[result addLast: (self copyFrom: subsequenceStart to: size)].
+ 	^result asArray
+ 
+ 	"'Now is the time for all good people to come to the aid of the cause of world peace.  It is just fine, even desirable, to love your country, if that means wanting it to play a beneficial role in the course of world events and be the best possible example of a good society.  But if it means wanting dominion over the rest of the world, it is not love but defensiveness or self-glorification, and will lead only to oblivion.' subStrings: Character space"
+ 
+ 	"'Now is the time for all good people to come to the aid of the cause of world peace.  It is just fine, even desirable, to love your country, if that means wanting it to play a beneficial role in the course of world events and be the best possible example of a good society.  But if it means wanting dominion over the rest of the world, it is not love but defensiveness or self-glorification, and will lead only to oblivion.' subStrings: ' ,.-'"!

Item was changed:
  ----- Method: String>>subStrings: (in category 'converting') -----
  subStrings: separators 
  	"Answer an array containing the substrings in the receiver separated 
  	 by the elements of separators, which should be a collection of Characters,
  	 or, for convenience, a single character.."
  	(separators isCharacter or: [separators isString or:[separators allSatisfy: [:element | element isCharacter]]]) ifTrue:
+ 		[^self subsequences: separators].
- 		[^super subStrings: separators].
  	^self error: 'separators must be Characters.'
  
  	"'Now is the time for all good people to come to the aid of the cause of world peace.  It is just fine, even desirable, to love your country, if that means wanting it to play a beneficial role in the course of world events and be the best possible example of a good society.  But if it means wanting dominion over the rest of the world, it is not love but defensiveness or self-glorification, and will lead only to oblivion.' subStrings: Character space"
  
  	"'Now is the time for all good people to come to the aid of the cause of world peace.  It is just fine, even desirable, to love your country, if that means wanting it to play a beneficial role in the course of world events and be the best possible example of a good society.  But if it means wanting dominion over the rest of the world, it is not love but defensiveness or self-glorification, and will lead only to oblivion.' subStrings: ' ,.-'"!



More information about the Squeak-dev mailing list