3 HashedCollection classMethod!
5 ^ self new: self defaultCapacity!
7 HashedCollection classMethod!
9 ^ self basicNew initialize: initialCapacity!
11 HashedCollection method!
15 index := self find: anObject.
16 (array at: index) ifNil: [^ false].
20 HashedCollection method!
25 ifTrue: [ self error: 'cannot insert self into dictionary' ].
27 index := self find: anObject.
28 (array at: index) ifNotNil: [ ^ anObject ].
30 array at: index put: anObject.
37 HashedCollection method!
39 ^ self remove: anObject ifAbsent: []!
41 HashedCollection method!
42 remove: anObject ifAbsent: aBlock
46 ifTrue: [ self error: 'cannot remove self from dictionary' ].
48 index := self find: anObject.
50 (array at: index) ifNil: [^ aBlock value].
52 array at: index put: self.
54 deleted := deleted + 1.
58 HashedCollection method!
60 ^ self find: anObject in: array!
62 HashedCollection method!
63 find: anObject in: anArray
66 mask := anArray size - 1.
68 i := ((self keyFor: anObject) hash bitAnd: mask) + 1.
72 object := anArray at: i.
74 (object = (self valueFor: anObject)) | (object == nil)
77 i := (i + 106720 bitAnd: mask) + 1.
81 HashedCollection method!
85 newArray := Array new: (array size + array size).
87 self contents do: [ :object |
88 newArray at: (self find: object in: newArray) put: object].
94 HashedCollection method!
96 "maximum 50% load factor"
97 (self occupiedCount * 2) > array size
98 ifTrue: [ self grow ]!
101 HashedCollection method!
105 HashedCollection method!
112 HashedCollection classMethod!
116 HashedCollection classMethod!
120 HashedCollection method!
124 HashedCollection method!
128 HashedCollection method!
129 arraySizeForCapacity: capacity
132 size := HashedCollection minimumCapacity.
135 whileTrue: [ size := size + size ].
139 HashedCollection method!
143 HashedCollection method!
144 initialize: initialCapacity
145 array := Array new: (self arraySizeForCapacity: initialCapacity).
149 HashedCollection method!
151 ^ self occupiedCount / array size!
153 HashedCollection method!
155 ^ array select: [ :object | (object ~~ nil) & (object ~~ self) ]!