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 |
341 created by the compiler)" |
343 created by the compiler)" |
342 |
344 |
343 ^ self |
345 ^ self |
344 ! ! |
346 ! ! |
345 |
347 |
|
348 |
346 !Collection methodsFor:'Compatibility-ANSI'! |
349 !Collection methodsFor:'Compatibility-ANSI'! |
347 |
350 |
348 identityIncludes:anObject |
351 identityIncludes:anObject |
349 "return true, if the argument, anObject is in the collection. |
352 "return true, if the argument, anObject is in the collection. |
350 Same as #includesIdentical for Dolphin/ANSI compatibility." |
353 Same as #includesIdentical for Dolphin/ANSI compatibility." |
1424 ret := Array new:n. |
1427 ret := Array new:n. |
1425 n to:1 by:-1 do:[:i | |
1428 n to:1 by:-1 do:[:i | |
1426 ret at:i put:(self removeLast). |
1429 ret at:i put:(self removeLast). |
1427 ]. |
1430 ]. |
1428 ^ ret |
1431 ^ ret |
|
1432 ! |
|
1433 |
|
1434 testAndAdd:anElement |
|
1435 "add the argument, anObject to the receiver. |
|
1436 Answer true, if the element did already exist in the collection, |
|
1437 false otherwise. |
|
1438 |
|
1439 WARNING: do not add elements while iterating over the receiver. |
|
1440 Iterate over a copy to do this." |
|
1441 |
|
1442 (self includes:anElement) ifTrue:[ |
|
1443 ^ true. |
|
1444 ]. |
|
1445 self add:anElement. |
|
1446 ^ false. |
|
1447 |
|
1448 "Created: / 16-02-2017 / 13:41:58 / stefan" |
1429 ! ! |
1449 ! ! |
1430 |
1450 |
1431 !Collection methodsFor:'bulk operations'! |
1451 !Collection methodsFor:'bulk operations'! |
1432 |
1452 |
1433 abs |
1453 abs |
4349 aStream nextPutAll:(s contents). |
4369 aStream nextPutAll:(s contents). |
4350 ]. |
4370 ]. |
4351 aStream nextPut:$) |
4371 aStream nextPut:$) |
4352 |
4372 |
4353 " |
4373 " |
4354 #(1 2 3 'hello' $a $ü) printOn:Transcript |
4374 #(1 2 3 'hello' $a $ü) printOn:Transcript |
4355 (Array new:100000) printOn:Transcript |
4375 (Array new:100000) printOn:Transcript |
4356 (Array new:100000) printOn:Stdout |
4376 (Array new:100000) printOn:Stdout |
4357 (Array new:100000) printString size |
4377 (Array new:100000) printString size |
4358 (Dictionary new at:#hello put:'world'; |
4378 (Dictionary new at:#hello put:'world'; |
4359 at:#foo put:'bar'; yourself) printOn:Transcript |
4379 at:#foo put:'bar'; yourself) printOn:Transcript |
5706 ! |
5726 ! |
5707 |
5727 |
5708 includesAll:aCollection |
5728 includesAll:aCollection |
5709 "return true if the receiver includes all elements of |
5729 "return true if the receiver includes all elements of |
5710 the argument, aCollection; false if any is missing. |
5730 the argument, aCollection; false if any is missing. |
5711 Notice: this method has O² runtime behavior and may be |
5731 Notice: this method has O² runtime behavior and may be |
5712 slow for big receivers/args. |
5732 slow for big receivers/args. |
5713 Think about using a Set, or Dictionary." |
5733 Think about using a Set, or Dictionary." |
5714 |
5734 |
5715 ^ aCollection conform:[:element | (self includes:element)] |
5735 ^ aCollection conform:[:element | (self includes:element)] |
5716 |
5736 |
5726 includesAny:searchedElementsCollection |
5746 includesAny:searchedElementsCollection |
5727 "return true if the receiver includes any from the argument, aCollection. |
5747 "return true if the receiver includes any from the argument, aCollection. |
5728 Return false if it includes none. |
5748 Return false if it includes none. |
5729 Uses #= (value compare) |
5749 Uses #= (value compare) |
5730 Notice: |
5750 Notice: |
5731 this method has O² runtime behavior for some subclasses and may be slow for big receivers/args. |
5751 this method has O² runtime behavior for some subclasses and may be slow for big receivers/args. |
5732 Think about using a Set or Dictionary. |
5752 Think about using a Set or Dictionary. |
5733 Some speedup is also possible, by arranging highly |
5753 Some speedup is also possible, by arranging highly |
5734 probable elements towards the beginning of aCollection, to avoid useless searches. |
5754 probable elements towards the beginning of aCollection, to avoid useless searches. |
5735 |
5755 |
5736 Also: I am not sure, if (and if so, at which breakeven), |
5756 Also: I am not sure, if (and if so, at which breakeven), |
5803 includesAnyIdentical:searchedElementsCollection |
5823 includesAnyIdentical:searchedElementsCollection |
5804 "return true, if the receiver includes any from the argument, aCollection. |
5824 "return true, if the receiver includes any from the argument, aCollection. |
5805 Return false if it includes none. |
5825 Return false if it includes none. |
5806 Use identity compare for comparing. |
5826 Use identity compare for comparing. |
5807 Notice: |
5827 Notice: |
5808 this method has O² runtime behavior for some subclasses and may be slow for big receivers/args. |
5828 this method has O² runtime behavior for some subclasses and may be slow for big receivers/args. |
5809 Think about using a Set or Dictionary. |
5829 Think about using a Set or Dictionary. |
5810 Some speedup is also possible, by arranging highly |
5830 Some speedup is also possible, by arranging highly |
5811 probable elements towards the beginning of aCollection, to avoid useless searches." |
5831 probable elements towards the beginning of aCollection, to avoid useless searches." |
5812 |
5832 |
5813 searchedElementsCollection do:[:element | |
5833 searchedElementsCollection do:[:element | |