--- a/VariableArray.st Wed Aug 24 01:15:47 1994 +0200
+++ b/VariableArray.st Mon Oct 10 01:53:55 1994 +0100
@@ -1,6 +1,6 @@
"
COPYRIGHT (c) 1989 by Claus Gittinger
- All Rights Reserved
+ All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
@@ -14,14 +14,14 @@
instanceVariableNames:'tally contentsArray'
classVariableNames:''
poolDictionaries:''
- category:'Collections-Indexed'
+ category:'Collections-Sequenceable'
!
VariableArray comment:'
COPYRIGHT (c) 1989 by Claus Gittinger
- All Rights Reserved
+ All Rights Reserved
-$Header: /cvs/stx/stx/libbasic2/VariableArray.st,v 1.7 1994-08-05 01:07:53 claus Exp $
+$Header: /cvs/stx/stx/libbasic2/VariableArray.st,v 1.8 1994-10-10 00:52:54 claus Exp $
'!
!VariableArray class methodsFor:'documentation'!
@@ -29,7 +29,7 @@
copyright
"
COPYRIGHT (c) 1989 by Claus Gittinger
- All Rights Reserved
+ All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
@@ -42,17 +42,19 @@
version
"
-$Header: /cvs/stx/stx/libbasic2/VariableArray.st,v 1.7 1994-08-05 01:07:53 claus Exp $
+$Header: /cvs/stx/stx/libbasic2/VariableArray.st,v 1.8 1994-10-10 00:52:54 claus Exp $
"
!
documentation
"
VariableArrays can grow and shrink - in contrast to Arrays which are
- fixed in size. Do not use this class - its a historic leftover from
- times when no OrderedCollection existed.
+ fixed in size.
+ WARNING: Do not use this class for new applications - its a historic
+ leftover from times when no OrderedCollection existed.
+
Use OrderedCollection, which offers more functionality, and is even
- a bit faster.
+ a bit faster in some operations.
"
! !
@@ -130,15 +132,15 @@
col := aCollection.
(aCollection isKindOf:VariableArray) ifTrue:[
- ((stop - start + repStart) <= aCollection size) ifTrue:[
- col := aCollection getContents
- ]
+ ((stop - start + repStart) <= aCollection size) ifTrue:[
+ col := aCollection getContents
+ ]
].
(col isMemberOf:Array) ifTrue:[
- (stop <= tally) ifTrue:[
- contentsArray replaceFrom:start to:stop with:col startingAt:repStart.
+ (stop <= tally) ifTrue:[
+ contentsArray replaceFrom:start to:stop with:col startingAt:repStart.
^ self
- ]
+ ]
].
^ super replaceFrom:start to:stop with:aCollection startingAt:repStart
! !
@@ -151,11 +153,11 @@
|newSize|
(endIndex >= tally) ifTrue:[
- self grow:(startIndex - 1)
+ self grow:(startIndex - 1)
] ifFalse:[
- newSize := tally - endIndex + startIndex - 1.
- contentsArray replaceFrom:startIndex to:newSize with:contentsArray startingAt:(endIndex + 1).
- self grow:newSize
+ newSize := tally - endIndex + startIndex - 1.
+ contentsArray replaceFrom:startIndex to:newSize with:contentsArray startingAt:(endIndex + 1).
+ self grow:newSize
]
! !
@@ -181,12 +183,12 @@
|index|
(start > tally) ifFalse:[
- index := contentsArray indexOf:anElement startingAt:start.
- index == 0 ifFalse:[
- (index between:1 and:tally) ifTrue:[
- ^ index
- ]
- ]
+ index := contentsArray indexOf:anElement startingAt:start.
+ index == 0 ifFalse:[
+ (index between:1 and:tally) ifTrue:[
+ ^ index
+ ]
+ ]
].
^ 0
!
@@ -199,12 +201,12 @@
|index|
(start > tally) ifFalse:[
- index := contentsArray identityIndexOf:anElement startingAt:start.
- index == 0 ifFalse:[
- (index between:1 and:tally) ifTrue:[
- ^ index
- ]
- ]
+ index := contentsArray identityIndexOf:anElement startingAt:start.
+ index == 0 ifFalse:[
+ (index between:1 and:tally) ifTrue:[
+ ^ index
+ ]
+ ]
].
^ 0
! !
@@ -215,7 +217,7 @@
"return the element at index"
(index between:1 and:tally) ifFalse:[
- ^ self subscriptBoundsError
+ ^ self subscriptBoundsError:index
].
^ contentsArray at:index
!
@@ -224,7 +226,7 @@
"set the element at index"
(index between:1 and:tally) ifFalse:[
- ^ self subscriptBoundsError
+ ^ self subscriptBoundsError:index
].
^ contentsArray at:index put:anObject
! !
@@ -237,13 +239,13 @@
|newArray|
(newSize > tally) ifTrue:[
- (newSize > contentsArray size) ifTrue:[
- newArray := Array new:(newSize * 2).
- newArray replaceFrom:1 to:tally with:contentsArray startingAt:1.
- contentsArray := newArray
- ]
+ (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
+ contentsArray from:(newSize + 1) to:tally put:nil
].
tally := newSize
!
@@ -255,9 +257,9 @@
newSize := tally + 1.
(newSize <= contentsArray size) ifTrue:[
- tally := newSize
+ tally := newSize
] ifFalse:[
- self grow:newSize
+ self grow:newSize
].
contentsArray at:tally put:anElement
! !
@@ -276,8 +278,8 @@
in the collection"
(stop <= tally) ifTrue:[
- contentsArray from:start to:stop do:aBlock
+ contentsArray from:start to:stop do:aBlock
] ifFalse:[
- super from:start to:stop do:aBlock
+ super from:start to:stop do:aBlock
]
! !