A new version of Collections was added to project The Inbox:
http://source.squeak.org/inbox/Collections-ul.140.mcz ==================== Summary ==================== Name: Collections-ul.140 Author: ul Time: 20 September 2009, 4:01:30 am UUID: 700b7cc5-9d52-de44-a3ed-1925ea20ecca Ancestors: Collections-ul.139 Warning! Don't load this without having Collections-ul.139 in your image! - removed unused #scanForNil: implementations (replaced by #scanForEmptySlotFor:), updated comments in #scanFor: =============== Diff against Collections-ul.139 =============== Item was changed: ----- Method: WeakIdentityKeyDictionary>>scanFor: (in category 'private') ----- scanFor: anObject - "ar 10/21/2000: The method has been copied to this location to indicate that whenever #scanFor: changes #scanForNil: must be changed in the receiver as well." "Scan the key array for the first slot containing either a nil (indicating an empty slot) or an element that matches anObject. Answer the index of that slot or zero if no slot is found. This method will be overridden in various subclasses that have different interpretations for matching elements." | element start finish hash | finish := array size. finish > 4096 ifTrue: [hash := anObject identityHash * (finish // 4096)] ifFalse: [hash := anObject identityHash]. start := (hash \\ finish) + 1. "Search from (hash mod size) to the end." start to: finish do: [:index | ((element := array at: index) == nil or: [element key == anObject]) ifTrue: [^ index ]]. "Search from 1 to where we started." 1 to: start-1 do: [:index | ((element := array at: index) == nil or: [element key == anObject]) ifTrue: [^ index ]]. ^ 0 "No match AND no empty slot"! Item was changed: ----- Method: WeakKeyDictionary>>scanFor: (in category 'private') ----- scanFor: anObject - "ar 10/21/2000: The method has been copied to this location to indicate that whenever #scanFor: changes #scanForNil: must be changed in the receiver as well." "Scan the key array for the first slot containing either a nil (indicating an empty slot) or an element that matches anObject. Answer the index of that slot or zero if no slot is found. This method will be overridden in various subclasses that have different interpretations for matching elements." | element start finish | finish := array size. start := (anObject hash \\ finish) + 1. "Search from (hash mod size) to the end." start to: finish do: [:index | ((element := array at: index) == nil or: [element key = anObject]) ifTrue: [^ index ]]. "Search from 1 to where we started." 1 to: start-1 do: [:index | ((element := array at: index) == nil or: [element key = anObject]) ifTrue: [^ index ]]. ^ 0 "No match AND no empty slot"! Item was removed: - ----- Method: WeakIdentityKeyDictionary>>scanForNil: (in category 'private') ----- - scanForNil: anObject - "Private. Scan the key array for the first slot containing nil (indicating an empty slot). Answer the index of that slot." - | start finish hash | - finish := array size. - finish > 4096 - ifTrue: [hash := anObject identityHash * (finish // 4096)] - ifFalse: [hash := anObject identityHash]. - start := (hash \\ array size) + 1. - - "Search from (hash mod size) to the end." - start to: finish do: - [:index | (array at: index) == nil ifTrue: [^ index ]]. - - "Search from 1 to where we started." - 1 to: start-1 do: - [:index | (array at: index) == nil ifTrue: [^ index ]]. - - ^ 0 "No match AND no empty slot"! Item was removed: - ----- Method: WeakKeyDictionary>>scanForNil: (in category 'private') ----- - scanForNil: anObject - "Private. Scan the key array for the first slot containing nil (indicating an empty slot). Answer the index of that slot." - | start finish | - start := (anObject hash \\ array size) + 1. - finish := array size. - - "Search from (hash mod size) to the end." - start to: finish do: - [:index | (array at: index) == nil ifTrue: [^ index ]]. - - "Search from 1 to where we started." - 1 to: start-1 do: - [:index | (array at: index) == nil ifTrue: [^ index ]]. - - ^ 0 "No match AND no empty slot"! |
Free forum by Nabble | Edit this page |