<div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000;text-align: left" dir="ltr">
                                        Hi Christoph --<div><br></div><div>I have to agree with Dave. Can we find a threshold when it makes sense to show the counts of each element? Maybe drop the "1" entirely and only show "->n" for n > 1? Maybe don't use "->" but parentheses? And maybe check with objects that have a more complex printString on their own. Hmm...</div><div><br></div><div>aBag(10@10 (2) 20@20 (3) ...)</div><div><br></div><div>(Also make sure that the printString is kind of as fast as before. Thanks.)</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 26.02.2022 23:08:06 schrieb David T. Lewis <lewis@mail.msen.com>:</p><div style="font-family:Arial,Helvetica,sans-serif">This seems easier to read for the case of a Bag containing<br>many copies of the same entry, and harder to read for the<br>case of a Bag containing mostly different entries. I am not<br>sure which is the more common scenario.<br><br>The original printString hides the implementation, which seems<br>like a good thing.<br><br>Either approach would be fine for me, although I think I slightly<br>prefer the original version.<br><br>Dave<br><br>On Sat, Feb 26, 2022 at 08:49:48PM +0100, christoph.thiede@student.hpi.uni-potsdam.de wrote:<br>> =============== Summary ===============<br>> <br>> Change Set:????????Bag printString<br>> Date:????????????26 February 2022<br>> Author:????????????Christoph Thiede<br>> <br>> This changeset customizes the Bag printString to no longer emit every occurence of each element repeatedly.<br>> <br>> Example:<br>> ????{10 @ 10. 10 @ 10. 20 @ 20. 20 @ 20. 20 @ 20. 30 @ 30. 30 @ 30. 40 @ 40} asBag. 'a Bag(10@10->2 20@20->3 30@30->2 40@40->1)'.<br>> <br>> Thanks to Robert (rhi) for the hint!<br>> <br>> =============== Diff ===============<br>> <br>> Bag>>printElementsOn: {printing} ? ct 2/26/2022 20:26<br>> + printElementsOn: aStream<br>> + <br>> + ????contents printElementsOn: aStream.<br>> <br>> BagTest>>testPrintString {tests} ? ct 2/26/2022 20:25<br>> + testPrintString<br>> + <br>> + ????| bag |<br>> + ????bag := Bag new.<br>> + ????bag add: '1' withOccurrences: 5.<br>> + ????bag add: '2' withOccurrences: 1.<br>> + ????bag add: '3' withOccurrences: 3.<br>> + ????<br>> + ????self assert: 'a Bag(''1''->5 ''2''->1 ''3''->3)' equals: bag printString.<br>> <br>> Dictionary>>printElementsOn: {printing} ? ct 2/26/2022 20:28 (changed)<br>> printElementsOn: aStream <br>> ????aStream nextPut: $(.<br>> ????self size > 100<br>> ????????ifTrue: [aStream nextPutAll: 'size '.<br>> ????????????self size printOn: aStream]<br>> ????????ifFalse: [self keysInOrder<br>> ????????????????do: [:key | aStream print: key;<br>> ???????????????????????? nextPutAll: '->';????????????????<br>> - ???????????????????????? print: (self at: key);<br>> - ???????????????????????? space]].<br>> + ???????????????????????? print: (self at: key)]<br>> + ????????????????separatedBy: [aStream space]].<br>> ????aStream nextPut: $)<br>> <br>> ---<br>> Sent from Squeak Inbox Talk<br>> ["Bag printString.1.cs"]<br><br>> <br><br><br></div></blockquote></div>