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 |
13 |
15 |
14 "{ NameSpace: Smalltalk }" |
16 "{ NameSpace: Smalltalk }" |
15 |
17 |
16 Object subclass:#Collection |
18 Object subclass:#Collection |
17 instanceVariableNames:'' |
19 instanceVariableNames:'' |
18 classVariableNames:'InvalidKeySignal EmptyCollectionSignal ValueNotFoundSignal |
20 classVariableNames:'EmptyCollectionSignal InvalidKeySignal NotEnoughElementsSignal |
19 NotEnoughElementsSignal' |
21 ValueNotFoundSignal' |
20 poolDictionaries:'' |
22 poolDictionaries:'' |
21 category:'Collections-Abstract' |
23 category:'Collections-Abstract' |
22 ! |
24 ! |
23 |
25 |
24 !Collection class methodsFor:'documentation'! |
26 !Collection class methodsFor:'documentation'! |
4331 aStream nextPutAll:(s contents). |
4333 aStream nextPutAll:(s contents). |
4332 ]. |
4334 ]. |
4333 aStream nextPut:$) |
4335 aStream nextPut:$) |
4334 |
4336 |
4335 " |
4337 " |
4336 #(1 2 3 'hello' $a $ü) printOn:Transcript |
4338 #(1 2 3 'hello' $a $ü) printOn:Transcript |
4337 (Array new:100000) printOn:Transcript |
4339 (Array new:100000) printOn:Transcript |
4338 (Array new:100000) printOn:Stdout |
4340 (Array new:100000) printOn:Stdout |
4339 (Array new:100000) printString size |
4341 (Array new:100000) printString size |
4340 (Dictionary new at:#hello put:'world'; |
4342 (Dictionary new at:#hello put:'world'; |
4341 at:#foo put:'bar'; yourself) printOn:Transcript |
4343 at:#foo put:'bar'; yourself) printOn:Transcript |
4439 "true if this is a readOnly (immutable) collection. |
4441 "true if this is a readOnly (immutable) collection. |
4440 Q1: should this be called isImmutable? |
4442 Q1: should this be called isImmutable? |
4441 Q2: who uses this?" |
4443 Q2: who uses this?" |
4442 |
4444 |
4443 ^ false |
4445 ^ false |
|
4446 ! |
|
4447 |
|
4448 isValidElement:anObject |
|
4449 "return true, if I can hold this kind of object" |
|
4450 |
|
4451 "/ here, true is returned for any. |
|
4452 "/ nust be redefined in subclasses which do nt allow some (i.e. ByteArray) |
|
4453 ^ true |
4444 ! |
4454 ! |
4445 |
4455 |
4446 isWritable |
4456 isWritable |
4447 "true if this is not a readOnly (immutable) collection. |
4457 "true if this is not a readOnly (immutable) collection. |
4448 Q1: should this be called isMutable? |
4458 Q1: should this be called isMutable? |
5677 ! |
5687 ! |
5678 |
5688 |
5679 includesAll:aCollection |
5689 includesAll:aCollection |
5680 "return true if the receiver includes all elements of |
5690 "return true if the receiver includes all elements of |
5681 the argument, aCollection; false if any is missing. |
5691 the argument, aCollection; false if any is missing. |
5682 Notice: this method has O² runtime behavior and may be |
5692 Notice: this method has O² runtime behavior and may be |
5683 slow for big receivers/args. |
5693 slow for big receivers/args. |
5684 Think about using a Set, or Dictionary." |
5694 Think about using a Set, or Dictionary." |
5685 |
5695 |
5686 ^ aCollection conform:[:element | (self includes:element)] |
5696 ^ aCollection conform:[:element | (self includes:element)] |
5687 |
5697 |
5697 includesAny:searchedElementsCollection |
5707 includesAny:searchedElementsCollection |
5698 "return true if the receiver includes any from the argument, aCollection. |
5708 "return true if the receiver includes any from the argument, aCollection. |
5699 Return false if it includes none. |
5709 Return false if it includes none. |
5700 Uses #= (value compare) |
5710 Uses #= (value compare) |
5701 Notice: |
5711 Notice: |
5702 this method has O² runtime behavior for some subclasses and may be slow for big receivers/args. |
5712 this method has O² runtime behavior for some subclasses and may be slow for big receivers/args. |
5703 Think about using a Set or Dictionary. |
5713 Think about using a Set or Dictionary. |
5704 Some speedup is also possible, by arranging highly |
5714 Some speedup is also possible, by arranging highly |
5705 probable elements towards the beginning of aCollection, to avoid useless searches. |
5715 probable elements towards the beginning of aCollection, to avoid useless searches. |
5706 |
5716 |
5707 Also: I am not sure, if (and if so, at which breakeven), |
5717 Also: I am not sure, if (and if so, at which breakeven), |
5767 includesAnyIdentical:searchedElementsCollection |
5777 includesAnyIdentical:searchedElementsCollection |
5768 "return true, if the receiver includes any from the argument, aCollection. |
5778 "return true, if the receiver includes any from the argument, aCollection. |
5769 Return false if it includes none. |
5779 Return false if it includes none. |
5770 Use identity compare for comparing. |
5780 Use identity compare for comparing. |
5771 Notice: |
5781 Notice: |
5772 this method has O² runtime behavior for some subclasses and may be slow for big receivers/args. |
5782 this method has O² runtime behavior for some subclasses and may be slow for big receivers/args. |
5773 Think about using a Set or Dictionary. |
5783 Think about using a Set or Dictionary. |
5774 Some speedup is also possible, by arranging highly |
5784 Some speedup is also possible, by arranging highly |
5775 probable elements towards the beginning of aCollection, to avoid useless searches." |
5785 probable elements towards the beginning of aCollection, to avoid useless searches." |
5776 |
5786 |
5777 searchedElementsCollection do:[:element | |
5787 searchedElementsCollection do:[:element | |