equal
deleted
inserted
replaced
|
1 "{ Encoding: utf8 }" |
|
2 |
1 " |
3 " |
2 COPYRIGHT (c) 1989 by Claus Gittinger |
4 COPYRIGHT (c) 1989 by Claus Gittinger |
3 All Rights Reserved |
5 All Rights Reserved |
4 |
6 |
5 This software is furnished under a license and may be used |
7 This software is furnished under a license and may be used |
271 Kludges around the stupid definition of OrderedCollection>>new:" |
273 Kludges around the stupid definition of OrderedCollection>>new:" |
272 |
274 |
273 ^ self newWithSize:n |
275 ^ self newWithSize:n |
274 ! ! |
276 ! ! |
275 |
277 |
276 |
|
277 !Collection class methodsFor:'Signal constants'! |
278 !Collection class methodsFor:'Signal constants'! |
278 |
279 |
279 emptyCollectionSignal |
280 emptyCollectionSignal |
280 "return the signal used to report non-allowed operation on empty collections" |
281 "return the signal used to report non-allowed operation on empty collections" |
281 |
282 |
331 "Return if this class is an abstract class. |
332 "Return if this class is an abstract class. |
332 True is returned for Collection here; false for subclasses. |
333 True is returned for Collection here; false for subclasses. |
333 Abstract subclasses must redefine this again." |
334 Abstract subclasses must redefine this again." |
334 |
335 |
335 ^ self == Collection |
336 ^ self == Collection |
|
337 ! |
|
338 |
|
339 mutableClass |
|
340 "Return a version of me with mutable instances. |
|
341 Only redefined in the immutable collections (of which instances are |
|
342 created by the compiler)" |
|
343 |
|
344 ^ self |
336 ! ! |
345 ! ! |
337 |
346 |
338 !Collection methodsFor:'Compatibility-ANSI'! |
347 !Collection methodsFor:'Compatibility-ANSI'! |
339 |
348 |
340 identityIncludes:anObject |
349 identityIncludes:anObject |
537 |
546 |
538 ^ self intersect:aCollection |
547 ^ self intersect:aCollection |
539 |
548 |
540 "Created: / 22-10-2008 / 21:29:27 / cg" |
549 "Created: / 22-10-2008 / 21:29:27 / cg" |
541 ! ! |
550 ! ! |
542 |
|
543 |
551 |
544 !Collection methodsFor:'accessing'! |
552 !Collection methodsFor:'accessing'! |
545 |
553 |
546 anElement |
554 anElement |
547 "return any element from the collection, |
555 "return any element from the collection, |
4331 aStream nextPutAll:(s contents). |
4339 aStream nextPutAll:(s contents). |
4332 ]. |
4340 ]. |
4333 aStream nextPut:$) |
4341 aStream nextPut:$) |
4334 |
4342 |
4335 " |
4343 " |
4336 #(1 2 3 'hello' $a $ü) printOn:Transcript |
4344 #(1 2 3 'hello' $a $ü) printOn:Transcript |
4337 (Array new:100000) printOn:Transcript |
4345 (Array new:100000) printOn:Transcript |
4338 (Array new:100000) printOn:Stdout |
4346 (Array new:100000) printOn:Stdout |
4339 (Array new:100000) printString size |
4347 (Array new:100000) printString size |
4340 (Dictionary new at:#hello put:'world'; |
4348 (Dictionary new at:#hello put:'world'; |
4341 at:#foo put:'bar'; yourself) printOn:Transcript |
4349 at:#foo put:'bar'; yourself) printOn:Transcript |
5685 ! |
5693 ! |
5686 |
5694 |
5687 includesAll:aCollection |
5695 includesAll:aCollection |
5688 "return true if the receiver includes all elements of |
5696 "return true if the receiver includes all elements of |
5689 the argument, aCollection; false if any is missing. |
5697 the argument, aCollection; false if any is missing. |
5690 Notice: this method has O² runtime behavior and may be |
5698 Notice: this method has O² runtime behavior and may be |
5691 slow for big receivers/args. |
5699 slow for big receivers/args. |
5692 Think about using a Set, or Dictionary." |
5700 Think about using a Set, or Dictionary." |
5693 |
5701 |
5694 ^ aCollection conform:[:element | (self includes:element)] |
5702 ^ aCollection conform:[:element | (self includes:element)] |
5695 |
5703 |
5705 includesAny:searchedElementsCollection |
5713 includesAny:searchedElementsCollection |
5706 "return true if the receiver includes any from the argument, aCollection. |
5714 "return true if the receiver includes any from the argument, aCollection. |
5707 Return false if it includes none. |
5715 Return false if it includes none. |
5708 Uses #= (value compare) |
5716 Uses #= (value compare) |
5709 Notice: |
5717 Notice: |
5710 this method has O² runtime behavior for some subclasses and may be slow for big receivers/args. |
5718 this method has O² runtime behavior for some subclasses and may be slow for big receivers/args. |
5711 Think about using a Set or Dictionary. |
5719 Think about using a Set or Dictionary. |
5712 Some speedup is also possible, by arranging highly |
5720 Some speedup is also possible, by arranging highly |
5713 probable elements towards the beginning of aCollection, to avoid useless searches. |
5721 probable elements towards the beginning of aCollection, to avoid useless searches. |
5714 |
5722 |
5715 Also: I am not sure, if (and if so, at which breakeven), |
5723 Also: I am not sure, if (and if so, at which breakeven), |
5775 includesAnyIdentical:searchedElementsCollection |
5783 includesAnyIdentical:searchedElementsCollection |
5776 "return true, if the receiver includes any from the argument, aCollection. |
5784 "return true, if the receiver includes any from the argument, aCollection. |
5777 Return false if it includes none. |
5785 Return false if it includes none. |
5778 Use identity compare for comparing. |
5786 Use identity compare for comparing. |
5779 Notice: |
5787 Notice: |
5780 this method has O² runtime behavior for some subclasses and may be slow for big receivers/args. |
5788 this method has O² runtime behavior for some subclasses and may be slow for big receivers/args. |
5781 Think about using a Set or Dictionary. |
5789 Think about using a Set or Dictionary. |
5782 Some speedup is also possible, by arranging highly |
5790 Some speedup is also possible, by arranging highly |
5783 probable elements towards the beginning of aCollection, to avoid useless searches." |
5791 probable elements towards the beginning of aCollection, to avoid useless searches." |
5784 |
5792 |
5785 searchedElementsCollection do:[:element | |
5793 searchedElementsCollection do:[:element | |
5991 "dispatch for visitor pattern; send #visitCollection:with: to aVisitor" |
5999 "dispatch for visitor pattern; send #visitCollection:with: to aVisitor" |
5992 |
6000 |
5993 ^ aVisitor visitCollection:self with:aParameter |
6001 ^ aVisitor visitCollection:self with:aParameter |
5994 ! ! |
6002 ! ! |
5995 |
6003 |
5996 |
|
5997 !Collection class methodsFor:'documentation'! |
6004 !Collection class methodsFor:'documentation'! |
5998 |
6005 |
5999 version |
6006 version |
6000 ^ '$Header$' |
6007 ^ '$Header$' |
6001 ! |
6008 ! |