Collection.st
changeset 21647 a27784bdb210
parent 21631 b0e8d73f8f49
child 21650 61639cef6166
equal deleted inserted replaced
21646:efbec3f0a85f 21647:a27784bdb210
    12 "{ Package: 'stx:libbasic' }"
    12 "{ Package: 'stx:libbasic' }"
    13 
    13 
    14 "{ NameSpace: Smalltalk }"
    14 "{ NameSpace: Smalltalk }"
    15 
    15 
    16 Object subclass:#Collection
    16 Object subclass:#Collection
    17 	instanceVariableNames:''
    17         instanceVariableNames:''
    18 	classVariableNames:'EmptyCollectionSignal InvalidKeySignal NotEnoughElementsSignal
    18         classVariableNames:'EmptyCollectionSignal InvalidKeySignal NotEnoughElementsSignal
    19 		ValueNotFoundSignal'
    19                 ValueNotFoundSignal'
    20 	poolDictionaries:''
    20         poolDictionaries:''
    21 	category:'Collections-Abstract'
    21         category:'Collections-Abstract'
    22 !
    22 !
    23 
    23 
    24 !Collection class methodsFor:'documentation'!
    24 !Collection class methodsFor:'documentation'!
    25 
    25 
    26 copyright
    26 copyright
  2408     "
  2408     "
  2409      #(1 2 3 4 5 1 2 3 4 5) addAllTo:Set new
  2409      #(1 2 3 4 5 1 2 3 4 5) addAllTo:Set new
  2410     "
  2410     "
  2411 
  2411 
  2412     "Modified: / 11.2.2000 / 11:22:14 / cg"
  2412     "Modified: / 11.2.2000 / 11:22:14 / cg"
       
  2413 !
       
  2414 
       
  2415 and:aSecondCollection and:aThirdCollection do:aBlock
       
  2416     "evaluate the argument, aBlock for each element in the receiver,
       
  2417      then for each element in aSecondCollection, then for each in aThirdCollection."
       
  2418 
       
  2419     self do:aBlock.
       
  2420     aSecondCollection do:aBlock.
       
  2421     aThirdCollection do:aBlock.
       
  2422 
       
  2423     "
       
  2424      #(1 2 3) and: #(a b c) and: #(x y z) do:[:each | Transcript showCR:each]
       
  2425     "
       
  2426 
       
  2427     "Created: / 15-03-2017 / 18:19:34 / cg"
       
  2428 !
       
  2429 
       
  2430 and:aSecondCollection do:aBlock
       
  2431     "evaluate the argument, aBlock for each element in the receiver,
       
  2432      then for each element in aSecondCollection."
       
  2433 
       
  2434     self do:aBlock.
       
  2435     aSecondCollection do:aBlock.
       
  2436 
       
  2437     "
       
  2438      #(1 2 3) and: #(a b c) do:[:each | Transcript showCR:each]
       
  2439     "
       
  2440 
       
  2441     "Created: / 15-03-2017 / 18:19:03 / cg"
  2413 !
  2442 !
  2414 
  2443 
  2415 collect:aBlock
  2444 collect:aBlock
  2416     "for each element in the receiver, evaluate the argument, aBlock
  2445     "for each element in the receiver, evaluate the argument, aBlock
  2417      and return a new collection with the results"
  2446      and return a new collection with the results"