--- a/FileText.st Thu Nov 23 02:18:58 1995 +0100
+++ b/FileText.st Thu Nov 23 02:23:34 1995 +0100
@@ -11,11 +11,10 @@
"
StringCollection subclass:#FileText
- instanceVariableNames:'myStream lastLineKnown lastLineOfFile
- cachedLines cacheLineNr'
- classVariableNames:''
- poolDictionaries:''
- category:'Collections-Text'
+ instanceVariableNames:'myStream lastLineKnown lastLineOfFile cachedLines cacheLineNr'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Collections-Text'
!
!FileText class methodsFor:'documentation'!
@@ -34,10 +33,6 @@
"
!
-version
- ^ '$Header: /cvs/stx/stx/libbasic2/FileText.st,v 1.12 1995-11-11 15:21:20 cg Exp $'
-!
-
documentation
"
FileText represents the contents of a text-file;
@@ -55,6 +50,10 @@
It is highly recommended, to use fileText for readonly texts only.
"
+!
+
+version
+ ^ '$Header: /cvs/stx/stx/libbasic2/FileText.st,v 1.13 1995-11-23 01:23:34 cg Exp $'
! !
!FileText class methodsFor:'instance creation'!
@@ -77,15 +76,6 @@
!FileText methodsFor:'accessing'!
-of:aStream
- myStream := aStream.
- lastLineOfFile := nil.
- lastLineKnown := 0.
- cachedLines := nil
-! !
-
-!FileText methodsFor:'accessing'!
-
at:index
|entry oldPosition|
@@ -118,7 +108,14 @@
^ cachedLines at:(index - cacheLineNr + 1)
!
-
+
+of:aStream
+ myStream := aStream.
+ lastLineOfFile := nil.
+ lastLineKnown := 0.
+ cachedLines := nil
+!
+
size
"return the number of text-lines - have to scan file the first time"
@@ -186,3 +183,4 @@
]
]
! !
+
--- a/StrColl.st Thu Nov 23 02:18:58 1995 +0100
+++ b/StrColl.st Thu Nov 23 02:23:34 1995 +0100
@@ -11,10 +11,10 @@
"
VariableArray subclass:#StringCollection
- instanceVariableNames:''
- classVariableNames:''
- poolDictionaries:''
- category:'Collections-Text'
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Collections-Text'
!
!StringCollection class methodsFor:'documentation'!
@@ -33,10 +33,6 @@
"
!
-version
- ^ '$Header: /cvs/stx/stx/libbasic2/Attic/StrColl.st,v 1.17 1995-11-11 15:21:56 cg Exp $'
-!
-
documentation
"
StringCollection is an variable sized array of lines which are strings.
@@ -48,6 +44,10 @@
StringCollection used to be called Text, but this is a very bad name
- there is something totally different also named Text in ST-80 ...
"
+!
+
+version
+ ^ '$Header: /cvs/stx/stx/libbasic2/Attic/StrColl.st,v 1.18 1995-11-23 01:22:57 cg Exp $'
! !
!StringCollection class methodsFor:'instance creation'!
@@ -73,33 +73,6 @@
^ newStringCollection
! !
-!StringCollection methodsFor:'growing'!
-
-grow:newSize
- "grow to newsize - new elements are initialized with empty strings -
- not nil"
-
- |oldSize "{ Class:SmallInteger }"|
-
- oldSize := tally.
- super grow:newSize.
- (oldSize < newSize) ifTrue:[
- contentsArray from:(oldSize + 1) to:newSize put:''
- ]
-!
-
-add:aString
- "append the argument, aString to myself -
- we increase physical size by 50 to avoid lots of copying around"
-
- |oldSize "{ Class:SmallInteger }"|
-
- oldSize := tally.
- super grow:(oldSize + 50).
- tally := oldSize + 1.
- contentsArray at:tally put:aString
-! !
-
!StringCollection methodsFor:'converting'!
asString
@@ -111,6 +84,12 @@
final:Character cr
!
+asStringCollection
+ "return the receiver as a stringCollection - thats easy"
+
+ ^ self
+!
+
from:aString
"setup my contents from the argument, aString"
@@ -139,12 +118,33 @@
].
start := stop + 2
]
+! !
+
+!StringCollection methodsFor:'growing'!
+
+add:aString
+ "append the argument, aString to myself -
+ we increase physical size by 50 to avoid lots of copying around"
+
+ |oldSize "{ Class:SmallInteger }"|
+
+ oldSize := tally.
+ super grow:(oldSize + 50).
+ tally := oldSize + 1.
+ contentsArray at:tally put:aString
!
-asStringCollection
- "return the receiver as a stringCollection - thats easy"
+grow:newSize
+ "grow to newsize - new elements are initialized with empty strings -
+ not nil"
+
+ |oldSize "{ Class:SmallInteger }"|
- ^ self
+ oldSize := tally.
+ super grow:newSize.
+ (oldSize < newSize) ifTrue:[
+ contentsArray from:(oldSize + 1) to:newSize put:''
+ ]
! !
!StringCollection methodsFor:'printing'!
@@ -171,3 +171,4 @@
].
^ 0
! !
+
--- a/TwoByteStr.st Thu Nov 23 02:18:58 1995 +0100
+++ b/TwoByteStr.st Thu Nov 23 02:23:34 1995 +0100
@@ -11,10 +11,10 @@
"
CharacterArray subclass:#TwoByteString
- instanceVariableNames:''
- classVariableNames:''
- poolDictionaries:''
- category:'Collections-Text'
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Collections-Text'
!
!TwoByteString class methodsFor:'documentation'!
@@ -33,15 +33,15 @@
"
!
-version
- ^ '$Header: /cvs/stx/stx/libbasic2/Attic/TwoByteStr.st,v 1.13 1995-11-11 15:21:57 cg Exp $'
-!
-
documentation
"
TwoByteStrings are like strings, but storing 16bits per character.
The integration of them into the system is not completed ....
"
+!
+
+version
+ ^ '$Header: /cvs/stx/stx/libbasic2/Attic/TwoByteStr.st,v 1.14 1995-11-23 01:22:31 cg Exp $'
! !
!TwoByteString class methodsFor:'instance creation'!
@@ -192,15 +192,6 @@
"
! !
-!TwoByteString methodsFor:'queries'!
-
-basicSize
- "return the size of the receiver.
- (i.e. the number of characters in this String)"
-
- ^ super basicSize // 2
-! !
-
!TwoByteString methodsFor:'accessing'!
basicAt:index
@@ -227,3 +218,13 @@
super basicAt:i put:(val // 256).
^ aCharacter
! !
+
+!TwoByteString methodsFor:'queries'!
+
+basicSize
+ "return the size of the receiver.
+ (i.e. the number of characters in this String)"
+
+ ^ super basicSize // 2
+! !
+
--- a/ValLink.st Thu Nov 23 02:18:58 1995 +0100
+++ b/ValLink.st Thu Nov 23 02:23:34 1995 +0100
@@ -11,10 +11,10 @@
"
Link subclass:#ValueLink
- instanceVariableNames:'value'
- classVariableNames:''
- poolDictionaries:''
- category:'Collections-Support'
+ instanceVariableNames:'value'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Collections-Support'
!
!ValueLink class methodsFor:'documentation'!
@@ -33,15 +33,15 @@
"
!
-version
- ^ '$Header: /cvs/stx/stx/libbasic2/Attic/ValLink.st,v 1.9 1995-11-11 15:21:58 cg Exp $'
-!
-
documentation
"
this class provides Links which can hold a value.
Instances are typically used as elements in a linkedList.
"
+!
+
+version
+ ^ '$Header: /cvs/stx/stx/libbasic2/Attic/ValLink.st,v 1.10 1995-11-23 01:21:34 cg Exp $'
! !
!ValueLink methodsFor:'accessing'!
@@ -57,3 +57,4 @@
value := anObject
! !
+
--- a/ValueLink.st Thu Nov 23 02:18:58 1995 +0100
+++ b/ValueLink.st Thu Nov 23 02:23:34 1995 +0100
@@ -11,10 +11,10 @@
"
Link subclass:#ValueLink
- instanceVariableNames:'value'
- classVariableNames:''
- poolDictionaries:''
- category:'Collections-Support'
+ instanceVariableNames:'value'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Collections-Support'
!
!ValueLink class methodsFor:'documentation'!
@@ -33,15 +33,15 @@
"
!
-version
- ^ '$Header: /cvs/stx/stx/libbasic2/ValueLink.st,v 1.9 1995-11-11 15:21:58 cg Exp $'
-!
-
documentation
"
this class provides Links which can hold a value.
Instances are typically used as elements in a linkedList.
"
+!
+
+version
+ ^ '$Header: /cvs/stx/stx/libbasic2/ValueLink.st,v 1.10 1995-11-23 01:21:34 cg Exp $'
! !
!ValueLink methodsFor:'accessing'!
@@ -57,3 +57,4 @@
value := anObject
! !
+
--- a/VarArray.st Thu Nov 23 02:18:58 1995 +0100
+++ b/VarArray.st Thu Nov 23 02:23:34 1995 +0100
@@ -11,10 +11,10 @@
"
ArrayedCollection subclass:#VariableArray
- instanceVariableNames:'tally contentsArray'
- classVariableNames:''
- poolDictionaries:''
- category:'Collections-Sequenceable'
+ instanceVariableNames:'tally contentsArray'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Collections-Sequenceable'
!
!VariableArray class methodsFor:'documentation'!
@@ -33,10 +33,6 @@
"
!
-version
- ^ '$Header: /cvs/stx/stx/libbasic2/Attic/VarArray.st,v 1.12 1995-11-11 15:22:00 cg Exp $'
-!
-
documentation
"
VariableArrays can grow and shrink - in contrast to Arrays which are
@@ -47,6 +43,10 @@
Use OrderedCollection, which offers more functionality, and is even
a bit faster in some operations.
"
+!
+
+version
+ ^ '$Header: /cvs/stx/stx/libbasic2/Attic/VarArray.st,v 1.13 1995-11-23 01:20:36 cg Exp $'
! !
!VariableArray class methodsFor:'instance creation'!
@@ -63,54 +63,44 @@
^ (self basicNew) setContents:(Array new:size)
! !
-!VariableArray methodsFor:'kludges'!
+!VariableArray methodsFor:'accessing'!
-shallowCopy:anArray
- "return a shallow copy of the receiver
- have to kludge the kludge ... - shallow copy the contents array"
-
- |newText|
+at:index
+ "return the element at index"
- newText := self class new.
- newText setContents:(contentsArray shallowCopy).
- ^ newText
-! !
-
-!VariableArray methodsFor:'private'!
-
-getContents
- "return the contents array"
-
- ^ contentsArray
+ (index between:1 and:tally) ifFalse:[
+ ^ self subscriptBoundsError:index
+ ].
+ ^ contentsArray at:index
!
-setInitialContents:anArray
- "set the contents array but make size zero"
+at:index put:anObject
+ "set the element at index"
- tally := 0.
- contentsArray := anArray
-!
-
-setContents:anArray
- "set the contents array"
-
- tally := anArray size.
- contentsArray := anArray
+ (index between:1 and:tally) ifFalse:[
+ ^ self subscriptBoundsError:index
+ ].
+ ^ contentsArray at:index put:anObject
! !
-!VariableArray methodsFor:'inquiries'!
+!VariableArray methodsFor:'enumerating'!
-size
- "return the number of array elements"
+do:aBlock
+ "evaluate the argument, aBlock for each element
+ in the collection"
- ^ tally
+ contentsArray from:1 to:tally do:aBlock
!
-isFixedSize
- "return true if the receiver cannot grow - this will vanish once
- Arrays and Strings learn how to grow ..."
+from:start to:stop do:aBlock
+ "evaluate the argument, aBlock for some elements
+ in the collection"
- ^ false
+ (stop <= tally) ifTrue:[
+ contentsArray from:start to:stop do:aBlock
+ ] ifFalse:[
+ super from:start to:stop do:aBlock
+ ]
! !
!VariableArray methodsFor:'filling & replacing'!
@@ -136,6 +126,91 @@
^ super replaceFrom:start to:stop with:aCollection startingAt:repStart
! !
+!VariableArray methodsFor:'grow & shrink'!
+
+add:anElement
+ "add anElement to the end of the array"
+
+ |newSize "{ Class: SmallInteger }" |
+
+ newSize := tally + 1.
+ (newSize <= contentsArray size) ifTrue:[
+ tally := newSize
+ ] ifFalse:[
+ self grow:newSize
+ ].
+ contentsArray at:tally put:anElement
+!
+
+grow:newSize
+ "grow to newSize"
+
+ |newArray|
+
+ (newSize == tally) ifTrue:[^ self].
+
+ (newSize > tally) ifTrue:[
+ (newSize > contentsArray size) ifTrue:[
+ newArray := Array new:(newSize * 2).
+ newArray replaceFrom:1 to:tally with:contentsArray startingAt:1.
+ contentsArray := newArray
+ ]
+ ] ifFalse:[
+ contentsArray from:(newSize + 1) to:tally put:nil
+ ].
+ tally := newSize
+! !
+
+!VariableArray methodsFor:'inquiries'!
+
+isFixedSize
+ "return true if the receiver cannot grow - this will vanish once
+ Arrays and Strings learn how to grow ..."
+
+ ^ false
+!
+
+size
+ "return the number of array elements"
+
+ ^ tally
+! !
+
+!VariableArray methodsFor:'kludges'!
+
+shallowCopy:anArray
+ "return a shallow copy of the receiver
+ have to kludge the kludge ... - shallow copy the contents array"
+
+ |newText|
+
+ newText := self class new.
+ newText setContents:(contentsArray shallowCopy).
+ ^ newText
+! !
+
+!VariableArray methodsFor:'private'!
+
+getContents
+ "return the contents array"
+
+ ^ contentsArray
+!
+
+setContents:anArray
+ "set the contents array"
+
+ tally := anArray size.
+ contentsArray := anArray
+!
+
+setInitialContents:anArray
+ "set the contents array but make size zero"
+
+ tally := 0.
+ contentsArray := anArray
+! !
+
!VariableArray methodsFor:'removing'!
removeFromIndex:startIndex toIndex:endIndex
@@ -154,10 +229,22 @@
!VariableArray methodsFor:'testing'!
-occurrencesOf:anObject
- "return the number of occurrences of anObject in the receiver"
+identityIndexOf:anElement startingAt:start
+ "search the collection for anElement starting search at index start
+ using == for compares.
+ if found, return the index otherwise return 0"
+
+ |index|
- ^ contentsArray occurrencesOf:anObject
+ (start > tally) ifFalse:[
+ index := contentsArray identityIndexOf:anElement startingAt:start.
+ index == 0 ifFalse:[
+ (index between:1 and:tally) ifTrue:[
+ ^ index
+ ]
+ ]
+ ].
+ ^ 0
!
includes:anObject
@@ -184,95 +271,9 @@
^ 0
!
-identityIndexOf:anElement startingAt:start
- "search the collection for anElement starting search at index start
- using == for compares.
- if found, return the index otherwise return 0"
-
- |index|
+occurrencesOf:anObject
+ "return the number of occurrences of anObject in the receiver"
- (start > tally) ifFalse:[
- index := contentsArray identityIndexOf:anElement startingAt:start.
- index == 0 ifFalse:[
- (index between:1 and:tally) ifTrue:[
- ^ index
- ]
- ]
- ].
- ^ 0
-! !
-
-!VariableArray methodsFor:'accessing'!
-
-at:index
- "return the element at index"
-
- (index between:1 and:tally) ifFalse:[
- ^ self subscriptBoundsError:index
- ].
- ^ contentsArray at:index
-!
-
-at:index put:anObject
- "set the element at index"
-
- (index between:1 and:tally) ifFalse:[
- ^ self subscriptBoundsError:index
- ].
- ^ contentsArray at:index put:anObject
+ ^ contentsArray occurrencesOf:anObject
! !
-!VariableArray methodsFor:'grow & shrink'!
-
-grow:newSize
- "grow to newSize"
-
- |newArray|
-
- (newSize == tally) ifTrue:[^ self].
-
- (newSize > tally) ifTrue:[
- (newSize > contentsArray size) ifTrue:[
- newArray := Array new:(newSize * 2).
- newArray replaceFrom:1 to:tally with:contentsArray startingAt:1.
- contentsArray := newArray
- ]
- ] ifFalse:[
- contentsArray from:(newSize + 1) to:tally put:nil
- ].
- tally := newSize
-!
-
-add:anElement
- "add anElement to the end of the array"
-
- |newSize "{ Class: SmallInteger }" |
-
- newSize := tally + 1.
- (newSize <= contentsArray size) ifTrue:[
- tally := newSize
- ] ifFalse:[
- self grow:newSize
- ].
- contentsArray at:tally put:anElement
-! !
-
-!VariableArray methodsFor:'enumerating'!
-
-do:aBlock
- "evaluate the argument, aBlock for each element
- in the collection"
-
- contentsArray from:1 to:tally do:aBlock
-!
-
-from:start to:stop do:aBlock
- "evaluate the argument, aBlock for some elements
- in the collection"
-
- (stop <= tally) ifTrue:[
- contentsArray from:start to:stop do:aBlock
- ] ifFalse:[
- super from:start to:stop do:aBlock
- ]
-! !
--- a/VarString.st Thu Nov 23 02:18:58 1995 +0100
+++ b/VarString.st Thu Nov 23 02:23:34 1995 +0100
@@ -10,11 +10,11 @@
hereby transferred.
"
-ArrayedCollection subclass:#VariableString
- instanceVariableNames:'contents'
- classVariableNames:''
- poolDictionaries:''
- category:'Collections-Text'
+nil subclass:#VariableString
+ instanceVariableNames:'contents'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Collections-Text'
!
!VariableString class methodsFor:'documentation'!
@@ -33,10 +33,6 @@
"
!
-version
- ^ '$Header: /cvs/stx/stx/libbasic2/Attic/VarString.st,v 1.13 1995-11-11 15:22:01 cg Exp $'
-!
-
documentation
"
VariableStrings can grow and shrink - in contrast to Strings which are
@@ -45,6 +41,10 @@
WARNING: This class is a historic leftover and will vanish soon.
Dont use it.
"
+!
+
+version
+ ^ '$Header: /cvs/stx/stx/libbasic2/Attic/VarString.st,v 1.14 1995-11-23 01:22:07 cg Exp $'
! !
!VariableString class methodsFor:'initialization'!
@@ -57,6 +57,12 @@
!VariableString class methodsFor:'instance creation'!
+copyFrom:aString
+ "return a new VariableString with contents copied from the argument"
+
+ ^ self basicNew setContents:(String copyFrom:aString)
+!
+
new
"return a new VariableString - with size 0"
@@ -67,12 +73,6 @@
"return a new VariableString"
^ (self basicNew) setContents:(String new:size)
-!
-
-copyFrom:aString
- "return a new VariableString with contents copied from the argument"
-
- ^ self basicNew setContents:(String copyFrom:aString)
! !
!VariableString methodsFor:'accessing'!
@@ -89,17 +89,27 @@
^ contents at:index put:anObject
! !
-!VariableString methodsFor:'queries'!
+!VariableString methodsFor:'converting'!
-size
- ^ contents size
-!
+asStringCollection
+ ^ contents asStringCollection
+! !
+
+!VariableString methodsFor:'copying'!
-isFixedSize
- "return true if the receiver cannot grow - this will vanish once
- Arrays and Strings learn how to grow ..."
+postCopy
+ contents := contents copy
+! !
+
+!VariableString methodsFor:'error handling'!
- ^ false
+doesNotUnderstand:aMessage
+ "this is funny: all message we do not understand, are passed
+ on to the string - so we do not have to care for all
+ possible messages ...(thanks to the Message class)"
+
+ ^ contents perform:(aMessage selector)
+ withArguments:(aMessage arguments)
! !
!VariableString methodsFor:'filling & replacing'!
@@ -126,43 +136,6 @@
^ super replaceFrom:start to:stop with:aCollection startingAt:repStart
! !
-!VariableString methodsFor:'converting'!
-
-asStringCollection
- ^ contents asStringCollection
-! !
-
-!VariableString methodsFor:'copying'!
-
-postCopy
- contents := contents copy
-! !
-
-!VariableString methodsFor:'private'!
-
-getContents
- "return the contents array"
-
- ^ contents
-!
-
-setContents:aString
- "set the contents"
-
- contents := aString
-! !
-
-!VariableString methodsFor:'error handling'!
-
-doesNotUnderstand:aMessage
- "this is funny: all message we do not understand, are passed
- on to the string - so we do not have to care for all
- possible messages ...(thanks to the Message class)"
-
- ^ contents perform:(aMessage selector)
- withArguments:(aMessage arguments)
-! !
-
!VariableString methodsFor:'grow & shrink'!
grow:newSize
@@ -184,3 +157,32 @@
]
]
! !
+
+!VariableString methodsFor:'private'!
+
+getContents
+ "return the contents array"
+
+ ^ contents
+!
+
+setContents:aString
+ "set the contents"
+
+ contents := aString
+! !
+
+!VariableString methodsFor:'queries'!
+
+isFixedSize
+ "return true if the receiver cannot grow - this will vanish once
+ Arrays and Strings learn how to grow ..."
+
+ ^ false
+!
+
+size
+ ^ contents size
+! !
+
+VariableString initialize!
--- a/VariableArray.st Thu Nov 23 02:18:58 1995 +0100
+++ b/VariableArray.st Thu Nov 23 02:23:34 1995 +0100
@@ -11,10 +11,10 @@
"
ArrayedCollection subclass:#VariableArray
- instanceVariableNames:'tally contentsArray'
- classVariableNames:''
- poolDictionaries:''
- category:'Collections-Sequenceable'
+ instanceVariableNames:'tally contentsArray'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Collections-Sequenceable'
!
!VariableArray class methodsFor:'documentation'!
@@ -33,10 +33,6 @@
"
!
-version
- ^ '$Header: /cvs/stx/stx/libbasic2/VariableArray.st,v 1.12 1995-11-11 15:22:00 cg Exp $'
-!
-
documentation
"
VariableArrays can grow and shrink - in contrast to Arrays which are
@@ -47,6 +43,10 @@
Use OrderedCollection, which offers more functionality, and is even
a bit faster in some operations.
"
+!
+
+version
+ ^ '$Header: /cvs/stx/stx/libbasic2/VariableArray.st,v 1.13 1995-11-23 01:20:36 cg Exp $'
! !
!VariableArray class methodsFor:'instance creation'!
@@ -63,54 +63,44 @@
^ (self basicNew) setContents:(Array new:size)
! !
-!VariableArray methodsFor:'kludges'!
+!VariableArray methodsFor:'accessing'!
-shallowCopy:anArray
- "return a shallow copy of the receiver
- have to kludge the kludge ... - shallow copy the contents array"
-
- |newText|
+at:index
+ "return the element at index"
- newText := self class new.
- newText setContents:(contentsArray shallowCopy).
- ^ newText
-! !
-
-!VariableArray methodsFor:'private'!
-
-getContents
- "return the contents array"
-
- ^ contentsArray
+ (index between:1 and:tally) ifFalse:[
+ ^ self subscriptBoundsError:index
+ ].
+ ^ contentsArray at:index
!
-setInitialContents:anArray
- "set the contents array but make size zero"
+at:index put:anObject
+ "set the element at index"
- tally := 0.
- contentsArray := anArray
-!
-
-setContents:anArray
- "set the contents array"
-
- tally := anArray size.
- contentsArray := anArray
+ (index between:1 and:tally) ifFalse:[
+ ^ self subscriptBoundsError:index
+ ].
+ ^ contentsArray at:index put:anObject
! !
-!VariableArray methodsFor:'inquiries'!
+!VariableArray methodsFor:'enumerating'!
-size
- "return the number of array elements"
+do:aBlock
+ "evaluate the argument, aBlock for each element
+ in the collection"
- ^ tally
+ contentsArray from:1 to:tally do:aBlock
!
-isFixedSize
- "return true if the receiver cannot grow - this will vanish once
- Arrays and Strings learn how to grow ..."
+from:start to:stop do:aBlock
+ "evaluate the argument, aBlock for some elements
+ in the collection"
- ^ false
+ (stop <= tally) ifTrue:[
+ contentsArray from:start to:stop do:aBlock
+ ] ifFalse:[
+ super from:start to:stop do:aBlock
+ ]
! !
!VariableArray methodsFor:'filling & replacing'!
@@ -136,6 +126,91 @@
^ super replaceFrom:start to:stop with:aCollection startingAt:repStart
! !
+!VariableArray methodsFor:'grow & shrink'!
+
+add:anElement
+ "add anElement to the end of the array"
+
+ |newSize "{ Class: SmallInteger }" |
+
+ newSize := tally + 1.
+ (newSize <= contentsArray size) ifTrue:[
+ tally := newSize
+ ] ifFalse:[
+ self grow:newSize
+ ].
+ contentsArray at:tally put:anElement
+!
+
+grow:newSize
+ "grow to newSize"
+
+ |newArray|
+
+ (newSize == tally) ifTrue:[^ self].
+
+ (newSize > tally) ifTrue:[
+ (newSize > contentsArray size) ifTrue:[
+ newArray := Array new:(newSize * 2).
+ newArray replaceFrom:1 to:tally with:contentsArray startingAt:1.
+ contentsArray := newArray
+ ]
+ ] ifFalse:[
+ contentsArray from:(newSize + 1) to:tally put:nil
+ ].
+ tally := newSize
+! !
+
+!VariableArray methodsFor:'inquiries'!
+
+isFixedSize
+ "return true if the receiver cannot grow - this will vanish once
+ Arrays and Strings learn how to grow ..."
+
+ ^ false
+!
+
+size
+ "return the number of array elements"
+
+ ^ tally
+! !
+
+!VariableArray methodsFor:'kludges'!
+
+shallowCopy:anArray
+ "return a shallow copy of the receiver
+ have to kludge the kludge ... - shallow copy the contents array"
+
+ |newText|
+
+ newText := self class new.
+ newText setContents:(contentsArray shallowCopy).
+ ^ newText
+! !
+
+!VariableArray methodsFor:'private'!
+
+getContents
+ "return the contents array"
+
+ ^ contentsArray
+!
+
+setContents:anArray
+ "set the contents array"
+
+ tally := anArray size.
+ contentsArray := anArray
+!
+
+setInitialContents:anArray
+ "set the contents array but make size zero"
+
+ tally := 0.
+ contentsArray := anArray
+! !
+
!VariableArray methodsFor:'removing'!
removeFromIndex:startIndex toIndex:endIndex
@@ -154,10 +229,22 @@
!VariableArray methodsFor:'testing'!
-occurrencesOf:anObject
- "return the number of occurrences of anObject in the receiver"
+identityIndexOf:anElement startingAt:start
+ "search the collection for anElement starting search at index start
+ using == for compares.
+ if found, return the index otherwise return 0"
+
+ |index|
- ^ contentsArray occurrencesOf:anObject
+ (start > tally) ifFalse:[
+ index := contentsArray identityIndexOf:anElement startingAt:start.
+ index == 0 ifFalse:[
+ (index between:1 and:tally) ifTrue:[
+ ^ index
+ ]
+ ]
+ ].
+ ^ 0
!
includes:anObject
@@ -184,95 +271,9 @@
^ 0
!
-identityIndexOf:anElement startingAt:start
- "search the collection for anElement starting search at index start
- using == for compares.
- if found, return the index otherwise return 0"
-
- |index|
+occurrencesOf:anObject
+ "return the number of occurrences of anObject in the receiver"
- (start > tally) ifFalse:[
- index := contentsArray identityIndexOf:anElement startingAt:start.
- index == 0 ifFalse:[
- (index between:1 and:tally) ifTrue:[
- ^ index
- ]
- ]
- ].
- ^ 0
-! !
-
-!VariableArray methodsFor:'accessing'!
-
-at:index
- "return the element at index"
-
- (index between:1 and:tally) ifFalse:[
- ^ self subscriptBoundsError:index
- ].
- ^ contentsArray at:index
-!
-
-at:index put:anObject
- "set the element at index"
-
- (index between:1 and:tally) ifFalse:[
- ^ self subscriptBoundsError:index
- ].
- ^ contentsArray at:index put:anObject
+ ^ contentsArray occurrencesOf:anObject
! !
-!VariableArray methodsFor:'grow & shrink'!
-
-grow:newSize
- "grow to newSize"
-
- |newArray|
-
- (newSize == tally) ifTrue:[^ self].
-
- (newSize > tally) ifTrue:[
- (newSize > contentsArray size) ifTrue:[
- newArray := Array new:(newSize * 2).
- newArray replaceFrom:1 to:tally with:contentsArray startingAt:1.
- contentsArray := newArray
- ]
- ] ifFalse:[
- contentsArray from:(newSize + 1) to:tally put:nil
- ].
- tally := newSize
-!
-
-add:anElement
- "add anElement to the end of the array"
-
- |newSize "{ Class: SmallInteger }" |
-
- newSize := tally + 1.
- (newSize <= contentsArray size) ifTrue:[
- tally := newSize
- ] ifFalse:[
- self grow:newSize
- ].
- contentsArray at:tally put:anElement
-! !
-
-!VariableArray methodsFor:'enumerating'!
-
-do:aBlock
- "evaluate the argument, aBlock for each element
- in the collection"
-
- contentsArray from:1 to:tally do:aBlock
-!
-
-from:start to:stop do:aBlock
- "evaluate the argument, aBlock for some elements
- in the collection"
-
- (stop <= tally) ifTrue:[
- contentsArray from:start to:stop do:aBlock
- ] ifFalse:[
- super from:start to:stop do:aBlock
- ]
-! !
--- a/VariableString.st Thu Nov 23 02:18:58 1995 +0100
+++ b/VariableString.st Thu Nov 23 02:23:34 1995 +0100
@@ -10,11 +10,11 @@
hereby transferred.
"
-ArrayedCollection subclass:#VariableString
- instanceVariableNames:'contents'
- classVariableNames:''
- poolDictionaries:''
- category:'Collections-Text'
+nil subclass:#VariableString
+ instanceVariableNames:'contents'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Collections-Text'
!
!VariableString class methodsFor:'documentation'!
@@ -33,10 +33,6 @@
"
!
-version
- ^ '$Header: /cvs/stx/stx/libbasic2/VariableString.st,v 1.13 1995-11-11 15:22:01 cg Exp $'
-!
-
documentation
"
VariableStrings can grow and shrink - in contrast to Strings which are
@@ -45,6 +41,10 @@
WARNING: This class is a historic leftover and will vanish soon.
Dont use it.
"
+!
+
+version
+ ^ '$Header: /cvs/stx/stx/libbasic2/VariableString.st,v 1.14 1995-11-23 01:22:07 cg Exp $'
! !
!VariableString class methodsFor:'initialization'!
@@ -57,6 +57,12 @@
!VariableString class methodsFor:'instance creation'!
+copyFrom:aString
+ "return a new VariableString with contents copied from the argument"
+
+ ^ self basicNew setContents:(String copyFrom:aString)
+!
+
new
"return a new VariableString - with size 0"
@@ -67,12 +73,6 @@
"return a new VariableString"
^ (self basicNew) setContents:(String new:size)
-!
-
-copyFrom:aString
- "return a new VariableString with contents copied from the argument"
-
- ^ self basicNew setContents:(String copyFrom:aString)
! !
!VariableString methodsFor:'accessing'!
@@ -89,17 +89,27 @@
^ contents at:index put:anObject
! !
-!VariableString methodsFor:'queries'!
+!VariableString methodsFor:'converting'!
-size
- ^ contents size
-!
+asStringCollection
+ ^ contents asStringCollection
+! !
+
+!VariableString methodsFor:'copying'!
-isFixedSize
- "return true if the receiver cannot grow - this will vanish once
- Arrays and Strings learn how to grow ..."
+postCopy
+ contents := contents copy
+! !
+
+!VariableString methodsFor:'error handling'!
- ^ false
+doesNotUnderstand:aMessage
+ "this is funny: all message we do not understand, are passed
+ on to the string - so we do not have to care for all
+ possible messages ...(thanks to the Message class)"
+
+ ^ contents perform:(aMessage selector)
+ withArguments:(aMessage arguments)
! !
!VariableString methodsFor:'filling & replacing'!
@@ -126,43 +136,6 @@
^ super replaceFrom:start to:stop with:aCollection startingAt:repStart
! !
-!VariableString methodsFor:'converting'!
-
-asStringCollection
- ^ contents asStringCollection
-! !
-
-!VariableString methodsFor:'copying'!
-
-postCopy
- contents := contents copy
-! !
-
-!VariableString methodsFor:'private'!
-
-getContents
- "return the contents array"
-
- ^ contents
-!
-
-setContents:aString
- "set the contents"
-
- contents := aString
-! !
-
-!VariableString methodsFor:'error handling'!
-
-doesNotUnderstand:aMessage
- "this is funny: all message we do not understand, are passed
- on to the string - so we do not have to care for all
- possible messages ...(thanks to the Message class)"
-
- ^ contents perform:(aMessage selector)
- withArguments:(aMessage arguments)
-! !
-
!VariableString methodsFor:'grow & shrink'!
grow:newSize
@@ -184,3 +157,32 @@
]
]
! !
+
+!VariableString methodsFor:'private'!
+
+getContents
+ "return the contents array"
+
+ ^ contents
+!
+
+setContents:aString
+ "set the contents"
+
+ contents := aString
+! !
+
+!VariableString methodsFor:'queries'!
+
+isFixedSize
+ "return true if the receiver cannot grow - this will vanish once
+ Arrays and Strings learn how to grow ..."
+
+ ^ false
+!
+
+size
+ ^ contents size
+! !
+
+VariableString initialize!