1
|
1 |
"
|
5
|
2 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
155
|
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 |
Object subclass:#Collection
|
|
14 |
instanceVariableNames:''
|
345
|
15 |
classVariableNames:'InvalidKeySignal EmptyCollectionSignal
|
348
|
16 |
ValueNotFoundSignal NotEnoughElementsSignal'
|
1
|
17 |
poolDictionaries:''
|
|
18 |
category:'Collections-Abstract'
|
|
19 |
!
|
|
20 |
|
|
21 |
Collection comment:'
|
88
|
22 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
155
|
23 |
All Rights Reserved
|
92
|
24 |
|
348
|
25 |
$Header: /cvs/stx/stx/libbasic/Attic/Coll.st,v 1.34 1995-05-18 15:09:00 claus Exp $
|
88
|
26 |
'!
|
1
|
27 |
|
88
|
28 |
!Collection class methodsFor:'documentation'!
|
|
29 |
|
|
30 |
copyright
|
|
31 |
"
|
|
32 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
155
|
33 |
All Rights Reserved
|
1
|
34 |
|
88
|
35 |
This software is furnished under a license and may be used
|
|
36 |
only in accordance with the terms of that license and with the
|
|
37 |
inclusion of the above copyright notice. This software may not
|
|
38 |
be provided or otherwise made available to, or used by, any
|
|
39 |
other person. No title to or ownership of the software is
|
|
40 |
hereby transferred.
|
|
41 |
"
|
|
42 |
!
|
1
|
43 |
|
88
|
44 |
version
|
|
45 |
"
|
348
|
46 |
$Header: /cvs/stx/stx/libbasic/Attic/Coll.st,v 1.34 1995-05-18 15:09:00 claus Exp $
|
88
|
47 |
"
|
|
48 |
!
|
|
49 |
|
|
50 |
documentation
|
|
51 |
"
|
|
52 |
Abstract superclass for all collections.
|
|
53 |
This abstract class provides functionality common to all collections,
|
|
54 |
without knowing how the concrete class implements things. Thus, all
|
|
55 |
methods found here depend on some basic mechanisms to be defined in the
|
|
56 |
concrete class.
|
|
57 |
These basic methods are usually defined as #subclassResponsibility here.
|
|
58 |
Some methods are also redefined for better performance.
|
|
59 |
"
|
|
60 |
! !
|
1
|
61 |
|
10
|
62 |
!Collection class methodsFor:'initialization'!
|
|
63 |
|
|
64 |
initialize
|
|
65 |
"setup the signal"
|
|
66 |
|
54
|
67 |
InvalidKeySignal isNil ifTrue:[
|
302
|
68 |
InvalidKeySignal := ErrorSignal newSignalMayProceed:true.
|
155
|
69 |
InvalidKeySignal nameClass:self message:#invalidKeySignal.
|
345
|
70 |
InvalidKeySignal notifierString:'invalid key:'.
|
|
71 |
|
|
72 |
ValueNotFoundSignal := ErrorSignal newSignalMayProceed:true.
|
|
73 |
ValueNotFoundSignal nameClass:self message:#valueNotFoundSignal.
|
|
74 |
ValueNotFoundSignal notifierString:'value not found:'.
|
155
|
75 |
|
348
|
76 |
NotEnoughElementsSignal := ErrorSignal newSignalMayProceed:true.
|
|
77 |
NotEnoughElementsSignal nameClass:self message:#notEnoughElementsSignal.
|
|
78 |
NotEnoughElementsSignal notifierString:'not enough elements in collection'.
|
|
79 |
|
|
80 |
EmptyCollectionSignal := NotEnoughElementsSignal newSignalMayProceed:true.
|
155
|
81 |
EmptyCollectionSignal nameClass:self message:#emptyCollectionSignal.
|
|
82 |
EmptyCollectionSignal notifierString:'operation not allowed for empty collections'.
|
54
|
83 |
]
|
10
|
84 |
! !
|
|
85 |
|
345
|
86 |
!Collection class methodsFor:'Signal constants'!
|
10
|
87 |
|
|
88 |
invalidKeySignal
|
|
89 |
"return the signal used to report bad key usage"
|
|
90 |
|
|
91 |
^ InvalidKeySignal
|
155
|
92 |
!
|
|
93 |
|
345
|
94 |
valueNotFoundSignal
|
|
95 |
"return the signal used to report a nonexisting element."
|
|
96 |
|
|
97 |
^ ValueNotFoundSignal
|
|
98 |
!
|
|
99 |
|
155
|
100 |
emptyCollectionSignal
|
|
101 |
"return the signal used to report non-allowed operation on empty collections"
|
|
102 |
|
|
103 |
^ EmptyCollectionSignal
|
348
|
104 |
!
|
|
105 |
|
|
106 |
notEnoughElementsSignal
|
|
107 |
"return the signal used to report attempts for an operation, for which
|
|
108 |
there are not enough elements in the collection"
|
|
109 |
|
|
110 |
^ NotEnoughElementsSignal
|
10
|
111 |
! !
|
|
112 |
|
92
|
113 |
!Collection class methodsFor:'queries'!
|
|
114 |
|
|
115 |
growIsCheap
|
|
116 |
"return true, if this collection can easily grow
|
|
117 |
(i.e. without a need for become:).
|
|
118 |
Returns true here; this method is redefined in fix-size
|
|
119 |
collections"
|
|
120 |
|
|
121 |
^ true
|
|
122 |
! !
|
|
123 |
|
1
|
124 |
!Collection class methodsFor:'instance creation'!
|
|
125 |
|
|
126 |
with:anObject
|
|
127 |
"return a new Collection with one element:anObject"
|
|
128 |
|
|
129 |
|newCollection|
|
|
130 |
|
|
131 |
newCollection := self new.
|
|
132 |
newCollection add:anObject.
|
|
133 |
^ newCollection
|
|
134 |
!
|
|
135 |
|
|
136 |
with:firstObject with:secondObject
|
|
137 |
"return a new Collection with two elements:firstObject and secondObject"
|
|
138 |
|
|
139 |
|newCollection|
|
|
140 |
|
|
141 |
newCollection := self new.
|
|
142 |
newCollection add:firstObject.
|
|
143 |
newCollection add:secondObject.
|
|
144 |
^ newCollection
|
|
145 |
!
|
|
146 |
|
|
147 |
with:firstObject with:secondObject with:thirdObject
|
|
148 |
"return a new Collection with three elements"
|
|
149 |
|
|
150 |
|newCollection|
|
|
151 |
|
|
152 |
newCollection := self new.
|
|
153 |
newCollection add:firstObject.
|
|
154 |
newCollection add:secondObject.
|
|
155 |
newCollection add:thirdObject.
|
|
156 |
^ newCollection
|
|
157 |
!
|
|
158 |
|
|
159 |
with:firstObject with:secondObject with:thirdObject with:fourthObject
|
|
160 |
"return a new Collection with four elements"
|
|
161 |
|
|
162 |
|newCollection|
|
|
163 |
|
|
164 |
newCollection := self new.
|
|
165 |
newCollection add:firstObject.
|
|
166 |
newCollection add:secondObject.
|
|
167 |
newCollection add:thirdObject.
|
|
168 |
newCollection add:fourthObject.
|
|
169 |
^ newCollection
|
|
170 |
!
|
|
171 |
|
345
|
172 |
with:one with:two with:three with:four with:five
|
|
173 |
"return a new Collection with five elements"
|
|
174 |
|
|
175 |
|newCollection|
|
|
176 |
|
|
177 |
newCollection := self new.
|
|
178 |
newCollection add:one.
|
|
179 |
newCollection add:two.
|
|
180 |
newCollection add:three.
|
|
181 |
newCollection add:four.
|
|
182 |
newCollection add:five.
|
|
183 |
^ newCollection
|
|
184 |
!
|
|
185 |
|
1
|
186 |
new:size withAll:element
|
|
187 |
"return a new COllection of size, where all elements are
|
|
188 |
initialized to element"
|
|
189 |
|
|
190 |
|newCollection|
|
|
191 |
|
|
192 |
newCollection := self new:size.
|
|
193 |
size timesRepeat:[newCollection add:element]
|
|
194 |
!
|
|
195 |
|
|
196 |
withAll:aCollection
|
|
197 |
"return a new Collection with all elements taken from the argument,
|
|
198 |
aCollection"
|
|
199 |
|
|
200 |
|newCollection|
|
|
201 |
|
|
202 |
newCollection := self new.
|
|
203 |
newCollection addAll:aCollection.
|
|
204 |
^newCollection
|
|
205 |
! !
|
|
206 |
|
|
207 |
!Collection methodsFor:'error handling'!
|
|
208 |
|
|
209 |
errorNotKeyed
|
|
210 |
"report an error that keyed access methods are not allowed"
|
|
211 |
|
140
|
212 |
^ self error:(self class name, 's do not respond to keyed accessing messages')
|
10
|
213 |
!
|
|
214 |
|
345
|
215 |
errorInvalidKey:aKey
|
10
|
216 |
"report an error that the given key was invalid"
|
|
217 |
|
345
|
218 |
^ InvalidKeySignal raiseRequestWith:aKey
|
|
219 |
!
|
|
220 |
|
|
221 |
errorValueNotFound:anObject
|
|
222 |
"report an error that an object was not found in the collection"
|
|
223 |
|
|
224 |
^ ValueNotFoundSignal raiseRequestWith:anObject
|
155
|
225 |
!
|
|
226 |
|
|
227 |
emptyCollectionError
|
|
228 |
"report an error that the operation is not allowed for
|
|
229 |
empty collections"
|
|
230 |
|
|
231 |
^ EmptyCollectionSignal raise
|
308
|
232 |
!
|
|
233 |
|
348
|
234 |
notEnoughElementsError
|
|
235 |
"report an error that the operation is not allowed,
|
|
236 |
since not enough elements are in the collection"
|
|
237 |
|
|
238 |
^ NotEnoughElementsSignal raise
|
|
239 |
!
|
|
240 |
|
308
|
241 |
emptyCheck
|
|
242 |
"check if the receiver is empty; report an error if so"
|
|
243 |
|
|
244 |
self size == 0 ifTrue:[
|
|
245 |
^ self emptyCollectionError.
|
|
246 |
].
|
1
|
247 |
! !
|
|
248 |
|
201
|
249 |
!Collection methodsFor:'copying'!
|
|
250 |
|
|
251 |
copyEmpty:size
|
|
252 |
"return a copy of the receiver with no elements, but space for
|
|
253 |
size elements. This is used by copying and enumertion methods
|
|
254 |
to get a new instance which is similar to the receiver.
|
|
255 |
This method should be redefined in subclasses with instance
|
|
256 |
variables, which should be put into the copy too.
|
|
257 |
For example, SortedCollection has to copy its sortBlock into the
|
|
258 |
new collection."
|
|
259 |
|
|
260 |
^ self species new:size
|
|
261 |
!
|
|
262 |
|
|
263 |
copyEmpty
|
|
264 |
"return a copy of the receiver with no elements.
|
|
265 |
This is used by copying and enumertion methods
|
|
266 |
to get a new instance which is similar to the receiver."
|
|
267 |
|
|
268 |
^ self species new
|
249
|
269 |
!
|
|
270 |
|
|
271 |
copyEmptyAndGrow:size
|
|
272 |
"return a copy of the receiver with size nil elements.
|
|
273 |
This is used by copying and enumertion methods
|
|
274 |
to get a new instance which is similar to the receiver."
|
|
275 |
|
|
276 |
^ (self copyEmpty:size) grow:size
|
201
|
277 |
! !
|
|
278 |
|
257
|
279 |
!Collection methodsFor:'queries'!
|
|
280 |
|
|
281 |
isCollection
|
|
282 |
"return true, if the receiver is some kind of collection;
|
|
283 |
true is returned here - the method is redefined from Object."
|
|
284 |
|
|
285 |
^ true
|
|
286 |
! !
|
|
287 |
|
1
|
288 |
!Collection methodsFor:'accessing'!
|
|
289 |
|
68
|
290 |
first
|
|
291 |
"return the first element of the collection.
|
|
292 |
This should be redefined in subclasses."
|
|
293 |
|
|
294 |
self do:[:e | ^ e].
|
|
295 |
|
|
296 |
"error if collection is empty"
|
155
|
297 |
^ self emptyCollectionError
|
68
|
298 |
!
|
|
299 |
|
|
300 |
last
|
|
301 |
"return the last element of the collection.
|
|
302 |
This should be redefined in subclasses."
|
|
303 |
|
|
304 |
|theLastOne any|
|
|
305 |
|
|
306 |
any := false.
|
|
307 |
self do:[:e | any := true. theLastOne := e].
|
|
308 |
any ifTrue:[
|
155
|
309 |
^ theLastOne
|
68
|
310 |
].
|
|
311 |
|
|
312 |
"error if collection is empty"
|
155
|
313 |
^ self emptyCollectionError
|
68
|
314 |
!
|
|
315 |
|
1
|
316 |
anElement
|
68
|
317 |
"return any element from the collection, or nil if there is none"
|
1
|
318 |
|
|
319 |
self do: [:each | ^ each].
|
|
320 |
^ nil
|
328
|
321 |
!
|
|
322 |
|
|
323 |
upTo:anElement
|
|
324 |
"return a new collection consisting of the receivers elements upTo
|
|
325 |
(but excluding) anElement.
|
|
326 |
If anElement is not in the receiver, the returned collection
|
|
327 |
will consist of all elements of the receiver"
|
|
328 |
|
|
329 |
|s|
|
|
330 |
|
|
331 |
s := ReadStream on:self.
|
|
332 |
^ s upTo:anElement
|
|
333 |
|
|
334 |
"
|
|
335 |
'test.text' upTo:$.
|
|
336 |
#(1 2 3 4 5) upTo:4
|
|
337 |
"
|
1
|
338 |
! !
|
|
339 |
|
|
340 |
!Collection methodsFor:'adding & removing'!
|
|
341 |
|
|
342 |
add:anObject
|
88
|
343 |
"add the argument, anObject to the receiver.
|
|
344 |
If the receiver is ordered, the position of the new element is undefined
|
|
345 |
(i.e. dont depend on where it will be put)."
|
1
|
346 |
|
|
347 |
^ self subclassResponsibility
|
|
348 |
!
|
|
349 |
|
|
350 |
addLast:anObject
|
88
|
351 |
"add the argument, anObject to the receiver.
|
|
352 |
If the receiver is ordered, the new element will be added at the end."
|
1
|
353 |
|
|
354 |
^ self add:anObject
|
|
355 |
!
|
|
356 |
|
12
|
357 |
addFirst:anObject
|
88
|
358 |
"add the argument, anObject to the receiver.
|
|
359 |
If the receiver is ordered, the new element will be added at the beginning."
|
12
|
360 |
|
|
361 |
^ self subclassResponsibility
|
|
362 |
!
|
|
363 |
|
1
|
364 |
addAll:aCollection
|
88
|
365 |
"add all elements of the argument, aCollection to the receiver."
|
1
|
366 |
|
|
367 |
aCollection do:[:element |
|
155
|
368 |
self add:element
|
1
|
369 |
].
|
|
370 |
^ aCollection
|
88
|
371 |
|
|
372 |
"
|
|
373 |
#(1 2 3 4) copy addAll:#(5 6 7 8)
|
|
374 |
#(1 2 3 4) asOrderedCollection addAll:#(5 6 7 8)
|
|
375 |
"
|
1
|
376 |
!
|
|
377 |
|
12
|
378 |
addAllLast:aCollection
|
|
379 |
"add all elements of the argument, aCollection to the receiver"
|
|
380 |
|
88
|
381 |
aCollection do:[:element |
|
155
|
382 |
self addLast:element
|
88
|
383 |
].
|
|
384 |
^ aCollection
|
|
385 |
|
|
386 |
"
|
|
387 |
|c|
|
|
388 |
c := #(4 3 2 1) asOrderedCollection.
|
|
389 |
c addAllLast:#(9 8 7 6 5)
|
|
390 |
"
|
12
|
391 |
!
|
|
392 |
|
|
393 |
addAllFirst:aCollection
|
|
394 |
"insert all elements of the argument, aCollection at the beginning
|
|
395 |
of the receiver"
|
|
396 |
|
|
397 |
aCollection reverseDo:[:element |
|
155
|
398 |
self addFirst:element
|
12
|
399 |
].
|
|
400 |
^ aCollection
|
|
401 |
|
|
402 |
"
|
|
403 |
|c|
|
|
404 |
c := #(4 3 2 1) asOrderedCollection.
|
|
405 |
c addAllFirst:#(9 8 7 6 5)
|
|
406 |
"
|
|
407 |
!
|
|
408 |
|
1
|
409 |
remove:anObject ifAbsent:exceptionBlock
|
348
|
410 |
"remove the (first occurrence of) argument, anObject from the receiver,
|
|
411 |
and return it.
|
|
412 |
If it was not in the collection, return the the value of the exceptionBlock"
|
1
|
413 |
|
|
414 |
^ self subclassResponsibility
|
|
415 |
!
|
|
416 |
|
|
417 |
remove:anObject
|
348
|
418 |
"remove the (first occurrence of) argument, anObject from the receiver,
|
|
419 |
and return it.
|
|
420 |
If it was not in the collection, raise an error."
|
1
|
421 |
|
345
|
422 |
self remove:anObject ifAbsent:[self errorValueNotFound:anObject]
|
1
|
423 |
!
|
|
424 |
|
134
|
425 |
removeAll
|
|
426 |
"remove all elements from the receiver.
|
|
427 |
This should be reimplemented in subclasses for better
|
|
428 |
performance."
|
|
429 |
|
|
430 |
[self notEmpty] whileTrue:[
|
155
|
431 |
self removeFirst
|
134
|
432 |
].
|
|
433 |
!
|
|
434 |
|
1
|
435 |
removeAll:aCollection
|
|
436 |
"remove all elements of the argument, aCollection from the receiver"
|
|
437 |
|
|
438 |
aCollection do:[:element | self remove:element].
|
|
439 |
^ aCollection
|
348
|
440 |
!
|
|
441 |
|
|
442 |
removeFirst
|
|
443 |
"remove the first element from the receiver.
|
|
444 |
Return the removed element."
|
|
445 |
|
|
446 |
^ self subclassResponsibility
|
|
447 |
!
|
|
448 |
|
|
449 |
removeLast
|
|
450 |
"remove the last element from the receiver.
|
|
451 |
Return the removed element."
|
|
452 |
|
|
453 |
^ self subclassResponsibility
|
|
454 |
!
|
|
455 |
|
|
456 |
removeFirst:n
|
|
457 |
"remove the first n elements from the receiver.
|
|
458 |
Return an array filled with the removed elements."
|
|
459 |
|
|
460 |
|ret|
|
|
461 |
|
|
462 |
self size < n ifTrue:[
|
|
463 |
^ self notEnoughElementsError
|
|
464 |
].
|
|
465 |
ret := Array new:n.
|
|
466 |
1 to:n do:[:i |
|
|
467 |
ret at:i put:(self removeFirst).
|
|
468 |
].
|
|
469 |
^ ret
|
|
470 |
!
|
|
471 |
|
|
472 |
removeLast:n
|
|
473 |
"remove the last n elements from the receiver.
|
|
474 |
Return an array filled with the removed elements."
|
|
475 |
|
|
476 |
|ret|
|
|
477 |
|
|
478 |
self size < n ifTrue:[
|
|
479 |
^ self notEnoughElementsError
|
|
480 |
].
|
|
481 |
ret := Array new:n.
|
|
482 |
n to:1 by:-1 do:[:i |
|
|
483 |
ret at:i put:(self removeLast).
|
|
484 |
].
|
|
485 |
^ ret
|
1
|
486 |
! !
|
|
487 |
|
|
488 |
!Collection methodsFor:'growing'!
|
|
489 |
|
|
490 |
growSize
|
|
491 |
"return a suitable size increment for growing"
|
|
492 |
|
|
493 |
^ self size max:2
|
|
494 |
!
|
|
495 |
|
|
496 |
grow
|
|
497 |
"make the receiver larger"
|
|
498 |
|
|
499 |
self grow:(self size + self growSize)
|
|
500 |
!
|
|
501 |
|
|
502 |
grow:howBig
|
|
503 |
"change the receivers size"
|
|
504 |
|
|
505 |
^ self subclassResponsibility
|
|
506 |
! !
|
|
507 |
|
|
508 |
!Collection methodsFor:'testing'!
|
|
509 |
|
|
510 |
isEmpty
|
|
511 |
"return true, if the receiver is empty"
|
|
512 |
|
|
513 |
^ self size == 0
|
|
514 |
!
|
|
515 |
|
68
|
516 |
notEmpty
|
|
517 |
"return true, if the receiver is not empty"
|
|
518 |
|
|
519 |
^ self isEmpty not
|
|
520 |
!
|
|
521 |
|
1
|
522 |
includes:anElement
|
|
523 |
"return true, if the argument, anObject is in the list"
|
|
524 |
|
|
525 |
self do:[:element |
|
155
|
526 |
(anElement = element) ifTrue:[^ true].
|
1
|
527 |
].
|
|
528 |
^ false
|
|
529 |
!
|
|
530 |
|
|
531 |
includesAll:aCollection
|
|
532 |
"return true, if the the receiver includes all elements of
|
|
533 |
the argument, aCollection; false if any is missing"
|
|
534 |
|
|
535 |
aCollection do:[:element |
|
155
|
536 |
(self includes:element) ifFalse:[^ false].
|
1
|
537 |
].
|
|
538 |
^ true
|
88
|
539 |
|
|
540 |
"
|
|
541 |
#(1 2 3 4 5 6 7) includesAll:#(1 2 3)
|
|
542 |
#('hello' 'there' 'world') includesAll:#('hello' 'world')
|
|
543 |
#(1 2 3 4 5 6 7) includesAll:#(7 8 9)
|
|
544 |
"
|
1
|
545 |
!
|
|
546 |
|
2
|
547 |
includesAny:aCollection
|
|
548 |
"return true, if the the receiver includes any elements of
|
|
549 |
the argument, aCollection; false if it includes none"
|
|
550 |
|
|
551 |
aCollection do:[:element |
|
155
|
552 |
(self includes:element) ifTrue:[^ true].
|
2
|
553 |
].
|
|
554 |
^ false
|
88
|
555 |
|
|
556 |
"
|
|
557 |
#(1 2 3 4 5 6 7) includesAny:#(1 2 3)
|
|
558 |
#('hello' 'there' 'world') includesAny:#('hello' 'world')
|
|
559 |
#(1 2 3 4 5 6 7) includesAny:#(7 8 9)
|
|
560 |
#(1 2 3 4 5 6 7) includesAny:#(8 9 10)
|
|
561 |
"
|
2
|
562 |
!
|
|
563 |
|
1
|
564 |
occurrencesOf:anElement
|
|
565 |
"return the number of occurrences of the argument, anElement in
|
|
566 |
the receiver"
|
|
567 |
|
201
|
568 |
|count "{ Class: SmallInteger }" |
|
1
|
569 |
|
|
570 |
count := 0.
|
|
571 |
self do:[:element |
|
155
|
572 |
(anElement = element) ifTrue:[
|
|
573 |
count := count + 1
|
|
574 |
].
|
1
|
575 |
].
|
|
576 |
^ count
|
|
577 |
!
|
|
578 |
|
|
579 |
size
|
88
|
580 |
"return the number of elements in the receiver.
|
|
581 |
This is usually redefined in subclasses for more performance."
|
1
|
582 |
|
201
|
583 |
|count "{ Class: SmallInteger }" |
|
1
|
584 |
|
|
585 |
count := 0.
|
|
586 |
self do:[:element |
|
155
|
587 |
count := count + 1
|
1
|
588 |
].
|
|
589 |
^ count
|
155
|
590 |
!
|
|
591 |
|
|
592 |
max
|
213
|
593 |
"return the maximum value in the receiver collection"
|
155
|
594 |
|
|
595 |
^ self inject:nil
|
|
596 |
into:[:maxSoFar :this |
|
|
597 |
(maxSoFar isNil
|
|
598 |
or:[this > maxSoFar]) ifTrue:[this]
|
|
599 |
ifFalse:[maxSoFar]]
|
|
600 |
|
|
601 |
"
|
|
602 |
#(15 1 -9 10 5) max
|
|
603 |
(1 to:15) max
|
|
604 |
"
|
|
605 |
!
|
|
606 |
|
|
607 |
min
|
213
|
608 |
"return the minimum value in the receiver collection"
|
155
|
609 |
|
|
610 |
^ self inject:nil
|
|
611 |
into:[:minSoFar :this |
|
|
612 |
(minSoFar isNil
|
|
613 |
or:[this < minSoFar]) ifTrue:[this]
|
|
614 |
ifFalse:[minSoFar]]
|
|
615 |
|
|
616 |
"
|
|
617 |
#(15 1 -9 10 5) min
|
|
618 |
(1 to:15) min
|
|
619 |
"
|
1
|
620 |
! !
|
|
621 |
|
|
622 |
!Collection methodsFor:'enumerating'!
|
|
623 |
|
|
624 |
do:aBlock
|
|
625 |
"evaluate the argument, aBlock for each element"
|
|
626 |
|
|
627 |
^ self subclassResponsibility
|
|
628 |
!
|
|
629 |
|
68
|
630 |
reverseDo:aBlock
|
|
631 |
"evaluate the argument, aBlock for each element in reverse order."
|
|
632 |
|
|
633 |
"it could be defined in terms of do: - but very inefficient.
|
|
634 |
Better force programmer to define a better version ..."
|
|
635 |
|
|
636 |
^ self subclassResponsibility
|
|
637 |
!
|
|
638 |
|
3
|
639 |
keysAndValuesDo:aTwoArgBlock
|
|
640 |
"evaluate the argument, aBlock for every element in the collection,
|
|
641 |
passing both index and element as arguments."
|
|
642 |
|
|
643 |
^ self errorNotKeyed
|
|
644 |
!
|
|
645 |
|
314
|
646 |
with:aCollection do:aTwoArgBlock
|
77
|
647 |
"evaluate the argument, aBlock for successive elements from
|
|
648 |
each the receiver and the argument, aSequenceableCollection.
|
|
649 |
The second argument, aBlock must be a two-argument block.
|
314
|
650 |
This method fails if neither the receiver nor aCollection is
|
|
651 |
a sequenceable collection (i.e. implements numeric key access)."
|
77
|
652 |
|
316
|
653 |
|index "{ Class: SmallInteger }"|
|
77
|
654 |
|
|
655 |
index := 1.
|
314
|
656 |
aCollection isSequenceable ifFalse:[
|
|
657 |
self isSequenceable ifFalse:[
|
|
658 |
^ self error:'neither collection is sequenceable'.
|
|
659 |
].
|
|
660 |
aCollection do:[:element |
|
|
661 |
aTwoArgBlock value:(self at:index) value:element.
|
|
662 |
index := index + 1
|
|
663 |
]
|
316
|
664 |
] ifTrue:[
|
314
|
665 |
self do:[:element |
|
|
666 |
aTwoArgBlock value:element value:(aCollection at:index).
|
|
667 |
index := index + 1
|
|
668 |
]
|
77
|
669 |
]
|
|
670 |
|
|
671 |
"
|
|
672 |
(1 to:3) with:#(one two three) do:[:num :sym |
|
155
|
673 |
Transcript showCr:(num->sym)
|
77
|
674 |
]
|
314
|
675 |
(1 to:3) with:#(one two three) asSet do:[:num :sym |
|
|
676 |
Transcript showCr:(num->sym)
|
316
|
677 |
].
|
|
678 |
(1 to:3) asSet with:#(one two three) do:[:num :sym |
|
|
679 |
Transcript showCr:(num->sym)
|
314
|
680 |
]
|
77
|
681 |
"
|
|
682 |
!
|
|
683 |
|
1
|
684 |
collect:aBlock
|
|
685 |
"for each element in the receiver, evaluate the argument, aBlock
|
|
686 |
and return a new collection with the results"
|
|
687 |
|
|
688 |
|newCollection|
|
|
689 |
|
201
|
690 |
newCollection := self species new.
|
|
691 |
self do:[:element | newCollection add:(aBlock value:element)].
|
1
|
692 |
^ newCollection
|
68
|
693 |
|
|
694 |
"
|
|
695 |
#(1 2 3 4) collect:[:n | n * 2]
|
|
696 |
"
|
1
|
697 |
!
|
|
698 |
|
314
|
699 |
with:aCollection collect:aTwoArgBlock
|
77
|
700 |
"evaluate the argument, aBlock for successive elements from
|
|
701 |
each the receiver and the argument, aSequenceableCollection;
|
|
702 |
The second argument, aBlock must be a two-argument block, which is
|
|
703 |
evaluated for each element-pair.
|
|
704 |
Collect the results and return a collection containing them.
|
314
|
705 |
This method fails if neither the receiver nor aCollection is
|
|
706 |
a sequenceable collection (i.e. implements numeric key access)."
|
77
|
707 |
|
|
708 |
|index "{ Class: SmallInteger }"
|
|
709 |
newCollection|
|
|
710 |
|
201
|
711 |
newCollection := self species new.
|
77
|
712 |
index := 1.
|
314
|
713 |
aCollection isSequenceable ifFalse:[
|
|
714 |
self isSequenceable ifFalse:[
|
|
715 |
^ self error:'neither collection is sequenceable'.
|
|
716 |
].
|
|
717 |
aCollection do:[:element |
|
|
718 |
newCollection add:(aTwoArgBlock value:(self at:index)
|
|
719 |
value:element).
|
|
720 |
index := index + 1
|
|
721 |
]
|
|
722 |
] ifTrue:[
|
|
723 |
self do:[:element |
|
|
724 |
newCollection add:(aTwoArgBlock value:element
|
|
725 |
value:(aCollection at:index)).
|
|
726 |
index := index + 1
|
|
727 |
]
|
77
|
728 |
].
|
|
729 |
^ newCollection
|
|
730 |
|
|
731 |
"
|
|
732 |
(1 to:3) with:#(one two three) collect:[:num :sym | (num->sym)]
|
|
733 |
#(1 2 3) with:#(10 20 30) collect:[:x :y | (x@y)]
|
|
734 |
"
|
|
735 |
!
|
|
736 |
|
1
|
737 |
detect:aBlock
|
|
738 |
"evaluate the argument, aBlock for each element in the receiver until
|
|
739 |
the block returns true; in this case return the element which caused
|
|
740 |
the true evaluation.
|
345
|
741 |
If none of the evaluations returns true, report an error"
|
1
|
742 |
|
|
743 |
^ self detect:aBlock ifNone:[self errorNotFound]
|
68
|
744 |
|
|
745 |
"
|
|
746 |
#(1 2 3 4) detect:[:n | n odd]
|
|
747 |
#(2 4 6 8) detect:[:n | n odd]
|
|
748 |
"
|
1
|
749 |
!
|
|
750 |
|
|
751 |
detect:aBlock ifNone:exceptionBlock
|
|
752 |
"evaluate the argument, aBlock for each element in the receiver until
|
|
753 |
the block returns true; in this case return the element which caused
|
|
754 |
the true evaluation.
|
|
755 |
If none of the evaluations returns true, return the result of the
|
|
756 |
evaluation of the exceptionBlock"
|
|
757 |
|
|
758 |
self do:[:each |
|
155
|
759 |
(aBlock value:each) ifTrue:[^ each].
|
1
|
760 |
].
|
|
761 |
^ exceptionBlock value
|
68
|
762 |
|
|
763 |
"
|
|
764 |
#(1 2 3 4) detect:[:n | n odd] ifNone:['sorry']
|
|
765 |
#(2 4 6 8) detect:[:n | n odd] ifNone:['sorry']
|
|
766 |
"
|
1
|
767 |
!
|
|
768 |
|
|
769 |
inject:thisValue into:binaryBlock
|
|
770 |
|nextValue|
|
|
771 |
|
|
772 |
nextValue := thisValue.
|
|
773 |
self do: [:each | nextValue := binaryBlock value:nextValue value:each].
|
|
774 |
^ nextValue
|
68
|
775 |
|
|
776 |
"
|
|
777 |
#(1 2 3 4) inject:0 into:[:accu :element | accu + element]
|
|
778 |
(1 to:10) inject:0 into:[:accu :element | accu + element]
|
|
779 |
"
|
1
|
780 |
!
|
|
781 |
|
|
782 |
reject:aBlock
|
|
783 |
"return a new collection with all elements from the receiver, for which
|
|
784 |
the argument aBlock evaluates to false"
|
|
785 |
|
|
786 |
^ self select:[:element | (aBlock value:element) == false]
|
68
|
787 |
|
|
788 |
"
|
|
789 |
#(1 2 3 4) reject:[:e | e odd]
|
|
790 |
(1 to:10) reject:[:e | e even]
|
|
791 |
"
|
1
|
792 |
!
|
|
793 |
|
|
794 |
select:aBlock
|
|
795 |
"return a new collection with all elements from the receiver, for which
|
|
796 |
the argument aBlock evaluates to true"
|
|
797 |
|
|
798 |
|newCollection|
|
|
799 |
|
201
|
800 |
newCollection := self species new.
|
1
|
801 |
self do:[:each |
|
155
|
802 |
(aBlock value:each) ifTrue:[newCollection add:each].
|
1
|
803 |
].
|
|
804 |
^ newCollection
|
68
|
805 |
|
|
806 |
"
|
|
807 |
#(1 2 3 4) select:[:e | e odd]
|
|
808 |
(1 to:10) select:[:e | e even]
|
|
809 |
"
|
|
810 |
!
|
|
811 |
|
|
812 |
select:aBlock ifNone:exceptionBlock
|
|
813 |
"try a new collection with all elements from the receiver, for which
|
|
814 |
the argument aBlock evaluates to true. If none of the elements passes
|
|
815 |
the check of aBlock, return the result of evaluating exceptionBlock."
|
|
816 |
|
|
817 |
|newCollection|
|
|
818 |
|
|
819 |
newCollection := self select:aBlock.
|
|
820 |
newCollection isEmpty ifTrue:[^ exceptionBlock value].
|
|
821 |
^ newCollection
|
|
822 |
|
|
823 |
"
|
|
824 |
#(1 2 3 4) select:[:e | e > 10] ifNone:['sorry']
|
|
825 |
"
|
12
|
826 |
!
|
|
827 |
|
314
|
828 |
conform:aBlock
|
|
829 |
"return true, if every element conforms to some condition.
|
|
830 |
I.e. return false, if aBlock returns false for any element;
|
|
831 |
true otherwise."
|
|
832 |
|
|
833 |
self do:[:element | (aBlock value:element) ifFalse:[^ false]].
|
|
834 |
^ true
|
|
835 |
!
|
|
836 |
|
12
|
837 |
addAllTo:aCollection
|
|
838 |
"add all elements of the receiver, to aCollection.
|
|
839 |
Return aCollection."
|
|
840 |
|
|
841 |
self do:[:each | aCollection add:each].
|
|
842 |
^ aCollection
|
1
|
843 |
! !
|
|
844 |
|
|
845 |
!Collection methodsFor:'converting'!
|
|
846 |
|
|
847 |
asArray
|
|
848 |
"return a new Array with the collections elements"
|
|
849 |
|
|
850 |
|anArray
|
201
|
851 |
index "{ Class: SmallInteger }" |
|
1
|
852 |
|
|
853 |
anArray := Array new:(self size).
|
|
854 |
index := 1.
|
|
855 |
self do:[:each |
|
155
|
856 |
anArray at:index put:each.
|
|
857 |
index := index + 1
|
1
|
858 |
].
|
|
859 |
^ anArray
|
|
860 |
!
|
|
861 |
|
|
862 |
asByteArray
|
34
|
863 |
"return a new ByteArray with the collections elements
|
|
864 |
(which must convert to integers in the range 0..255)."
|
1
|
865 |
|
|
866 |
|aByteArray
|
201
|
867 |
index "{ Class: SmallInteger }" |
|
1
|
868 |
|
|
869 |
aByteArray := ByteArray new:(self size).
|
|
870 |
index := 1.
|
|
871 |
self do:[:each |
|
155
|
872 |
aByteArray at:index put:each asInteger.
|
|
873 |
index := index + 1
|
1
|
874 |
].
|
|
875 |
^ aByteArray
|
|
876 |
!
|
|
877 |
|
54
|
878 |
asFloatArray
|
|
879 |
"return a new FloatArray with the collections elements
|
|
880 |
(which must convert to floats)."
|
|
881 |
|
|
882 |
|aFloatArray
|
201
|
883 |
index "{ Class: SmallInteger }" |
|
54
|
884 |
|
|
885 |
aFloatArray := FloatArray new:(self size).
|
|
886 |
index := 1.
|
|
887 |
self do:[:each |
|
155
|
888 |
aFloatArray at:index put:each asFloat.
|
|
889 |
index := index + 1
|
54
|
890 |
].
|
|
891 |
^ aFloatArray
|
|
892 |
!
|
|
893 |
|
|
894 |
asDoubleArray
|
|
895 |
"return a new DoubleArray with the collections elements
|
|
896 |
(which must convert to floats)."
|
|
897 |
|
|
898 |
|aDoubleArray
|
201
|
899 |
index "{ Class: SmallInteger }" |
|
54
|
900 |
|
|
901 |
aDoubleArray := DoubleArray new:(self size).
|
|
902 |
index := 1.
|
|
903 |
self do:[:each |
|
155
|
904 |
aDoubleArray at:index put:each asFloat.
|
|
905 |
index := index + 1
|
54
|
906 |
].
|
|
907 |
^ aDoubleArray
|
|
908 |
!
|
|
909 |
|
1
|
910 |
asString
|
|
911 |
"return a String with the collections elements
|
34
|
912 |
(which must convert to characters)"
|
1
|
913 |
|
|
914 |
|aString
|
201
|
915 |
index "{ Class: SmallInteger }" |
|
1
|
916 |
|
|
917 |
aString := String new:(self size).
|
|
918 |
index := 1.
|
|
919 |
self do:[:each |
|
155
|
920 |
aString at:index put:each asCharacter.
|
|
921 |
index := index + 1
|
1
|
922 |
].
|
|
923 |
^ aString
|
|
924 |
!
|
|
925 |
|
244
|
926 |
asStringCollection
|
|
927 |
"return a new Text-object (collection of lines) with the elements printstings"
|
|
928 |
|
|
929 |
^ self addAllTo:(StringCollection new)
|
|
930 |
!
|
|
931 |
|
1
|
932 |
asText
|
244
|
933 |
"return a Text-object (collection of lines) from myself.
|
|
934 |
BIG warning: asText is totally misnamed here
|
|
935 |
- ST/X's asText has nothing to do with PP's asText.
|
260
|
936 |
Therefore it will be removed/renamed soon.
|
|
937 |
Please use #asStringCollection."
|
1
|
938 |
|
342
|
939 |
self obsoleteMethodWarning:'use #asStringCollection; #asText will change its meaning'.
|
260
|
940 |
|
244
|
941 |
^ self asStringCollection
|
1
|
942 |
!
|
|
943 |
|
|
944 |
asBag
|
|
945 |
"return a new Bag with the receiver collections elements"
|
|
946 |
|
12
|
947 |
^ self addAllTo:(Bag new)
|
1
|
948 |
!
|
|
949 |
|
|
950 |
asOrderedCollection
|
|
951 |
"return a new OrderedCollection with the receiver collections elements"
|
|
952 |
|
12
|
953 |
^ self addAllTo:(OrderedCollection new:self size)
|
1
|
954 |
!
|
|
955 |
|
|
956 |
asSet
|
|
957 |
"return a new Set with the receiver collections elements"
|
|
958 |
|
12
|
959 |
^ self addAllTo:(Set new:self size)
|
|
960 |
!
|
1
|
961 |
|
12
|
962 |
asIdentitySet
|
|
963 |
"return a new IdentitySet with the receiver collections elements"
|
|
964 |
|
|
965 |
^ self addAllTo:(IdentitySet new:self size)
|
1
|
966 |
!
|
|
967 |
|
|
968 |
asSortedCollection
|
|
969 |
"return a new SortedCollection with the receiver collections elements"
|
|
970 |
|
|
971 |
|aSortedCollection|
|
|
972 |
|
|
973 |
aSortedCollection := SortedCollection new:self size.
|
|
974 |
aSortedCollection addAll:self.
|
|
975 |
^ aSortedCollection
|
|
976 |
!
|
|
977 |
|
|
978 |
asSortedCollection:sortBlock
|
|
979 |
"return a new SortedCollection with the receiver collections elements,
|
|
980 |
using sortBlock for comparing"
|
|
981 |
|
|
982 |
|aSortedCollection|
|
|
983 |
|
|
984 |
aSortedCollection := SortedCollection sortBlock:sortBlock.
|
|
985 |
aSortedCollection addAll:self.
|
|
986 |
^ aSortedCollection
|
2
|
987 |
!
|
|
988 |
|
|
989 |
writeStream
|
|
990 |
"return a stream for writing onto the receiver"
|
|
991 |
|
|
992 |
^ WriteStream on:self
|
201
|
993 |
|
|
994 |
"
|
|
995 |
|s|
|
|
996 |
|
|
997 |
s := #() copy writeStream.
|
|
998 |
s nextPut:1.
|
|
999 |
s nextPut:2.
|
|
1000 |
s nextPut:3.
|
|
1001 |
s contents inspect
|
|
1002 |
"
|
|
1003 |
|
|
1004 |
"
|
|
1005 |
|s|
|
|
1006 |
|
|
1007 |
s := OrderedCollection new writeStream.
|
|
1008 |
s nextPut:1.
|
|
1009 |
s nextPut:2.
|
|
1010 |
s nextPut:3.
|
|
1011 |
s contents inspect
|
|
1012 |
"
|
2
|
1013 |
!
|
|
1014 |
|
|
1015 |
readStream
|
|
1016 |
"return a stream for reading from the receiver"
|
|
1017 |
|
|
1018 |
^ ReadStream on:self
|
201
|
1019 |
|
|
1020 |
"
|
|
1021 |
|s|
|
|
1022 |
|
|
1023 |
s := 'hello world' readStream.
|
|
1024 |
s next:5.
|
|
1025 |
s next.
|
|
1026 |
(s next:5) inspect
|
|
1027 |
"
|
1
|
1028 |
! !
|
|
1029 |
|
|
1030 |
!Collection methodsFor:'printing & storing'!
|
|
1031 |
|
|
1032 |
maxPrint
|
169
|
1033 |
"the print-limit; printOn: will try to not produce more output
|
88
|
1034 |
than the limit defined here."
|
|
1035 |
|
1
|
1036 |
^ 5000
|
|
1037 |
!
|
|
1038 |
|
12
|
1039 |
printOrDisplayStringUsing:aSelector
|
|
1040 |
"common code for printString and displayString; they only differ in
|
|
1041 |
the print-message sent to the elements"
|
1
|
1042 |
|
169
|
1043 |
|thisString buffer count string noneYet total limit|
|
1
|
1044 |
|
25
|
1045 |
thisContext isRecursive ifTrue:[
|
155
|
1046 |
Transcript showCr:'Error: print/storeString of self referencing collection.'.
|
|
1047 |
^ '#("recursive")'
|
25
|
1048 |
].
|
|
1049 |
|
1
|
1050 |
string := (self class name) , '('.
|
|
1051 |
noneYet := true.
|
|
1052 |
buffer := ''.
|
|
1053 |
count := 0.
|
|
1054 |
total := 0.
|
169
|
1055 |
limit := self maxPrint.
|
|
1056 |
|
1
|
1057 |
self do: [:element |
|
155
|
1058 |
thisString := element perform:aSelector.
|
|
1059 |
noneYet ifTrue:[
|
|
1060 |
noneYet := false.
|
|
1061 |
buffer := buffer , thisString
|
|
1062 |
] ifFalse:[
|
|
1063 |
buffer := buffer , (' ' , thisString)
|
|
1064 |
].
|
|
1065 |
count := count + 1.
|
|
1066 |
(count == 20) ifTrue:[
|
|
1067 |
string := string , buffer.
|
|
1068 |
buffer := ''.
|
|
1069 |
count := 0
|
|
1070 |
].
|
|
1071 |
total := total + 1.
|
169
|
1072 |
(total > limit) ifTrue:[
|
155
|
1073 |
string := string , buffer , '... )'.
|
169
|
1074 |
^ string
|
155
|
1075 |
]
|
1
|
1076 |
].
|
|
1077 |
string := string , buffer , ')'.
|
169
|
1078 |
^ string
|
1
|
1079 |
!
|
|
1080 |
|
12
|
1081 |
displayString
|
|
1082 |
"return a printed representation of the receiver for display in inspectors etc."
|
|
1083 |
|
|
1084 |
^ self printOrDisplayStringUsing:#displayString
|
1
|
1085 |
!
|
|
1086 |
|
|
1087 |
printOn:aStream
|
88
|
1088 |
"append a user readable representation of the receiver to aStream.
|
|
1089 |
The text appended is not meant to be read back for reconstruction of
|
169
|
1090 |
the receiver. Also, this method limits the size of generated string.
|
88
|
1091 |
"
|
|
1092 |
|
169
|
1093 |
|limit firstOne string|
|
1
|
1094 |
|
44
|
1095 |
thisContext isRecursive ifTrue:[
|
155
|
1096 |
Transcript showCr:'Error: printOn: of self referencing collection.'.
|
|
1097 |
aStream nextPutAll:'#("recursive")'.
|
|
1098 |
^ self
|
44
|
1099 |
].
|
|
1100 |
|
|
1101 |
limit := self maxPrint.
|
1
|
1102 |
aStream nextPutAll:self class name.
|
|
1103 |
aStream nextPut:$(.
|
|
1104 |
firstOne := true.
|
169
|
1105 |
|
1
|
1106 |
self do:[:element |
|
169
|
1107 |
firstOne ifFalse:[
|
|
1108 |
aStream space
|
|
1109 |
] ifTrue:[
|
|
1110 |
firstOne := false
|
|
1111 |
].
|
|
1112 |
(limit <= 0) ifTrue:[
|
|
1113 |
aStream nextPutAll:'...etc...)'.
|
|
1114 |
^ self
|
|
1115 |
] ifFalse:[
|
92
|
1116 |
"/ old code, worked only on positionable streams
|
|
1117 |
"/
|
|
1118 |
"/ pos1 := aStream position.
|
|
1119 |
"/ element printOn:aStream.
|
|
1120 |
"/ limit := limit - (aStream position - pos1)
|
169
|
1121 |
|
|
1122 |
string := element printString.
|
|
1123 |
aStream nextPutAll:string.
|
|
1124 |
limit := limit - string size.
|
155
|
1125 |
].
|
1
|
1126 |
].
|
|
1127 |
aStream nextPut:$)
|
44
|
1128 |
|
88
|
1129 |
"
|
|
1130 |
#(1 2 3 'hello' $a) printOn:Transcript
|
169
|
1131 |
(Array new:100000) printOn:Transcript
|
|
1132 |
(Array new:100000) printString size
|
88
|
1133 |
(Dictionary new at:#hello put:'world'; yourself) printOn:Transcript
|
169
|
1134 |
"
|
|
1135 |
"
|
88
|
1136 |
|a|
|
|
1137 |
a := Array new:3.
|
|
1138 |
a at:2 put:a.
|
|
1139 |
a printOn:Transcript
|
|
1140 |
"
|
1
|
1141 |
!
|
|
1142 |
|
|
1143 |
storeOn:aStream
|
88
|
1144 |
"output a printed representation onto the argument, aStream.
|
|
1145 |
The text can be re-read to reconstruct (a copy of) the receiver.
|
|
1146 |
Recursive (i.e. cyclic) collections cannot be stored correctly
|
|
1147 |
(use storeBinaryOn: to handle those)."
|
1
|
1148 |
|
|
1149 |
|isEmpty|
|
|
1150 |
|
44
|
1151 |
thisContext isRecursive ifTrue:[
|
155
|
1152 |
Transcript showCr:'Error: storeOn: of self referencing collection.'.
|
293
|
1153 |
aStream nextPutAll:'#recursive'.
|
155
|
1154 |
^ self
|
44
|
1155 |
].
|
|
1156 |
|
|
1157 |
aStream nextPutAll:'('.
|
1
|
1158 |
aStream nextPutAll:(self class name).
|
44
|
1159 |
aStream nextPutAll:' new'.
|
1
|
1160 |
isEmpty := true.
|
|
1161 |
self do:[:element |
|
155
|
1162 |
aStream nextPutAll:' add:'.
|
|
1163 |
element storeOn:aStream.
|
|
1164 |
aStream nextPutAll:';'.
|
|
1165 |
isEmpty := false
|
1
|
1166 |
].
|
|
1167 |
isEmpty ifFalse:[aStream nextPutAll:' yourself'].
|
|
1168 |
aStream nextPut:$)
|
44
|
1169 |
|
88
|
1170 |
"
|
|
1171 |
OrderedCollection new storeOn:Transcript
|
|
1172 |
(1 to:10) storeOn:Transcript
|
|
1173 |
(Set new add:1; add:'hello'; yourself) storeOn:Transcript
|
|
1174 |
"
|
293
|
1175 |
"
|
|
1176 |
|s|
|
|
1177 |
|
|
1178 |
s := Set new.
|
|
1179 |
s add:1; add:'hello'; add:s.
|
|
1180 |
s storeOn:Transcript
|
|
1181 |
"
|
1
|
1182 |
! !
|