SequenceableCollection.st
changeset 13469 7f911a9f891d
parent 13465 35721e64ac25
child 13697 6e9de7dc94bc
equal deleted inserted replaced
13468:7a4e15f44afe 13469:7f911a9f891d
  4652 
  4652 
  4653 with:aSequenceableCollection do:aTwoArgBlock
  4653 with:aSequenceableCollection do:aTwoArgBlock
  4654     "evaluate the argument, aBlock for successive elements from
  4654     "evaluate the argument, aBlock for successive elements from
  4655      each the receiver and the argument, aSequenceableCollection.
  4655      each the receiver and the argument, aSequenceableCollection.
  4656      The second argument, aBlock must be a two-argument block.
  4656      The second argument, aBlock must be a two-argument block.
  4657      The collection argument must implement access via a numeric key and
  4657      The collection argument must implement access via a numeric key 
  4658      the sizes must be the same."
  4658      and (new!!) the sizes must be the same."
  4659 
  4659 
  4660     |stop  "{ Class: SmallInteger }" |
  4660     |stop  "{ Class: SmallInteger }" |
  4661 
  4661 
  4662     stop := self size.
  4662     stop := self size.
  4663     aSequenceableCollection size == stop ifFalse:[
  4663     aSequenceableCollection size == stop ifFalse:[
  4664         ^ self error:'collections must be of the same size'.
  4664         NotEnoughElementsSignal raiseRequestErrorString:'collections must be of the same size'.
  4665     ].
  4665     ].
       
  4666 
  4666     1 to:stop do:[:index |
  4667     1 to:stop do:[:index |
  4667         aTwoArgBlock value:(self at:index) value:(aSequenceableCollection at:index).
  4668         aTwoArgBlock value:(self at:index) value:(aSequenceableCollection at:index).
  4668     ]
  4669     ]
  4669 
  4670 
  4670     "
  4671     "
  4671      #(one two three four five six)
  4672      #(one two three four five six)
  4672         with:(1 to:10)
  4673         with:(1 to:10)
  4673         do:[:el1 :el2 | Transcript show:el1; space; showCR:el2]
  4674         do:[:el1 :el2 | Transcript show:el1; space; showCR:el2]
  4674     "
  4675     "
  4675 
  4676 
  4676     "Modified: / 30-06-2011 / 12:40:04 / cg"
  4677     "Modified (Format): / 30-06-2011 / 17:39:59 / cg"
  4677 !
  4678 !
  4678 
  4679 
  4679 with:aSequenceableCollection doWithIndex:aThreeArgBlock
  4680 with:aSequenceableCollection doWithIndex:aThreeArgBlock
  4680     "evaluate the argument, aBlock for successive elements from
  4681     "evaluate the argument, aBlock for successive elements from
  4681      each the receiver and the argument, aSequenceableCollection.
  4682      each the receiver and the argument, aSequenceableCollection.
  7895 ! !
  7896 ! !
  7896 
  7897 
  7897 !SequenceableCollection class methodsFor:'documentation'!
  7898 !SequenceableCollection class methodsFor:'documentation'!
  7898 
  7899 
  7899 version_CVS
  7900 version_CVS
  7900     ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.305 2011-06-30 10:41:09 cg Exp $'
  7901     ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.306 2011-06-30 15:40:20 cg Exp $'
  7901 ! !
  7902 ! !
  7902 
  7903 
  7903 SequenceableCollection initialize!
  7904 SequenceableCollection initialize!