equal
deleted
inserted
replaced
8 be provided or otherwise made available to, or used by, any |
8 be provided or otherwise made available to, or used by, any |
9 other person. No title to or ownership of the software is |
9 other person. No title to or ownership of the software is |
10 hereby transferred. |
10 hereby transferred. |
11 " |
11 " |
12 |
12 |
|
13 "{ Package: 'stx:libbasic' }" |
|
14 |
13 SequenceableCollection subclass:#Interval |
15 SequenceableCollection subclass:#Interval |
14 instanceVariableNames:'start stop step' |
16 instanceVariableNames:'start stop step' |
15 classVariableNames:'' |
17 classVariableNames:'' |
16 poolDictionaries:'' |
18 poolDictionaries:'' |
17 category:'Collections-Sequenceable' |
19 category:'Collections-Sequenceable' |
82 |
84 |
83 at:index |
85 at:index |
84 "return (i.e. compute) the index'th element" |
86 "return (i.e. compute) the index'th element" |
85 |
87 |
86 (index between:1 and:self size) ifTrue:[ |
88 (index between:1 and:self size) ifTrue:[ |
87 ^ start + (step * (index - 1)) |
89 ^ start + (step * (index - 1)) |
88 ]. |
90 ]. |
89 self errorSubscriptBounds:index |
91 ^ self subscriptBoundsError:index |
90 ! |
92 ! |
91 |
93 |
92 at:index put:anObject |
94 at:index put:anObject |
93 "{ Pragma: +optSpace }" |
95 "{ Pragma: +optSpace }" |
94 |
96 |
98 ! |
100 ! |
99 |
101 |
100 first |
102 first |
101 "return the first element of the collection" |
103 "return the first element of the collection" |
102 |
104 |
|
105 (((step < 0) and:[start < stop]) |
|
106 or:[(step > 0) and:[stop < start]]) ifTrue:[ |
|
107 ^ self emptyCollectionError |
|
108 ]. |
103 ^ start |
109 ^ start |
104 ! |
110 ! |
105 |
111 |
106 increment |
112 increment |
107 "alias for #step; for ST-80 compatibility" |
113 "alias for #step; for ST-80 compatibility" |
110 ! |
116 ! |
111 |
117 |
112 last |
118 last |
113 "return the last element of the collection" |
119 "return the last element of the collection" |
114 |
120 |
|
121 (((step < 0) and:[start < stop]) |
|
122 or:[(step > 0) and:[stop < start]]) ifTrue:[ |
|
123 ^ self emptyCollectionError |
|
124 ]. |
115 ^ stop |
125 ^ stop |
116 ! |
126 ! |
117 |
127 |
118 size |
128 size |
119 "return the number of elements in the collection" |
129 "return the number of elements in the collection" |
322 ! ! |
332 ! ! |
323 |
333 |
324 !Interval class methodsFor:'documentation'! |
334 !Interval class methodsFor:'documentation'! |
325 |
335 |
326 version |
336 version |
327 ^ '$Header: /cvs/stx/stx/libbasic/Interval.st,v 1.25 1999-05-08 13:25:13 cg Exp $' |
337 ^ '$Header: /cvs/stx/stx/libbasic/Interval.st,v 1.26 2000-08-15 14:31:18 cg Exp $' |
328 ! ! |
338 ! ! |