author | Claus Gittinger <cg@exept.de> |
Thu, 23 Nov 1995 18:07:57 +0100 | |
changeset 629 | 2ceefe9b5a19 |
parent 606 | 7a9ab63a6757 |
child 679 | d3165edbb098 |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
159 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
SequenceableCollection subclass:#OrderedCollection |
|
159 | 14 |
instanceVariableNames:'contentsArray firstIndex lastIndex' |
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Collections-Sequenceable' |
|
1 | 18 |
! |
19 |
||
33 | 20 |
!OrderedCollection class methodsFor:'documentation'! |
21 |
||
88 | 22 |
copyright |
23 |
" |
|
24 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
159 | 25 |
All Rights Reserved |
88 | 26 |
|
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
33 | 36 |
documentation |
37 |
" |
|
68 | 38 |
OrderedCollection have ordered elements. Insertion and removal at both ends |
39 |
is possible - therefore they can be used for queues and stacks. |
|
1 | 40 |
|
68 | 41 |
Instance variables: |
1 | 42 |
|
68 | 43 |
contentsArray <Array> the actual contents |
44 |
firstIndex <SmallInteger> index of first valid element |
|
45 |
lastIndex <SmallInteger> index of last valid element |
|
33 | 46 |
" |
47 |
! ! |
|
1 | 48 |
|
49 |
!OrderedCollection class methodsFor:'instance creation'! |
|
50 |
||
51 |
new |
|
52 |
"create a new OrderedCollection" |
|
53 |
||
54 |
^ (self basicNew) initContents:10 |
|
293 | 55 |
! |
56 |
||
606 | 57 |
new:size |
58 |
"create a new OrderedCollection" |
|
59 |
||
60 |
^ (self basicNew) initContents:(size max:3) |
|
293 | 61 |
! ! |
62 |
||
606 | 63 |
!OrderedCollection methodsFor:'accessing'! |
1 | 64 |
|
606 | 65 |
at:anInteger |
66 |
"return the element at index, anInteger" |
|
1 | 67 |
|
606 | 68 |
|idx| |
387 | 69 |
|
606 | 70 |
idx := anInteger + firstIndex - 1. |
71 |
((anInteger < 1) or:[idx > lastIndex]) ifTrue:[ |
|
72 |
^ self subscriptBoundsError:anInteger |
|
73 |
] ifFalse:[ |
|
74 |
^ contentsArray at:idx |
|
75 |
] |
|
360 | 76 |
! |
77 |
||
606 | 78 |
at:anInteger put:anObject |
79 |
"set the element at index, to be anInteger" |
|
1 | 80 |
|
606 | 81 |
|idx| |
1 | 82 |
|
606 | 83 |
idx := anInteger + firstIndex - 1. |
84 |
((anInteger < 1) or:[idx > lastIndex]) ifTrue:[ |
|
85 |
^ self subscriptBoundsError:anInteger |
|
86 |
] ifFalse:[ |
|
87 |
^ contentsArray at:idx put:anObject |
|
88 |
] |
|
202 | 89 |
! |
90 |
||
606 | 91 |
first |
92 |
"return the first element" |
|
1 | 93 |
|
606 | 94 |
firstIndex <= lastIndex ifTrue:[ |
95 |
^ contentsArray at:firstIndex |
|
1 | 96 |
]. |
606 | 97 |
"error if collection is empty" |
98 |
^ self emptyCollectionError |
|
2 | 99 |
|
93 | 100 |
" |
606 | 101 |
(OrderedCollection withAll:#(1 2 3 4 5)) first |
102 |
(SortedCollection withAll:#(5 4 3 2 1)) first |
|
93 | 103 |
" |
13 | 104 |
! |
105 |
||
606 | 106 |
last |
107 |
"return the last element" |
|
68 | 108 |
|
606 | 109 |
firstIndex <= lastIndex ifTrue:[ |
110 |
^ contentsArray at:lastIndex |
|
111 |
]. |
|
112 |
"error if collection is empty" |
|
113 |
^ self emptyCollectionError |
|
68 | 114 |
|
93 | 115 |
" |
606 | 116 |
(OrderedCollection withAll:#(1 2 3 4 5)) last |
117 |
(SortedCollection withAll:#(5 4 3 2 1)) last |
|
93 | 118 |
" |
1 | 119 |
! ! |
120 |
||
121 |
!OrderedCollection methodsFor:'adding & removing'! |
|
122 |
||
606 | 123 |
add:anObject |
124 |
"add the argument, anObject to the end of the collection |
|
125 |
Return the argument, anObject." |
|
126 |
||
127 |
|idx "{ Class:SmallInteger }"| |
|
1 | 128 |
|
606 | 129 |
idx := lastIndex. |
1 | 130 |
|
606 | 131 |
(idx == contentsArray size) ifTrue:[ |
132 |
self makeRoomAtLast. |
|
133 |
idx := lastIndex. |
|
42 | 134 |
]. |
606 | 135 |
idx := lastIndex := idx + 1. |
136 |
contentsArray at:idx put:anObject. |
|
137 |
"/ lastIndex := idx. |
|
1 | 138 |
^ anObject |
42 | 139 |
|
348 | 140 |
" |
606 | 141 |
|c| |
142 |
c := #(4 3 2 1) asOrderedCollection. |
|
143 |
c add:'here' |
|
348 | 144 |
" |
1 | 145 |
! |
146 |
||
606 | 147 |
add:newObject after:oldObject |
148 |
"insert the argument, newObject after oldObject. |
|
149 |
If oldObject is not in the receiver, report an error, |
|
150 |
otherwise return the argument, anObject." |
|
1 | 151 |
|
606 | 152 |
|idx| |
1 | 153 |
|
606 | 154 |
idx := self indexOf:oldObject. |
155 |
idx ~~ 0 ifTrue:[ |
|
156 |
^ self add:newObject beforeIndex:(idx + 1). |
|
42 | 157 |
]. |
606 | 158 |
self errorValueNotFound:oldObject |
42 | 159 |
|
348 | 160 |
" |
606 | 161 |
|c| |
162 |
c := #(4 3 2 1) asOrderedCollection. |
|
163 |
c add:'here' after:3. |
|
164 |
" |
|
165 |
" |
|
166 |
|c| |
|
167 |
c := #(4 3 2 1) asOrderedCollection. |
|
168 |
c add:'here' after:1. |
|
169 |
" |
|
170 |
" |
|
171 |
|c| |
|
172 |
c := #(4 3 2 1) asOrderedCollection. |
|
173 |
c add:'here' after:5 |
|
174 |
" |
|
175 |
! |
|
176 |
||
177 |
add:anObject afterIndex:index |
|
178 |
"insert the argument, anObject to become located at index. |
|
179 |
Return the argument, anObject." |
|
180 |
||
181 |
^ self add:anObject beforeIndex:(index + 1) |
|
182 |
||
183 |
" |
|
184 |
|c| |
|
185 |
c := #(4 3 2 1) asOrderedCollection. |
|
186 |
c add:'here' afterIndex:4 |
|
348 | 187 |
" |
188 |
! |
|
189 |
||
606 | 190 |
add:newObject before:oldObject |
191 |
"insert the argument, newObject before oldObject. |
|
192 |
If oldObject is not in the receiver, report an error, |
|
193 |
otherwise return the argument, anObject." |
|
348 | 194 |
|
606 | 195 |
|idx| |
348 | 196 |
|
606 | 197 |
idx := self indexOf:oldObject. |
198 |
idx ~~ 0 ifTrue:[ |
|
199 |
^ self add:newObject beforeIndex:idx. |
|
348 | 200 |
]. |
606 | 201 |
self errorValueNotFound:oldObject |
348 | 202 |
|
203 |
" |
|
606 | 204 |
|c| |
205 |
c := #(4 3 2 1) asOrderedCollection. |
|
206 |
c add:'here' before:3. |
|
207 |
c add:'here' before:5 |
|
348 | 208 |
" |
209 |
! |
|
210 |
||
606 | 211 |
add:anObject beforeIndex:index |
212 |
"insert the argument, anObject to become located at index. |
|
213 |
Return the argument, anObject." |
|
348 | 214 |
|
606 | 215 |
self makeRoomAtIndex:(index - firstIndex + 1). |
216 |
contentsArray at:(index - firstIndex + 1) put:anObject. |
|
348 | 217 |
|
218 |
" |
|
606 | 219 |
|c| |
220 |
c := #(4 3 2 1) asOrderedCollection. |
|
221 |
c add:'here' beforeIndex:3 |
|
222 |
" |
|
223 |
" |
|
224 |
|c| |
|
225 |
c := #(4 3 2 1) asOrderedCollection. |
|
226 |
c add:'here' beforeIndex:1 |
|
227 |
" |
|
228 |
" |
|
229 |
|c| |
|
230 |
c := #(4 3 2 1) asOrderedCollection. |
|
231 |
c add:'here' beforeIndex:5 |
|
348 | 232 |
" |
1 | 233 |
! |
234 |
||
606 | 235 |
addFirst:anObject |
236 |
"add the argument, anObject to the beginning of the collection. |
|
237 |
Return the argument, anObject." |
|
56 | 238 |
|
606 | 239 |
(firstIndex == 1) ifTrue:[ |
240 |
self makeRoomAtFront |
|
348 | 241 |
]. |
606 | 242 |
firstIndex := firstIndex - 1. |
243 |
contentsArray at:firstIndex put:anObject. |
|
244 |
^ anObject |
|
56 | 245 |
|
246 |
" |
|
606 | 247 |
|c| |
248 |
c := #(1 2 3 4) asOrderedCollection. |
|
249 |
c addFirst:'here'. |
|
250 |
c |
|
251 |
" |
|
252 |
||
253 |
" |
|
254 |
|c| |
|
255 |
c := #() asOrderedCollection. |
|
256 |
c addFirst:'here'. |
|
257 |
c |
|
56 | 258 |
" |
259 |
! |
|
260 |
||
1 | 261 |
remove:anObject ifAbsent:exceptionBlock |
407 | 262 |
"remove the first occurrence of anObject from the collection |
263 |
and return it. |
|
264 |
If its not in the receiver collection, return the value of exceptionBlock." |
|
1 | 265 |
|
266 |
|index "{ Class:SmallInteger }"| |
|
267 |
||
268 |
index := firstIndex. |
|
269 |
[index <= lastIndex] whileTrue:[ |
|
159 | 270 |
anObject = (contentsArray at:index) ifTrue:[ |
329 | 271 |
contentsArray |
272 |
replaceFrom:index |
|
273 |
to:(contentsArray size - 1) |
|
274 |
with:contentsArray |
|
275 |
startingAt:(index + 1). |
|
159 | 276 |
contentsArray at:lastIndex put:nil. |
277 |
lastIndex := lastIndex - 1. |
|
278 |
firstIndex > lastIndex ifTrue:[ |
|
279 |
"reset to avoid ever growing" |
|
280 |
firstIndex := 1. |
|
281 |
lastIndex := 0 |
|
282 |
]. |
|
283 |
^ anObject |
|
284 |
]. |
|
285 |
index := index + 1 |
|
1 | 286 |
]. |
287 |
^ exceptionBlock value |
|
348 | 288 |
|
289 |
" |
|
290 |
#(1 2 3 4 5 6 7 8 9) asOrderedCollection remove:3 ifAbsent:'oops' |
|
291 |
#(1 2 3 4 5) asOrderedCollection remove:9 ifAbsent:'oops' |
|
292 |
" |
|
1 | 293 |
! |
294 |
||
114 | 295 |
removeAll |
296 |
"remove all elements from the collection." |
|
297 |
||
298 |
self initContents:10 |
|
299 |
! |
|
300 |
||
348 | 301 |
removeAllSuchThat:aBlock |
302 |
"remove all elements that meet a test criteria as specified in aBlock. |
|
303 |
The argument, aBlock is evaluated for successive elements and all those, |
|
304 |
for which it returns true, are removed." |
|
305 |
||
306 |
"/ this is a q&d implementation (slow). |
|
307 |
"/ it should be rewritten to |
|
308 |
||
309 |
|runIndex removed element| |
|
310 |
||
311 |
removed := self species new. |
|
312 |
||
313 |
runIndex := 1. |
|
314 |
[runIndex <= self size] whileTrue:[ |
|
315 |
element := self at:runIndex. |
|
316 |
(aBlock value:element) ifTrue:[ |
|
317 |
removed add:element. |
|
318 |
self removeAtIndex:runIndex |
|
319 |
] ifFalse:[ |
|
320 |
runIndex := runIndex + 1 |
|
321 |
] |
|
322 |
]. |
|
323 |
^ removed |
|
324 |
||
325 |
" |
|
326 |
|coll| |
|
327 |
||
328 |
coll := OrderedCollection withAll:(1 to:10). |
|
329 |
Transcript showCr:(coll removeAllSuchThat:[:el | el even]). |
|
330 |
Transcript showCr:coll |
|
331 |
" |
|
332 |
! |
|
333 |
||
606 | 334 |
removeFirst |
335 |
"remove the first element from the collection; return the element" |
|
202 | 336 |
|
606 | 337 |
|anObject | |
13 | 338 |
|
606 | 339 |
firstIndex > lastIndex ifTrue:[ |
340 |
"error if collection is empty" |
|
341 |
^ self emptyCollectionError. |
|
342 |
]. |
|
343 |
anObject := contentsArray at:firstIndex. |
|
344 |
contentsArray at:firstIndex put:nil. |
|
345 |
firstIndex := firstIndex + 1. |
|
1 | 346 |
|
606 | 347 |
firstIndex > lastIndex ifTrue:[ |
348 |
"reset to avoid ever growing" |
|
349 |
firstIndex := 1. |
|
350 |
lastIndex := 0 |
|
1 | 351 |
]. |
352 |
^ anObject |
|
13 | 353 |
|
354 |
" |
|
606 | 355 |
(OrderedCollection withAll:#(1 2 3 4 5)) removeFirst; yourself |
356 |
OrderedCollection new removeFirst |
|
357 |
(SortedCollection withAll:#(5 4 3 2 1)) removeFirst; yourself |
|
93 | 358 |
" |
606 | 359 |
! |
360 |
||
361 |
removeFirst:n |
|
362 |
"remove the first n elements from the collection; |
|
363 |
return the elements in an Array" |
|
364 |
||
365 |
|mySize ret| |
|
366 |
||
367 |
mySize := self size. |
|
368 |
mySize < n ifTrue:[ |
|
369 |
"error if collection has not enough elements" |
|
370 |
^ self notEnoughElementsError. |
|
371 |
]. |
|
372 |
||
373 |
ret := Array new:n. |
|
374 |
ret replaceFrom:1 to:n with:contentsArray startingAt:firstIndex. |
|
375 |
"/ |
|
376 |
"/ nil-out contents array, to not keep elements from being GC'd |
|
377 |
"/ |
|
378 |
contentsArray from:firstIndex to:firstIndex + n - 1 put:nil. |
|
379 |
firstIndex := firstIndex + n. |
|
380 |
||
381 |
firstIndex > lastIndex ifTrue:[ |
|
382 |
"reset to avoid ever growing" |
|
383 |
firstIndex := 1. |
|
384 |
lastIndex := 0 |
|
385 |
]. |
|
386 |
^ ret |
|
93 | 387 |
|
388 |
" |
|
606 | 389 |
(OrderedCollection withAll:#(1 2 3 4 5)) removeFirst:2; yourself |
390 |
(OrderedCollection withAll:#(1 2 3 4 5)) removeFirst:0; yourself |
|
391 |
OrderedCollection new removeFirst:2 |
|
392 |
(OrderedCollection withAll:#(1 2 3 4 5)) removeFirst:6 |
|
393 |
(SortedCollection withAll:#(5 4 3 2 1)) removeFirst:2; yourself |
|
13 | 394 |
" |
1 | 395 |
! |
396 |
||
606 | 397 |
removeFromIndex:startIndex toIndex:stopIndex |
398 |
"remove the elements stored under startIndex up to and including |
|
399 |
the elements under stopIndex. |
|
400 |
Return the receiver. |
|
401 |
Returning the receiver here is a historic leftover - it may change. |
|
402 |
Please use yourself in a cascade, if you need the receivers value |
|
403 |
when using this method." |
|
404 |
||
405 |
|nDeleted| |
|
1 | 406 |
|
606 | 407 |
(startIndex < 1 |
408 |
or:[stopIndex > self size]) ifTrue:[ |
|
409 |
^ self notEnoughElementsError |
|
410 |
]. |
|
411 |
nDeleted := stopIndex - startIndex + 1. |
|
412 |
contentsArray |
|
413 |
replaceFrom:(firstIndex + startIndex - 1) |
|
414 |
to:(lastIndex - nDeleted) |
|
415 |
with:contentsArray |
|
416 |
startingAt:(firstIndex + stopIndex). |
|
417 |
||
418 |
contentsArray |
|
419 |
from:(lastIndex - nDeleted + 1) |
|
420 |
to:lastIndex |
|
421 |
put:nil. |
|
422 |
||
423 |
lastIndex := lastIndex - nDeleted. |
|
424 |
firstIndex > lastIndex ifTrue:[ |
|
425 |
"reset to avoid ever growing" |
|
426 |
firstIndex := 1. |
|
427 |
lastIndex := 0 |
|
428 |
] |
|
13 | 429 |
|
430 |
" |
|
606 | 431 |
#(1 2 3 4 5 6 7 8 9) asOrderedCollection removeFromIndex:3 toIndex:6 |
432 |
#(1 2 3 4 5) asOrderedCollection removeFromIndex:3 toIndex:6 |
|
217 | 433 |
" |
434 |
! |
|
435 |
||
606 | 436 |
removeLast |
437 |
"remove the last element from the collection; return the element" |
|
438 |
||
439 |
|anObject | |
|
217 | 440 |
|
606 | 441 |
firstIndex > lastIndex ifTrue:[ |
442 |
"error if collection is empty" |
|
443 |
^ self emptyCollectionError. |
|
444 |
]. |
|
445 |
anObject := contentsArray at:lastIndex. |
|
446 |
contentsArray at:lastIndex put:nil. |
|
447 |
lastIndex := lastIndex - 1. |
|
448 |
||
449 |
firstIndex > lastIndex ifTrue:[ |
|
450 |
"reset to avoid ever growing" |
|
451 |
firstIndex := 1. |
|
452 |
lastIndex := 0 |
|
453 |
]. |
|
454 |
^ anObject |
|
217 | 455 |
|
456 |
" |
|
606 | 457 |
(OrderedCollection withAll:#(1 2 3 4 5)) removeLast; yourself |
458 |
OrderedCollection new removeLast |
|
459 |
(SortedCollection withAll:#(5 4 3 2 1)) removeLast; yourself |
|
217 | 460 |
" |
13 | 461 |
! |
462 |
||
606 | 463 |
removeLast:n |
464 |
"remove the last n elements from the collection; |
|
465 |
return the elements in an Array" |
|
466 |
||
467 |
|mySize ret| |
|
468 |
||
469 |
mySize := self size. |
|
470 |
mySize < n ifTrue:[ |
|
471 |
"error if collection has not enough elements" |
|
472 |
^ self notEnoughElementsError. |
|
473 |
]. |
|
13 | 474 |
|
606 | 475 |
ret := Array new:n. |
476 |
ret replaceFrom:1 to:n with:contentsArray startingAt:lastIndex - n + 1. |
|
477 |
"/ |
|
478 |
"/ nil-out contents array, to not keep elements from being GC'd |
|
479 |
"/ |
|
480 |
contentsArray from:lastIndex - n + 1 to:lastIndex put:nil. |
|
481 |
lastIndex := lastIndex - n. |
|
13 | 482 |
|
606 | 483 |
firstIndex > lastIndex ifTrue:[ |
484 |
"reset to avoid ever growing" |
|
485 |
firstIndex := 1. |
|
486 |
lastIndex := 0 |
|
13 | 487 |
]. |
606 | 488 |
^ ret |
13 | 489 |
|
490 |
" |
|
606 | 491 |
(OrderedCollection withAll:#(1 2 3 4 5)) removeLast:2; yourself |
492 |
(OrderedCollection withAll:#(1 2 3 4 5)) removeLast:0; yourself |
|
493 |
(OrderedCollection withAll:#(1 2 3 4 5)) removeLast:6; yourself |
|
494 |
(SortedCollection withAll:#(5 4 3 2 1)) removeLast:2; yourself |
|
13 | 495 |
" |
1 | 496 |
! ! |
497 |
||
606 | 498 |
!OrderedCollection methodsFor:'converting'! |
1 | 499 |
|
606 | 500 |
asOrderedCollection |
501 |
"return the receiver as an ordered collection" |
|
1 | 502 |
|
606 | 503 |
"could be an instance of a subclass..." |
504 |
self class == OrderedCollection ifTrue:[ |
|
505 |
^ self |
|
506 |
]. |
|
507 |
^ super asOrderedCollection |
|
1 | 508 |
! ! |
509 |
||
606 | 510 |
!OrderedCollection methodsFor:'copying'! |
13 | 511 |
|
606 | 512 |
, aCollection |
513 |
"return a new collection formed from concatenating the receiver with |
|
514 |
the argument" |
|
1 | 515 |
|
606 | 516 |
|newCollection| |
1 | 517 |
|
606 | 518 |
newCollection := self copyEmpty:(self size + aCollection size). |
519 |
self do:[:element | |
|
520 |
newCollection add:element |
|
42 | 521 |
]. |
606 | 522 |
aCollection do:[:element | |
523 |
newCollection add:element |
|
524 |
]. |
|
525 |
^ newCollection |
|
42 | 526 |
|
253 | 527 |
" |
606 | 528 |
#(1 2 3) asOrderedCollection , #(4 5 6) asOrderedCollection |
529 |
#(1 2 3) asSortedCollection , #(99 101 100) asSortedCollection |
|
253 | 530 |
" |
42 | 531 |
! |
532 |
||
606 | 533 |
copy |
534 |
"return a new OrderedCollection containing the elements of the receiver." |
|
535 |
||
536 |
"redefinition is a consequence of the implementation with a |
|
537 |
separate array - otherwise we get a shallow copy of the |
|
538 |
contents array, which is not what we want here" |
|
539 |
||
540 |
^ self copyFrom:1 to:self size |
|
541 |
! |
|
542 |
||
543 |
copyEmpty |
|
544 |
"return a copy of the receiver without any elements." |
|
545 |
||
546 |
^ self copyEmpty:10 |
|
547 |
! |
|
548 |
||
549 |
copyFrom:start to:stop |
|
550 |
"return a new OrderedCollection containing the elements |
|
551 |
from start to stop." |
|
42 | 552 |
|
606 | 553 |
|newCollection sz| |
554 |
||
555 |
sz := stop - start + 1. |
|
556 |
newCollection := self copyEmptyAndGrow:sz. "must grow, otherwise replace fails" |
|
557 |
newCollection replaceFrom:1 to:sz with:self startingAt:start. |
|
558 |
^ newCollection |
|
559 |
! |
|
560 |
||
561 |
copyWith:newElement |
|
562 |
"return a new collection containing the receivers elements |
|
563 |
and the single new element, newElement. |
|
564 |
This is different from concatentation, which expects another collection |
|
565 |
as argument, but equivalent to copy-and-addLast." |
|
566 |
||
567 |
|newCollection mySize newSize| |
|
568 |
||
569 |
mySize := self size. |
|
570 |
newSize := mySize + 1. |
|
571 |
newCollection := self copyEmptyAndGrow:newSize. "must grow, otherwise replace fails" |
|
572 |
newCollection replaceFrom:1 to:mySize with:self startingAt:1. |
|
573 |
newCollection at:newSize put:newElement. |
|
574 |
^newCollection |
|
42 | 575 |
|
253 | 576 |
" |
606 | 577 |
#(1 2 3 4 5) copyWith:$a |
578 |
'abcdefg' copyWith:$h |
|
579 |
'abcdefg' copyWith:'123' -- will fail: string cannot be stored into string |
|
580 |
'abcdefg' copyWith:1 -- will fail: integer cannot be stored into string |
|
581 |
" |
|
582 |
! |
|
583 |
||
584 |
postCopy |
|
585 |
"have to copy the contentsArray too" |
|
586 |
||
587 |
contentsArray := contentsArray shallowCopy |
|
588 |
! ! |
|
589 |
||
590 |
!OrderedCollection methodsFor:'enumerating'! |
|
591 |
||
592 |
collect:aBlock |
|
593 |
"evaluate the argument, aBlock for every element in the collection |
|
594 |
and return a collection of the results" |
|
595 |
||
596 |
|newCollection |
|
597 |
start "{ Class:SmallInteger }" |
|
598 |
stop "{ Class:SmallInteger }" | |
|
599 |
||
600 |
newCollection := self copyEmpty:(self size). |
|
601 |
stop := lastIndex. |
|
602 |
start := firstIndex. |
|
603 |
start to:stop do:[:index | |
|
604 |
newCollection add:(aBlock value:(contentsArray at:index)). |
|
605 |
]. |
|
606 |
^ newCollection |
|
607 |
||
253 | 608 |
" |
606 | 609 |
#(1 2 3 4) asOrderedCollection collect:[:i | i * i] |
610 |
#(1 2 3 4) asOrderedCollection collect:[:i | i even] |
|
611 |
" |
|
612 |
! |
|
613 |
||
614 |
do:aBlock |
|
615 |
"evaluate the argument, aBlock for every element in the collection." |
|
616 |
||
617 |
contentsArray from:firstIndex to:lastIndex do:aBlock |
|
618 |
! |
|
619 |
||
620 |
keysAndValuesDo:aTwoArgBlock |
|
621 |
"evaluate the argument, aBlock for every element in the collection, |
|
622 |
passing both index and element as arguments." |
|
623 |
||
624 |
|start "{ Class:SmallInteger }" |
|
625 |
stop "{ Class:SmallInteger }" | |
|
626 |
||
627 |
stop := lastIndex. |
|
628 |
start := firstIndex. |
|
629 |
start to:stop do:[:index | |
|
630 |
aTwoArgBlock value:index value:(contentsArray at:index) |
|
631 |
] |
|
632 |
||
633 |
" |
|
634 |
#(10 20 30 40) asOrderedCollection keysAndValuesDo:[:index :value | |
|
635 |
Transcript show:index; show:' '; showCr:value |
|
636 |
] |
|
637 |
" |
|
638 |
! |
|
639 |
||
640 |
reverseDo:aBlock |
|
641 |
"evaluate the argument, aBlock for every element in the collection |
|
642 |
procesing elements in reverse direction (i.e. starting with the last)" |
|
643 |
||
644 |
contentsArray from:firstIndex to:lastIndex reverseDo:aBlock |
|
1 | 645 |
! ! |
646 |
||
56 | 647 |
!OrderedCollection methodsFor:'filling & replacing'! |
13 | 648 |
|
649 |
replaceFrom:start to:stop with:aCollection startingAt:repStart |
|
650 |
"redefined - can be done faster" |
|
651 |
||
652 |
|end| |
|
653 |
||
654 |
end := stop + firstIndex - 1. |
|
655 |
((start >= 1) and:[end <= lastIndex]) ifTrue:[ |
|
293 | 656 |
aCollection class == self class ifTrue:[ |
657 |
contentsArray |
|
658 |
replaceFrom:(start + firstIndex - 1) |
|
659 |
to:end |
|
660 |
with:aCollection contentsArray |
|
661 |
startingAt:(repStart + aCollection firstIndex - 1). |
|
662 |
] ifFalse:[ |
|
663 |
contentsArray |
|
664 |
replaceFrom:(start + firstIndex - 1) |
|
665 |
to:end |
|
666 |
with:aCollection |
|
667 |
startingAt:repStart. |
|
668 |
]. |
|
159 | 669 |
^ self |
13 | 670 |
]. |
671 |
^ super replaceFrom:start to:stop with:aCollection startingAt:repStart |
|
293 | 672 |
|
673 |
" |
|
674 |
|c| |
|
675 |
||
676 |
c := #(1 2 3 4 5 6) asOrderedCollection. |
|
677 |
c replaceFrom:3 to:6 with:c startingAt:2. |
|
678 |
c |
|
679 |
" |
|
680 |
" |
|
681 |
|c| |
|
682 |
||
683 |
c := #(1 2 3 4 5 6) asOrderedCollection. |
|
684 |
c replaceFrom:3 to:5 with:c startingAt:4. |
|
685 |
c |
|
686 |
" |
|
13 | 687 |
! ! |
688 |
||
606 | 689 |
!OrderedCollection methodsFor:'grow & shrink'! |
77 | 690 |
|
606 | 691 |
grow:newSize |
692 |
"grow the receiver to newSize" |
|
77 | 693 |
|
606 | 694 |
|oldSize newContents oldLast newLast| |
77 | 695 |
|
606 | 696 |
oldSize := lastIndex - firstIndex + 1. |
697 |
newSize ~~ oldSize ifTrue:[ |
|
698 |
newLast := firstIndex + newSize - 1. |
|
699 |
newSize < oldSize ifTrue:[ |
|
700 |
oldLast := lastIndex. |
|
701 |
lastIndex := newLast. |
|
702 |
" |
|
703 |
nil out rest, to give GC a chance to reclaim things |
|
704 |
" |
|
705 |
contentsArray from:lastIndex + 1 to:oldLast put:nil. |
|
706 |
] ifFalse:[ |
|
707 |
newLast <= contentsArray size ifTrue:[ |
|
708 |
lastIndex := newLast. |
|
709 |
^ self |
|
710 |
]. |
|
77 | 711 |
|
606 | 712 |
newContents := Array basicNew:newSize. |
713 |
newContents replaceFrom:1 to:oldSize with:contentsArray startingAt:firstIndex. |
|
714 |
contentsArray := newContents. |
|
715 |
firstIndex := 1. |
|
716 |
lastIndex := newSize |
|
717 |
] |
|
718 |
] |
|
719 |
! ! |
|
77 | 720 |
|
606 | 721 |
!OrderedCollection methodsFor:'inspecting'! |
722 |
||
723 |
inspectorClass |
|
724 |
"redefined to launch an OrderedCollectionInspector |
|
725 |
(instead of the default InspectorView)." |
|
726 |
||
727 |
^ OrderedCollectionInspectorView |
|
77 | 728 |
|
729 |
" |
|
606 | 730 |
(OrderedCollection withAll:#(3 2 1)) inspect |
731 |
(OrderedCollection withAll:#(3 2 1)) removeFirst; yourself; inspect |
|
732 |
#(0 8 15 3 99 2) asSortedCollection inspect |
|
77 | 733 |
" |
734 |
! ! |
|
735 |
||
1 | 736 |
!OrderedCollection methodsFor:'private'! |
737 |
||
606 | 738 |
initContents:size |
739 |
"setup the receiver-collection to hold size entries" |
|
33 | 740 |
|
606 | 741 |
contentsArray := Array basicNew:size. |
742 |
firstIndex := 1. |
|
743 |
lastIndex := 0 |
|
1 | 744 |
! |
745 |
||
746 |
makeRoomAtFront |
|
282 | 747 |
"grow/shift the contents for more room at the beginning. |
748 |
Does not change the logical size. |
|
749 |
i.e. |
|
750 |
#(1 2 3 4 5 6) -> #(nil 1 2 3 4 5 6)" |
|
1 | 751 |
|
752 |
|newContents |
|
33 | 753 |
oldSize "{ Class:SmallInteger }" |
754 |
newSize "{ Class:SmallInteger }" |
|
755 |
startIndex "{ Class:SmallInteger }" |
|
756 |
sz "{ Class:SmallInteger }"| |
|
1 | 757 |
|
758 |
oldSize := contentsArray size. |
|
506
984b32fe635a
fixed makeRoomAtFront if underlying arrays size is <= 3
Claus Gittinger <cg@exept.de>
parents:
407
diff
changeset
|
759 |
sz := lastIndex - firstIndex + 1. |
984b32fe635a
fixed makeRoomAtFront if underlying arrays size is <= 3
Claus Gittinger <cg@exept.de>
parents:
407
diff
changeset
|
760 |
|
984b32fe635a
fixed makeRoomAtFront if underlying arrays size is <= 3
Claus Gittinger <cg@exept.de>
parents:
407
diff
changeset
|
761 |
((oldSize == 0) or:[sz == 0]) ifTrue:[ |
253 | 762 |
contentsArray := Array basicNew:3. |
159 | 763 |
firstIndex := 2. lastIndex := 1. |
764 |
^ self |
|
93 | 765 |
]. |
766 |
||
329 | 767 |
" |
768 |
if there is lots of room at the end (> 50%), |
|
769 |
shift instead of growing. This helps collections |
|
770 |
which get elements removed at the end and added at front. |
|
771 |
" |
|
33 | 772 |
oldSize > (sz * 2) ifTrue:[ |
508 | 773 |
startIndex := oldSize // 4. |
774 |
startIndex > 1 ifTrue:[ |
|
506
984b32fe635a
fixed makeRoomAtFront if underlying arrays size is <= 3
Claus Gittinger <cg@exept.de>
parents:
407
diff
changeset
|
775 |
contentsArray |
984b32fe635a
fixed makeRoomAtFront if underlying arrays size is <= 3
Claus Gittinger <cg@exept.de>
parents:
407
diff
changeset
|
776 |
replaceFrom:startIndex |
984b32fe635a
fixed makeRoomAtFront if underlying arrays size is <= 3
Claus Gittinger <cg@exept.de>
parents:
407
diff
changeset
|
777 |
to:startIndex + sz - 1 |
984b32fe635a
fixed makeRoomAtFront if underlying arrays size is <= 3
Claus Gittinger <cg@exept.de>
parents:
407
diff
changeset
|
778 |
with:contentsArray |
984b32fe635a
fixed makeRoomAtFront if underlying arrays size is <= 3
Claus Gittinger <cg@exept.de>
parents:
407
diff
changeset
|
779 |
startingAt:1. |
984b32fe635a
fixed makeRoomAtFront if underlying arrays size is <= 3
Claus Gittinger <cg@exept.de>
parents:
407
diff
changeset
|
780 |
contentsArray from:1 to:(startIndex - 1) put:nil. |
984b32fe635a
fixed makeRoomAtFront if underlying arrays size is <= 3
Claus Gittinger <cg@exept.de>
parents:
407
diff
changeset
|
781 |
firstIndex := startIndex. |
984b32fe635a
fixed makeRoomAtFront if underlying arrays size is <= 3
Claus Gittinger <cg@exept.de>
parents:
407
diff
changeset
|
782 |
lastIndex := startIndex + sz - 1. |
984b32fe635a
fixed makeRoomAtFront if underlying arrays size is <= 3
Claus Gittinger <cg@exept.de>
parents:
407
diff
changeset
|
783 |
^ self |
984b32fe635a
fixed makeRoomAtFront if underlying arrays size is <= 3
Claus Gittinger <cg@exept.de>
parents:
407
diff
changeset
|
784 |
] |
33 | 785 |
]. |
2 | 786 |
newSize := oldSize * 2. |
329 | 787 |
newSize == 0 ifTrue:[ newSize := 3]. |
253 | 788 |
newContents := Array basicNew:newSize. |
77 | 789 |
newContents |
159 | 790 |
replaceFrom:(oldSize + 1) |
791 |
to:newSize |
|
792 |
with:contentsArray |
|
793 |
startingAt:1. |
|
1 | 794 |
contentsArray := newContents. |
795 |
firstIndex := firstIndex + oldSize. |
|
796 |
lastIndex := lastIndex + oldSize |
|
506
984b32fe635a
fixed makeRoomAtFront if underlying arrays size is <= 3
Claus Gittinger <cg@exept.de>
parents:
407
diff
changeset
|
797 |
|
984b32fe635a
fixed makeRoomAtFront if underlying arrays size is <= 3
Claus Gittinger <cg@exept.de>
parents:
407
diff
changeset
|
798 |
"Created: 8.11.1995 / 12:47:49 / cg" |
1 | 799 |
! |
800 |
||
801 |
makeRoomAtIndex:index |
|
802 |
"grow the contents for inserting at index |
|
282 | 803 |
Changes the logical size. |
1 | 804 |
i.e. |
805 |
#(1 2 3 4 5 6) asOrderedCollection makeRoomAtIndex:3 -> #(1 2 nil 3 4 5 6) |
|
806 |
#(1 2 3 4 5 6) asOrderedCollection makeRoomAtIndex:1 -> #(nil 1 2 3 4 5 6) |
|
807 |
#(1 2 3 4 5 6) asOrderedCollection makeRoomAtIndex:7 -> #(1 2 3 4 5 6 nil)" |
|
808 |
||
809 |
|newContents |
|
810 |
newSize "{ Class:SmallInteger }" |
|
811 |
oldSize "{ Class:SmallInteger }" | |
|
812 |
||
813 |
oldSize := contentsArray size. |
|
68 | 814 |
((firstIndex > 1) and:[firstIndex > (oldSize // 4)]) ifTrue:[ |
159 | 815 |
"there is room (>25%) at the beginning" |
33 | 816 |
|
159 | 817 |
index == 1 ifFalse:[ |
818 |
contentsArray |
|
819 |
replaceFrom:(firstIndex - 1) |
|
820 |
to:(index - 1) |
|
821 |
with:contentsArray |
|
822 |
startingAt:firstIndex. |
|
823 |
contentsArray at:index put:nil. |
|
824 |
]. |
|
825 |
firstIndex := firstIndex - 1. |
|
826 |
^ self |
|
33 | 827 |
]. |
828 |
lastIndex < (oldSize * 3 // 4) ifTrue:[ |
|
159 | 829 |
"there is room (>25%) at the end" |
33 | 830 |
|
159 | 831 |
index == (lastIndex + 1) ifFalse:[ |
832 |
contentsArray |
|
833 |
replaceFrom:(index + 1) |
|
834 |
to:(lastIndex + 1) |
|
835 |
with:contentsArray |
|
836 |
startingAt:index. |
|
837 |
contentsArray at:index put:nil |
|
838 |
]. |
|
839 |
lastIndex := lastIndex + 1. |
|
840 |
^ self |
|
33 | 841 |
]. |
842 |
||
843 |
newSize := oldSize * 2. |
|
253 | 844 |
newContents := Array basicNew:newSize. |
329 | 845 |
index ~~ 1 ifTrue:[ |
846 |
newContents |
|
847 |
replaceFrom:1 |
|
848 |
to:index-1 |
|
849 |
with:contentsArray |
|
850 |
startingAt:1. |
|
1 | 851 |
]. |
329 | 852 |
index ~~ newSize ifTrue:[ |
159 | 853 |
newContents |
854 |
replaceFrom:index + 1 |
|
855 |
to:oldSize + 1 |
|
856 |
with:contentsArray |
|
857 |
startingAt:index. |
|
1 | 858 |
]. |
859 |
contentsArray := newContents. |
|
860 |
lastIndex := lastIndex + 1 |
|
861 |
! |
|
862 |
||
606 | 863 |
makeRoomAtLast |
864 |
"grow/shift the contents for more room at the end. |
|
865 |
Does not change the logical size. |
|
866 |
i.e. |
|
867 |
#(1 2 3 4 5 6) -> #(1 2 3 4 5 6 nil)" |
|
868 |
||
869 |
|newContents |
|
870 |
oldSize "{ Class:SmallInteger }" |
|
871 |
newSize "{ Class:SmallInteger }" |
|
872 |
startIndex "{ Class:SmallInteger }" |
|
873 |
sz "{ Class:SmallInteger }"| |
|
874 |
||
875 |
oldSize := contentsArray size. |
|
876 |
sz := lastIndex - firstIndex + 1. |
|
877 |
||
878 |
" |
|
879 |
if there is lots of room at the beginning (> 50%), |
|
880 |
shift instead of growing. This helps collections which get |
|
881 |
elements removed at front and added at the end. |
|
882 |
" |
|
883 |
oldSize > (sz * 2) ifTrue:[ |
|
884 |
startIndex := firstIndex // 4. |
|
885 |
startIndex == 0 ifTrue:[ |
|
886 |
startIndex := 1 |
|
887 |
]. |
|
888 |
contentsArray |
|
889 |
replaceFrom:startIndex |
|
890 |
to:startIndex + sz - 1 |
|
891 |
with:contentsArray |
|
892 |
startingAt:firstIndex. |
|
893 |
contentsArray from:startIndex + sz to:lastIndex put:nil. |
|
894 |
firstIndex := startIndex. |
|
895 |
lastIndex := startIndex + sz - 1. |
|
896 |
^ self |
|
897 |
]. |
|
898 |
newSize := oldSize * 2. |
|
899 |
newSize == 0 ifTrue:[newSize := 3]. |
|
900 |
newContents := Array basicNew:newSize. |
|
901 |
newContents |
|
902 |
replaceFrom:1 |
|
903 |
to:oldSize |
|
904 |
with:contentsArray |
|
905 |
startingAt:1. |
|
906 |
contentsArray := newContents |
|
907 |
! |
|
908 |
||
909 |
setFirstIndex:newFirstIndex lastIndex:newLastIndex |
|
910 |
"set first and last index" |
|
911 |
||
912 |
firstIndex := newFirstIndex. |
|
913 |
lastIndex := newLastIndex. |
|
914 |
! ! |
|
915 |
||
916 |
!OrderedCollection methodsFor:'private accessing'! |
|
917 |
||
918 |
contentsArray |
|
919 |
^ contentsArray |
|
920 |
! |
|
921 |
||
922 |
firstIndex |
|
923 |
^ firstIndex |
|
924 |
! ! |
|
925 |
||
926 |
!OrderedCollection methodsFor:'queries'! |
|
927 |
||
928 |
capacity |
|
929 |
"return the number of elements, that the receiver is |
|
930 |
prepared to take. |
|
931 |
Not used by the system; added for ST-80 compatibility." |
|
932 |
||
933 |
^ contentsArray size |
|
934 |
! |
|
935 |
||
936 |
isEmpty |
|
937 |
"return true, if the receiver has no elements" |
|
938 |
||
939 |
^ lastIndex < firstIndex |
|
940 |
! |
|
941 |
||
942 |
isFixedSize |
|
943 |
"return true if the receiver cannot grow - this will vanish once |
|
944 |
Arrays and Strings learn how to grow ..." |
|
40 | 945 |
|
606 | 946 |
^ false |
947 |
! |
|
948 |
||
949 |
notEmpty |
|
950 |
"return true, if the receiver has any elements" |
|
951 |
||
952 |
^ lastIndex >= firstIndex |
|
953 |
! |
|
954 |
||
955 |
size |
|
956 |
"return the number of elements in the collection" |
|
957 |
||
958 |
^ lastIndex - firstIndex + 1 |
|
959 |
! ! |
|
960 |
||
961 |
!OrderedCollection methodsFor:'searching'! |
|
962 |
||
963 |
after:anObject |
|
964 |
"return the element, after anObject. |
|
965 |
If anObject is not in the receiver, report an error." |
|
966 |
||
967 |
^ self after:anObject ifAbsent:[self errorValueNotFound:anObject] |
|
968 |
||
969 |
" |
|
970 |
#(4 3 2 1) asOrderedCollection after:3. |
|
971 |
#(4 3 2 1) asOrderedCollection after:5 |
|
972 |
#(4 3 2 1) asOrderedCollection after:1 |
|
973 |
" |
|
974 |
! |
|
975 |
||
976 |
after:anObject ifAbsent:exceptionBlock |
|
977 |
"return the element after the argument anObject, nil if there is none. |
|
978 |
If anObject is not in the receiver, return the result from evaluating exceptionBlock." |
|
979 |
||
980 |
|idx| |
|
981 |
||
982 |
idx := self indexOf:anObject. |
|
983 |
idx ~~ 0 ifTrue:[ |
|
984 |
idx == lastIndex ifTrue:[^ nil]. |
|
985 |
^ self at:(idx + 1). |
|
986 |
]. |
|
987 |
^ exceptionBlock value |
|
988 |
||
989 |
" |
|
990 |
#(4 3 2 1) asOrderedCollection after:3. |
|
991 |
#(4 3 2 1) asOrderedCollection after:5 |
|
992 |
#(4 3 2 1) asOrderedCollection after:1 |
|
993 |
" |
|
994 |
! |
|
995 |
||
996 |
before:anObject |
|
997 |
"return the element before the argument, anObject. |
|
998 |
If anObject is not in the receiver, report an error." |
|
999 |
||
1000 |
^ self before:anObject ifAbsent:[self errorValueNotFound:anObject] |
|
1001 |
||
1002 |
" |
|
1003 |
#(4 3 2 1) asOrderedCollection before:3. |
|
1004 |
#(4 3 2 1) asOrderedCollection before:4 |
|
1005 |
#(4 3 2 1) asOrderedCollection before:0 |
|
1006 |
" |
|
1007 |
! |
|
1008 |
||
1009 |
before:anObject ifAbsent:exceptionBlock |
|
1010 |
"return the element before the argument anObject, nil if there is none. |
|
1011 |
If anObject is not in the receiver, return the result from evaluating exceptionBlock." |
|
1012 |
||
1013 |
|idx| |
|
1014 |
||
1015 |
idx := self indexOf:anObject. |
|
1016 |
idx ~~ 0 ifTrue:[ |
|
1017 |
idx == firstIndex ifTrue:[^ nil]. |
|
1018 |
^ self at:(idx - 1). |
|
1019 |
]. |
|
1020 |
^ exceptionBlock value |
|
1021 |
||
1022 |
" |
|
1023 |
#(4 3 2 1) asOrderedCollection before:3. |
|
1024 |
#(4 3 2 1) asOrderedCollection before:5 |
|
1025 |
#(4 3 2 1) asOrderedCollection before:1 |
|
1026 |
#(4 3 2 1) asOrderedCollection before:4 |
|
1027 |
" |
|
1 | 1028 |
! ! |
1029 |
||
1030 |
!OrderedCollection methodsFor:'testing'! |
|
1031 |
||
1032 |
identityIndexOf:anObject |
|
33 | 1033 |
"return the index of anObject or 0 if not found. Compare using ==" |
1 | 1034 |
|
33 | 1035 |
|index "{ Class:SmallInteger }"| |
1 | 1036 |
|
13 | 1037 |
index := contentsArray identityIndexOf:anObject startingAt:firstIndex. |
33 | 1038 |
((index < firstIndex) or:[index > lastIndex]) ifTrue:[^ 0]. |
1 | 1039 |
^ index - firstIndex + 1 |
1040 |
! |
|
1041 |
||
1042 |
identityIndexOf:anObject startingAt:startIndex |
|
33 | 1043 |
"return the index of anObject, starting search at startIndex. |
1044 |
Compare using ==; return 0 if not found in the collection" |
|
1 | 1045 |
|
33 | 1046 |
|index "{ Class:SmallInteger }"| |
1 | 1047 |
|
1048 |
index := contentsArray identityIndexOf:anObject startingAt:(startIndex + firstIndex - 1). |
|
33 | 1049 |
((index < firstIndex) or:[index > lastIndex]) ifTrue:[^ 0]. |
1 | 1050 |
^ index - firstIndex + 1 |
1051 |
! |
|
1052 |
||
606 | 1053 |
includes:anObject |
1054 |
"return true if anObject is in the collection. Compare using =" |
|
1055 |
||
1056 |
|index "{ Class:SmallInteger }"| |
|
1057 |
||
1058 |
index := contentsArray indexOf:anObject startingAt:firstIndex. |
|
1059 |
((index < firstIndex) or:[index > lastIndex]) ifTrue:[^ false]. |
|
1060 |
^ true |
|
1061 |
! |
|
1062 |
||
1 | 1063 |
indexOf:anObject |
33 | 1064 |
"return the index of anObject or 0 if not found in the collection. |
1065 |
Compare using =" |
|
1 | 1066 |
|
33 | 1067 |
|index "{ Class:SmallInteger }"| |
1 | 1068 |
|
13 | 1069 |
index := contentsArray indexOf:anObject startingAt:firstIndex. |
33 | 1070 |
((index < firstIndex) or:[index > lastIndex]) ifTrue:[^ 0]. |
1 | 1071 |
^ index - firstIndex + 1 |
1072 |
! |
|
1073 |
||
1074 |
indexOf:anObject startingAt:startIndex |
|
33 | 1075 |
"return the index of anObject, starting search at startIndex. |
1076 |
Compare using =; return 0 if not found in the collection" |
|
1 | 1077 |
|
33 | 1078 |
|index "{ Class:SmallInteger }"| |
1 | 1079 |
|
1080 |
index := contentsArray indexOf:anObject startingAt:(startIndex + firstIndex - 1). |
|
33 | 1081 |
((index < firstIndex) or:[index > lastIndex]) ifTrue:[^ 0]. |
1 | 1082 |
^ index - firstIndex + 1 |
1083 |
! ! |
|
1084 |
||
629 | 1085 |
!OrderedCollection class methodsFor:'documentation'! |
1086 |
||
1087 |
version |
|
1088 |
^ '$Header: /cvs/stx/stx/libbasic/OrderedCollection.st,v 1.38 1995-11-23 17:06:25 cg Exp $' |
|
1089 |
! ! |