[Pkg] The Trunk: Collections-cmm.404.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Nov 11 17:08:26 UTC 2010


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)!



More information about the Packages mailing list