3664 "evaluate the argument, aBlock for every element in the collection, |
3664 "evaluate the argument, aBlock for every element in the collection, |
3665 passing both index and element as arguments. |
3665 passing both index and element as arguments. |
3666 Blocked here - must be redefined in subclasses which have keyed elements" |
3666 Blocked here - must be redefined in subclasses which have keyed elements" |
3667 |
3667 |
3668 ^ self errorNotKeyed |
3668 ^ self errorNotKeyed |
|
3669 ! |
|
3670 |
|
3671 keysAndValuesDo:aTwoArgBlock separatedBy:sepBlock |
|
3672 "evaluate the argument, aBlock for every element in the collection, |
|
3673 passing both index/key and element as arguments. |
|
3674 Between elements, evaluate aBlock (but not before the first)." |
|
3675 |
|
3676 |first| |
|
3677 |
|
3678 first := true. |
|
3679 self keysAndValuesDo:[:k :v | |
|
3680 first ifFalse:[ |
|
3681 sepBlock value. |
|
3682 ]. |
|
3683 first := false. |
|
3684 aTwoArgBlock value:k value:v |
|
3685 ]. |
|
3686 |
|
3687 " |
|
3688 |d| |
|
3689 d := OrderedDictionary withKeysAndValues:#('one' 1 'two' 2 'three' 3 'four' 4). |
|
3690 |
|
3691 d keysAndValuesDo:[:k :v | Transcript showCR:'%1 -> %2' with:k with:v] |
|
3692 separatedBy:[Transcript showCR:'====']. |
|
3693 |
|
3694 Transcript cr;cr. |
|
3695 d keysAndValuesDo:[:k :v | Transcript showCR:'%1 -> %2' with:k with:v]. |
|
3696 " |
|
3697 |
|
3698 "Created: / 25-05-2019 / 10:07:54 / Claus Gittinger" |
|
3699 "Modified (comment): / 25-05-2019 / 11:17:34 / Claus Gittinger" |
3669 ! |
3700 ! |
3670 |
3701 |
3671 keysAndValuesReverseDo:aTwoArgBlock |
3702 keysAndValuesReverseDo:aTwoArgBlock |
3672 "evaluate the argument, aBlock in reverse order for every element in the collection, |
3703 "evaluate the argument, aBlock in reverse order for every element in the collection, |
3673 passing both index and element as arguments. |
3704 passing both index and element as arguments. |