[squeak-dev] The Inbox: Collections-ul.138.mcz

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

[squeak-dev] The Inbox: Collections-ul.138.mcz

commits-2
A new version of Collections was added to project The Inbox:
http://source.squeak.org/inbox/Collections-ul.138.mcz

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

Name: Collections-ul.138
Author: ul
Time: 20 September 2009, 3:50:08 am
UUID: 20aa2cee-625f-3a47-8759-814bfc051d9b
Ancestors: Collections-ul.137

Warning! Don't load this without having Collections-ul.137 in your image!

- reimplement #rehash, #grow and #finalizeValues:

=============== Diff against Collections-ul.137 ===============

Item was changed:
  ----- Method: WeakKeyDictionary>>finalizeValues: (in category 'finalization') -----
  finalizeValues: finiObjects
  "Remove all associations with key == nil and value is in finiObjects.
  This method is folded with #rehash for efficiency."
+
+ | oldArray |
- | oldArray assoc newIndex |
  oldArray := array.
  array := Array new: oldArray size.
  tally := 0.
+ 1 to: array size do:[ :i |
+ | association |
+ (association := oldArray at: i) ifNotNil: [
+ (association key == nil and: [ finiObjects includes: association value ])
+ ifFalse:[
+ array
+ at: (self scanForEmptySlotFor: association key)
+ put: association ] ] ]!
- 1 to: array size do:[:i|
- assoc := oldArray at: i.
- assoc ifNotNil:[
- (assoc key == nil and:[finiObjects includes: assoc value]) ifFalse:[
- newIndex := self scanForNil: assoc key.
- self atNewIndex: newIndex put: assoc].
- ].
- ].!

Item was changed:
  ----- Method: Set>>grow (in category 'private') -----
  grow
  "Grow the elements array and reinsert the old elements"
+
+ self growTo: array size + self growSize!
- | oldElements |
- oldElements := array.
- array := Array new: array size + self growSize.
- tally := 0.
- oldElements do:
- [:each | each == nil ifFalse: [self noCheckAdd: each]]!

Item was changed:
  ----- Method: WeakSet>>growTo: (in category 'private') -----
  growTo: anInteger
  "Grow the elements array and reinsert the old elements"
 
  | oldElements |
 
  oldElements := array.
  array := WeakArray new: anInteger.
  array atAllPut: flag.
+ self noCheckNoGrowFillFrom: oldElements!
- tally := 0.
- oldElements do:
- [:each | (each == flag or: [each == nil]) ifFalse: [self noCheckAdd: each]]!

Item was changed:
  ----- Method: Set>>rehash (in category 'private') -----
  rehash
+
+ self growTo: array size!
- | newSelf |
- newSelf := self species new: self size.
- self do: [:each | newSelf noCheckAdd: each].
- array := newSelf array!