<div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000">
Hi, there.<div><br></div><div>From the client's perspective, isn't #do: already an abstraction level higher than #assocationsDo:? It is so on the implementation side, too - at least in Collection. Swapped in Dictionary and OrderedDictionary, though.</div><div><br></div><div>Collection >> associationsDo: aBlock</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>"Evaluate aBlock for each of the receiver's elements (key/value </div><div><span class="Apple-tab-span" style="white-space:pre"> </span>associations). If any non-association is within, the error is not caught now,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>but later, when a key or value message is sent to it."</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>self do: aBlock</div><div><br></div><div>Dictionary >> associationsDo: aBlock </div><div><span class="Apple-tab-span" style="white-space:pre"> </span>"Evaluate aBlock for each of the receiver's elements (key/value </div><div><span class="Apple-tab-span" style="white-space:pre"> </span>associations)."</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>tally = 0 ifTrue: [ ^self].</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>1 to: array size do: [ :index |</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>(array at: index) ifNotNil: [ :element |</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>aBlock value: element ] ]</div><div><br></div><div><div>OrderedDictionary >> associationsDo: aBlock</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>"Iterate over the order instead of the internal array."</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>order from: 1 to: tally do: aBlock</div></div><div><br></div><div>Best,</div><div>Marcel</div><div class="mb_sig"></div>
<blockquote class="history_container" type="cite" style="border-left-style: solid;border-width: 1px;margin-top: 20px;margin-left: 0px;padding-left: 10px;min-width: 500px">
<p style="color: #AAAAAA; margin-top: 10px;">Am 01.07.2019 02:47:26 schrieb Chris Muller <asqueaker@gmail.com>:</p><div style="font-family:Arial,Helvetica,sans-serif">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div dir="ltr"><div>Hi Patrick,</div><div><br></div><div>Would you be willing to employ the highest-level methods possible? "order do: [ .... ", creates an unnecessary dependency on the implementation when it appears #associationsDo: would work fine..?</div><div><br></div><div>It looks like it would put a space before the last paren. Picky, I know, but there is #do:separatedBy: to the rescue. I guess you could pre-allocate the OrderedDictionary to the proper size.</div><div><br></div><div>For the RunArray, could #runsAndValuesDo: help here? I'm having trouble following this code. At least in core code, #at:ifAbsentPut: should take a block for the second argument, IMO.</div><div><br></div><div>Best,</div><div> Chris</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 28, 2019 at 5:11 AM <<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex;border-left: 1px solid rgb(204,204,204);padding-left: 1ex;min-width: 500px">Patrick Rein uploaded a new version of Collections to project The Inbox:<br>
<a href="http://source.squeak.org/inbox/Collections-pre.838.mcz" rel="noreferrer" target="_blank">http://source.squeak.org/inbox/Collections-pre.838.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: Collections-pre.838<br>
Author: pre<br>
Time: 28 June 2019, 12:11:16.302033 pm<br>
UUID: db29f1b2-09b5-f045-aa21-9379185664df<br>
Ancestors: Collections-pre.837<br>
<br>
Two method additions to Collection. The first adds ordered printing to OrderedDictionaries, to allow users to actually see the ordering. The second adds a method to convert a run array into an expanded version of the runs.<br>
<br>
=============== Diff against Collections-pre.837 ===============<br>
<br>
Item was added:<br>
+ ----- Method: OrderedDictionary>>printElementsOn: (in category 'printing') -----<br>
+ printElementsOn: aStream <br>
+ "Based on Dictionary>>#printElementsOn:"<br>
+ <br>
+ aStream nextPut: $(.<br>
+ self size > 100<br>
+ ifTrue: [aStream nextPutAll: 'size '.<br>
+ self size printOn: aStream]<br>
+ ifFalse: [order do: [:assoc | assoc ifNotNil: [<br>
+ assoc printOn: aStream. aStream space]]].<br>
+ aStream nextPut: $)!<br>
<br>
Item was added:<br>
+ ----- Method: RunArray>>asValuesAndIntervals (in category 'converting') -----<br>
+ asValuesAndIntervals<br>
+ <br>
+ | interval result |<br>
+ result := OrderedDictionary new.<br>
+ 1 to: self size do: [:i |<br>
+ (self at: i) do: [:value |<br>
+ interval := result at: value ifAbsentPut: (i to: i).<br>
+ result at: value put: (interval start to: i)]].<br>
+ ^ result<br>
+ !<br>
<br><br></blockquote></div></div>
</div></blockquote></div>