<div dir="ltr"><div dir="ltr"></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div id="gmail-m_-6297668493763618414__MailbirdStyleContent" style="font-size:10pt;font-family:Arial;color:rgb(0,0,0)"><br>Hi, there.<div><br></div><div>From the client's perspective, isn't #do: already an abstraction level higher than #assocationsDo:? </div></div></blockquote><div><br></div><div>Not when one accounts for the receiver.  </div><div><br></div><div>    order do: [ ... ]</div><div><br></div><div>has to make assumptions about the internal representation, and it duplicates the responsibility for enumerating the receiver just to do some broader function (printing elements), even though the receiver already has a method to do that enumeration.</div><div><br></div><div>   self associationsDo: [ ... ]<br></div><div><br></div><div>Best,</div><div>  Chris</div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div id="gmail-m_-6297668493763618414__MailbirdStyleContent" style="font-size:10pt;font-family:Arial;color:rgb(0,0,0)"><div>It is so on the implementation side, too - at least in Collection. Swapped in Dictionary and OrderedDictionary, though.</div></div></blockquote><div><br></div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div id="gmail-m_-6297668493763618414__MailbirdStyleContent" style="font-size:10pt;font-family:Arial;color:rgb(0,0,0)"><div><br></div><div>Collection >> associationsDo: aBlock</div><div><span class="gmail-m_-6297668493763618414Apple-tab-span" style="white-space:pre-wrap">       </span>"Evaluate aBlock for each of the receiver's elements (key/value </div><div><span class="gmail-m_-6297668493763618414Apple-tab-span" style="white-space:pre-wrap">  </span>associations).  If any non-association is within, the error is not caught now,</div><div><span class="gmail-m_-6297668493763618414Apple-tab-span" style="white-space:pre-wrap">     </span>but later, when a key or value message is sent to it."</div><div><br></div><div><span class="gmail-m_-6297668493763618414Apple-tab-span" style="white-space:pre-wrap">        </span>self do: aBlock</div><div><br></div><div>Dictionary >> associationsDo: aBlock </div><div><span class="gmail-m_-6297668493763618414Apple-tab-span" style="white-space:pre-wrap">        </span>"Evaluate aBlock for each of the receiver's elements (key/value </div><div><span class="gmail-m_-6297668493763618414Apple-tab-span" style="white-space:pre-wrap">  </span>associations)."</div><div><br></div><div><span class="gmail-m_-6297668493763618414Apple-tab-span" style="white-space:pre-wrap">       </span>tally = 0 ifTrue: [ ^self].</div><div><span class="gmail-m_-6297668493763618414Apple-tab-span" style="white-space:pre-wrap"> </span>1 to: array size do: [ :index |</div><div><span class="gmail-m_-6297668493763618414Apple-tab-span" style="white-space:pre-wrap">             </span>(array at: index) ifNotNil: [ :element |</div><div><span class="gmail-m_-6297668493763618414Apple-tab-span" style="white-space:pre-wrap">                    </span>aBlock value: element ] ]</div><div><br></div><div><div>OrderedDictionary >> associationsDo: aBlock</div><div><span class="gmail-m_-6297668493763618414Apple-tab-span" style="white-space:pre-wrap">       </span>"Iterate over the order instead of the internal array."</div><div><br></div><div><span class="gmail-m_-6297668493763618414Apple-tab-span" style="white-space:pre-wrap">  </span>order from: 1 to: tally do: aBlock</div></div><div><br></div><div>Best,</div><div>Marcel</div><div class="gmail-m_-6297668493763618414mb_sig"></div>
                                        
                                        <blockquote class="gmail-m_-6297668493763618414history_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:rgb(170,170,170);margin-top:10px">Am 01.07.2019 02:47:26 schrieb Chris Muller <<a href="mailto:asqueaker@gmail.com" target="_blank">asqueaker@gmail.com</a>>:</p><div style="font-family:Arial,Helvetica,sans-serif">
<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><br>
</blockquote></div></div>