--- a/CharacterArray.st Sat Aug 10 13:32:14 2019 +0200
+++ b/CharacterArray.st Sat Aug 10 14:06:32 2019 +0200
@@ -417,6 +417,7 @@
"Modified: / 16-01-2018 / 18:59:04 / stefan"
! !
+
!CharacterArray class methodsFor:'cleanup'!
lowSpaceCleanup
@@ -679,6 +680,7 @@
"
! !
+
!CharacterArray class methodsFor:'pattern matching'!
matchEscapeCharacter
@@ -1086,6 +1088,7 @@
^ Unicode32String
! !
+
!CharacterArray class methodsFor:'utilities'!
through:aCharacter in:inStream
@@ -3402,6 +3405,50 @@
"Modified (comment): / 03-07-2018 / 10:59:36 / Claus Gittinger"
!
+asCollectionOfLinesDo:aBlock
+ "evaluate aBlock for each line (separated by cr) of the receiver.
+ Returns the number of lines (i.e. the number of invocations of aBlock).
+ This is similar to 'asCollectionOfLines do:...' or 'asStringCollection do:...'
+ but avoids the creation of a temporary collection."
+
+ |count "{ Class:SmallInteger }"
+ start "{ Class:SmallInteger }"
+ stop "{ Class:SmallInteger }"
+ mySize "{ Class:SmallInteger }"|
+
+ count := 0.
+ start := 1.
+ mySize := self size.
+ [start <= mySize] whileTrue:[
+ stop := self indexOf:Character cr startingAt:start.
+ stop == 0 ifTrue:[
+ aBlock value:(self copyFrom:start to:mySize).
+ ^ count + 1
+ ].
+ aBlock value:(self copyFrom:start to:(stop - 1)).
+ start := stop+1.
+ count := count + 1
+ ].
+ ^ count
+
+ "
+
+ c'hello\nworld\nisnt\nthis\n\nnice' asCollectionOfLinesDo:[:l | Transcript showCR:l]
+ c'hello\nworld\nisnt\nthis\n\nnice' asStringCollection do:[:l | Transcript showCR:l]
+
+ c'hello\nworld\nisnt\nthis\n\nnice\n' asCollectionOfLinesDo:[:l | Transcript showCR:l]
+ c'hello\nworld\nisnt\nthis\n\nnice\n' asStringCollection do:[:l | Transcript showCR:l]
+
+ c'hello\nworld\nisnt\nthis\n\nnice' asCollectionOfWordsDo:#transcribeCR
+ ' hello\n world\n isnt\n this\n nice\n ' asCollectionOfLinesDo:#transcribeCR
+ 'hello' asCollectionOfLinesDo:#transcribeCR
+ '' asCollectionOfLinesDo:#transcribeCR
+ ' ' asCollectionOfLinesDo:#transcribeCR
+ "
+
+ "Modified (comment): / 03-02-2019 / 13:08:15 / Claus Gittinger"
+!
+
asCollectionOfLinesWithReturn
"return a collection containing the lines (separated by cr) of the receiver.
If multiple cr's occur in a row, the result will contain empty strings."
@@ -3620,7 +3667,9 @@
"evaluate aBlock for each word (separated by whitespace) of the receiver.
Multiple occurrences of whitespace characters will be treated like one
- i.e. whitespace is skipped.
- Returns the number of words (i.e. the number of invocations of aBlock)."
+ Returns the number of words (i.e. the number of invocations of aBlock).
+ This is the same as 'asCollectionOfWords do:...' but avoids the creation of
+ a temporary collection."
|count "{ Class:SmallInteger }"
start "{ Class:SmallInteger }"
@@ -5429,6 +5478,8 @@
! !
+
+
!CharacterArray methodsFor:'matching - glob expressions'!
compoundMatch:aString
@@ -7459,6 +7510,7 @@
"Modified: 17.4.1997 / 12:50:23 / cg"
! !
+
!CharacterArray methodsFor:'special string converting'!
asUnixFilenameString
@@ -9188,6 +9240,7 @@
"
! !
+
!CharacterArray methodsFor:'substring searching'!
findRangeOfString:subString
@@ -9773,6 +9826,7 @@
^ aVisitor visitString:self with:aParameter
! !
+
!CharacterArray class methodsFor:'documentation'!
version