--- a/Interval.st Tue Aug 15 16:30:53 2000 +0200
+++ b/Interval.st Tue Aug 15 16:31:18 2000 +0200
@@ -10,6 +10,8 @@
hereby transferred.
"
+"{ Package: 'stx:libbasic' }"
+
SequenceableCollection subclass:#Interval
instanceVariableNames:'start stop step'
classVariableNames:''
@@ -84,9 +86,9 @@
"return (i.e. compute) the index'th element"
(index between:1 and:self size) ifTrue:[
- ^ start + (step * (index - 1))
+ ^ start + (step * (index - 1))
].
- self errorSubscriptBounds:index
+ ^ self subscriptBoundsError:index
!
at:index put:anObject
@@ -100,6 +102,10 @@
first
"return the first element of the collection"
+ (((step < 0) and:[start < stop])
+ or:[(step > 0) and:[stop < start]]) ifTrue:[
+ ^ self emptyCollectionError
+ ].
^ start
!
@@ -112,6 +118,10 @@
last
"return the last element of the collection"
+ (((step < 0) and:[start < stop])
+ or:[(step > 0) and:[stop < start]]) ifTrue:[
+ ^ self emptyCollectionError
+ ].
^ stop
!
@@ -324,5 +334,5 @@
!Interval class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Interval.st,v 1.25 1999-05-08 13:25:13 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Interval.st,v 1.26 2000-08-15 14:31:18 cg Exp $'
! !