--- a/Interval.st Fri Jun 11 19:55:26 2004 +0200
+++ b/Interval.st Fri Jun 11 20:12:49 2004 +0200
@@ -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
@@ -13,10 +13,10 @@
"{ Package: 'stx:libbasic' }"
ReadOnlySequenceableCollection subclass:#Interval
- instanceVariableNames:'start stop step'
- classVariableNames:''
- poolDictionaries:''
- category:'Collections-Sequenceable'
+ instanceVariableNames:'start stop step'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Collections-Sequenceable'
!
!Interval class methodsFor:'documentation'!
@@ -24,7 +24,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
@@ -45,22 +45,22 @@
examples:
- (1 to:10) do:[:i | Transcript showCR:i]
+ (1 to:10) do:[:i | Transcript showCR:i]
notice, that this is semantically equivalent to:
- 1 to:10 do:[:i | Transcript showCR:i]
+ 1 to:10 do:[:i | Transcript showCR:i]
however, the second is preferred, since loops using to:do: are
much faster and do not create temporary garbage objects.
Therefore, Intervals are generally NOT used for this kind of loops.
- (1 to:10) asArray
+ (1 to:10) asArray
- (1 to:10 by:2) asOrderedCollection
+ (1 to:10 by:2) asOrderedCollection
[author:]
- Claus Gittinger
+ Claus Gittinger
"
! !
@@ -142,7 +142,7 @@
step
"return the step increment of the range.
OBSOLETE:
- Please use #increment for ST-80 compatibility."
+ Please use #increment for ST-80 compatibility."
^ step
!
@@ -246,15 +246,6 @@
"
! !
-!Interval methodsFor:'encoding'!
-
-encodeOn:anEncoder with:aParameter
- "this is special. Some encoders want to encode this as a sequenceable collection,
- some want to encode a less expensive representation"
-
- anEncoder encodeInterval:self with:aParameter
-! !
-
!Interval methodsFor:'enumerating'!
collect:aBlock
@@ -266,7 +257,7 @@
newCollection := self species new:(self size).
self do:[:each |
- newCollection add:(aBlock value:each)
+ newCollection add:(aBlock value:each)
].
^ newCollection
@@ -333,7 +324,7 @@
newColl := self species new:(self size).
self do:[:each |
- (aBlock value:each) ifTrue:[newColl add:each]
+ (aBlock value:each) ifTrue:[newColl add:each]
].
^ newColl
@@ -360,8 +351,8 @@
aStream nextPutAll:' to:'.
stop printOn:aStream.
step ~= 1 ifTrue:[
- aStream nextPutAll:' by:'.
- step printOn:aStream.
+ aStream nextPutAll:' by:'.
+ step printOn:aStream.
].
"
@@ -477,13 +468,13 @@
"return the number of elements in the collection"
(step < 0) ifTrue:[
- (start < stop) ifTrue:[
- ^ 0
- ].
- ^ stop - start // step + 1
+ (start < stop) ifTrue:[
+ ^ 0
+ ].
+ ^ stop - start // step + 1
].
(stop < start) ifTrue:[
- ^ 0
+ ^ 0
].
^ stop - start // step + 1
! !
@@ -544,8 +535,17 @@
"
! !
+!Interval methodsFor:'visiting'!
+
+acceptVisitor:aVisitor with:aParameter
+ "this is special. Some encoders want to encode this as a sequenceable collection,
+ some want to encode a less expensive representation"
+
+ ^ aVisitor visitInterval:self with:aParameter
+! !
+
!Interval class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Interval.st,v 1.40 2004-06-07 09:02:59 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Interval.st,v 1.41 2004-06-11 18:10:32 stefan Exp $'
! !