Collection.st
changeset 16172 68c4859fc136
parent 16075 4a15dc058fbe
child 16178 af76f92e5d7f
equal deleted inserted replaced
16171:886b698e5f10 16172:68c4859fc136
   257      Kludges around the stupid definition of OrderedCollection>>new:"
   257      Kludges around the stupid definition of OrderedCollection>>new:"
   258 
   258 
   259     ^ self withSize:n
   259     ^ self withSize:n
   260 ! !
   260 ! !
   261 
   261 
       
   262 
   262 !Collection class methodsFor:'Signal constants'!
   263 !Collection class methodsFor:'Signal constants'!
   263 
   264 
   264 emptyCollectionSignal
   265 emptyCollectionSignal
   265     "return the signal used to report non-allowed operation on empty collections"
   266     "return the signal used to report non-allowed operation on empty collections"
   266 
   267 
   414     "
   415     "
   415 !
   416 !
   416 
   417 
   417 gather:aBlock
   418 gather:aBlock
   418     "return an Array,
   419     "return an Array,
   419      containing all elements as returned from applying aBlock to each element if the receiver,
   420      containing all elements as returned from applying aBlock to each element of the receiver,
   420      where the block returns a collection of to-be-added elements.
   421      where the block returns a collection of to-be-added elements.
   421      This could also be called: collectAllAsArray:"
   422      This could also be called: collectAllAsArray:"
   422 
   423 
   423     ^ self gather:aBlock as:Array
   424     ^ self gather:aBlock as:Array
   424 
   425 
   427     "
   428     "
   428 !
   429 !
   429 
   430 
   430 gather:aBlock as:aClass
   431 gather:aBlock as:aClass
   431     "return an instance of the collection-class aClass,
   432     "return an instance of the collection-class aClass,
   432      containing all elements as returned from applying aBlock to each element if the receiver.
   433      containing all elements as returned from applying aBlock to each element of the receiver.
   433      where the block returns a collection of to-be-added elements.
   434      where the block returns a collection of to-be-added elements.
   434      This could also be called: collectAll:as:"
   435      This could also be called: collectAll:as:"
   435 
   436 
   436     ^ aClass streamContents:[:s |
   437     ^ aClass streamContents:[:s |
   437         self do: [:ea | s nextPutAll: (aBlock value: ea)]
   438         self do: [:ea | s nextPutAll: (aBlock value: ea)]
   527 
   528 
   528     ^ self keysAndValuesDo:[:key :index |
   529     ^ self keysAndValuesDo:[:key :index |
   529         aTwoArgBlock value:index value:key
   530         aTwoArgBlock value:index value:key
   530     ].
   531     ].
   531 ! !
   532 ! !
       
   533 
   532 
   534 
   533 !Collection methodsFor:'accessing'!
   535 !Collection methodsFor:'accessing'!
   534 
   536 
   535 anElement
   537 anElement
   536     "return any element from the collection, 
   538     "return any element from the collection, 
  5425 ! !
  5427 ! !
  5426 
  5428 
  5427 !Collection class methodsFor:'documentation'!
  5429 !Collection class methodsFor:'documentation'!
  5428 
  5430 
  5429 version
  5431 version
  5430     ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.329 2014-02-19 16:08:19 cg Exp $'
  5432     ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.330 2014-03-01 13:41:07 cg Exp $'
  5431 !
  5433 !
  5432 
  5434 
  5433 version_CVS
  5435 version_CVS
  5434     ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.329 2014-02-19 16:08:19 cg Exp $'
  5436     ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.330 2014-03-01 13:41:07 cg Exp $'
  5435 ! !
  5437 ! !
  5436 
  5438 
  5437 
  5439 
  5438 Collection initialize!
  5440 Collection initialize!