[squeak-dev] The Inbox: Collections-pre.838.mcz
asqueaker at gmail.com
Mon Jul 1 00:46:39 UTC 2019
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..?
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.
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.
On Fri, Jun 28, 2019 at 5:11 AM <commits at source.squeak.org> wrote:
> Patrick Rein uploaded a new version of Collections to project The Inbox:
> ==================== Summary ====================
> Name: Collections-pre.838
> Author: pre
> Time: 28 June 2019, 12:11:16.302033 pm
> UUID: db29f1b2-09b5-f045-aa21-9379185664df
> Ancestors: Collections-pre.837
> 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
> =============== Diff against Collections-pre.837 ===============
> Item was added:
> + ----- Method: OrderedDictionary>>printElementsOn: (in category
> 'printing') -----
> + printElementsOn: aStream
> + "Based on Dictionary>>#printElementsOn:"
> + aStream nextPut: $(.
> + self size > 100
> + ifTrue: [aStream nextPutAll: 'size '.
> + self size printOn: aStream]
> + ifFalse: [order do: [:assoc | assoc ifNotNil: [
> + assoc printOn: aStream. aStream
> + aStream nextPut: $)!
> Item was added:
> + ----- Method: RunArray>>asValuesAndIntervals (in category 'converting')
> + asValuesAndIntervals
> + | interval result |
> + result := OrderedDictionary new.
> + 1 to: self size do: [:i |
> + (self at: i) do: [:value |
> + interval := result at: value ifAbsentPut: (i to:
> + result at: value put: (interval start to: i)]].
> + ^ result
> + !
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev