The Trunk: Collections-cmm.404.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Collections-cmm.404.mcz

commits-2
Chris Muller uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-cmm.404.mcz

==================== Summary ====================

Name: Collections-cmm.404
Author: cmm
Time: 11 November 2010, 11:08:07.979 am
UUID: f4fd12e0-266e-4e95-a4ac-b2064707494c
Ancestors: Collections-ul.403

Introduced WeakOrderedCollection.

=============== Diff against Collections-ul.403 ===============

Item was added:
+ ----- Method: OrderedCollection class>>arrayType (in category 'private') -----
+ arrayType
+ ^ Array!

Item was changed:
  ----- Method: OrderedCollection class>>new: (in category 'instance creation') -----
  new: anInteger
+ ^ self basicNew setCollection: (self arrayType new: anInteger)!
- ^ self basicNew setCollection: (Array new: anInteger)!

Item was changed:
  ----- Method: OrderedCollection class>>new:withAll: (in category 'instance creation') -----
  new: anInteger withAll: anObject
+ ^ self basicNew setContents: (self arrayType new: anInteger withAll: anObject)!
- ^ self basicNew setContents: (Array new: anInteger withAll: anObject)!

Item was changed:
  ----- Method: OrderedCollection>>growAtFirst (in category 'private') -----
  growAtFirst
  "Add new empty slots to the front of array, while keeping the empty slots at the end."
 
  | newArray newFirstIndex newLastIndex |
+ newArray := self class arrayType new: (array size * 2 max: 1).
- newArray := Array new: (array size * 2 max: 1).
  newFirstIndex := newArray size - array size + firstIndex.
  newLastIndex := newFirstIndex + lastIndex - firstIndex.
  newArray
  replaceFrom: newFirstIndex
  to: newLastIndex
  with: array
  startingAt: firstIndex.
  array := newArray.
  firstIndex := newFirstIndex.
  lastIndex := newLastIndex!

Item was changed:
  ----- Method: OrderedCollection>>growAtLast (in category 'private') -----
  growAtLast
  "Add new empty slots to the end of array, while keeping the empty slots at the front."
 
  | newArray |
+ newArray := self class arrayType new: (array size * 2 max: 1).
- newArray := Array new: (array size * 2 max: 1).
  newArray
  replaceFrom: firstIndex
  to: lastIndex
  with: array
  startingAt: firstIndex.
  array := newArray!

Item was changed:
  ----- Method: OrderedCollection>>removeAll (in category 'removing') -----
  removeAll
  "remove all the elements from this collection.
  Keep same amount of storage"
 
+ self setCollection: (self class arrayType new: array size)!
- self setCollection: (Array new: array size)!

Item was changed:
  ----- Method: OrderedCollection>>removeFirst: (in category 'removing') -----
+ removeFirst: n
- removeFirst: n
  "Remove first n object into an array"
-
  | list |
+ list := self class arrayType new: n.
+ 1
+ to: n
+ do:
+ [ : i | list
+ at: i
+ put: self removeFirst ].
- list := Array new: n.
- 1 to: n do: [:i |
- list at: i put: self removeFirst].
  ^ list!

Item was changed:
  ----- Method: OrderedCollection>>removeLast: (in category 'removing') -----
+ removeLast: n
- removeLast: n
  "Remove last n object into an array with last in last position"
-
  | list |
+ list := self class arrayType new: n.
+ n
+ to: 1
+ by: -1
+ do:
+ [ : i | list
+ at: i
+ put: self removeLast ].
- list := Array new: n.
- n to: 1 by: -1 do: [:i |
- list at: i put: self removeLast].
  ^ list!

Item was added:
+ OrderedCollection subclass: #WeakOrderedCollection
+ instanceVariableNames: ''
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'Collections-Sequenceable'!

Item was added:
+ ----- Method: WeakOrderedCollection classSide>>arrayType (in category 'as yet unclassified') -----
+ arrayType
+ ^ WeakArray!

Item was added:
+ ----- Method: WeakOrderedCollection classSide>>new: (in category 'as yet unclassified') -----
+ new: anInteger
+ ^ self basicNew setCollection: (WeakArray new: anInteger)!

Item was added:
+ ----- Method: WeakOrderedCollection classSide>>new:withAll: (in category 'as yet unclassified') -----
+ new: anInteger withAll: anObject
+ ^ self basicNew setContents: (WeakArray new: anInteger withAll: anObject)!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-cmm.404.mcz

Levente Uzonyi-2
On Thu, 11 Nov 2010, [hidden email] wrote:

> Chris Muller uploaded a new version of Collections to project The Trunk:
> http://source.squeak.org/trunk/Collections-cmm.404.mcz
>
> ==================== Summary ====================
>
> Name: Collections-cmm.404
> Author: cmm
> Time: 11 November 2010, 11:08:07.979 am
> UUID: f4fd12e0-266e-4e95-a4ac-b2064707494c
> Ancestors: Collections-ul.403
>
> Introduced WeakOrderedCollection.

There are two unnecessary methods: WeakOrderedCollection >> #new: and
WeakOrderedCollection >> #new:withAll:.

Shouldn't WeakOrderedCollection be in the Collections-Weak category like
all other weak collections?

Are you using the prettyprinter to format the methods? Some of your
changes (#to:do: #to:by:do:) take a lot more time for me to understand in
this format. And it reminds me to what the prettyprinter does.


Levente

snip

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-cmm.404.mcz

Chris Muller-3
Thanks for reviewing.

Sorry you don't like the formatting, you are welcome to change it to
your preference.  I do use a pretty print enhanced to employ the
Rectangular-Block formatting pattern (which, IIRC, does actually make
an exception for Integer>>#to:by:do:, but this printer is not
sophisticated enough to make that exception, sorry)..


On Thu, Nov 11, 2010 at 11:21 AM, Levente Uzonyi <[hidden email]> wrote:

> On Thu, 11 Nov 2010, [hidden email] wrote:
>
>> Chris Muller uploaded a new version of Collections to project The Trunk:
>> http://source.squeak.org/trunk/Collections-cmm.404.mcz
>>
>> ==================== Summary ====================
>>
>> Name: Collections-cmm.404
>> Author: cmm
>> Time: 11 November 2010, 11:08:07.979 am
>> UUID: f4fd12e0-266e-4e95-a4ac-b2064707494c
>> Ancestors: Collections-ul.403
>>
>> Introduced WeakOrderedCollection.
>
> There are two unnecessary methods: WeakOrderedCollection >> #new: and
> WeakOrderedCollection >> #new:withAll:.
>
> Shouldn't WeakOrderedCollection be in the Collections-Weak category like all
> other weak collections?
>
> Are you using the prettyprinter to format the methods? Some of your changes
> (#to:do: #to:by:do:) take a lot more time for me to understand in this
> format. And it reminds me to what the prettyprinter does.
>
>
> Levente
>
> snip
>
>