195 |
|
this.next = next; |
196 |
|
this.value = value; |
197 |
|
} |
198 |
+ |
|
199 |
+ |
@SuppressWarnings("unchecked") |
200 |
+ |
static final <K,V> HashEntry<K,V>[] newArray(int i) { |
201 |
+ |
return new HashEntry[i]; |
202 |
+ |
} |
203 |
|
} |
204 |
|
|
205 |
|
/** |
270 |
|
transient int threshold; |
271 |
|
|
272 |
|
/** |
273 |
< |
* The per-segment table. Declared as a raw type, casted |
269 |
< |
* to HashEntry<K,V> on each use. |
270 |
< |
*/ |
273 |
> |
* The per-segment table. */ |
274 |
|
transient volatile HashEntry<K,V>[] table; |
275 |
|
|
276 |
|
/** |
283 |
|
|
284 |
|
Segment(int initialCapacity, float lf) { |
285 |
|
loadFactor = lf; |
286 |
< |
setTable(new HashEntry[initialCapacity]); |
286 |
> |
setTable(HashEntry.<K,V>newArray(initialCapacity)); |
287 |
> |
} |
288 |
> |
|
289 |
> |
@SuppressWarnings("unchecked") |
290 |
> |
static final <K,V> Segment<K,V>[] newArray(int i) { |
291 |
> |
return new Segment[i]; |
292 |
|
} |
293 |
|
|
294 |
|
/** |
359 |
|
HashEntry<K,V>[] tab = table; |
360 |
|
int len = tab.length; |
361 |
|
for (int i = 0 ; i < len; i++) { |
362 |
< |
for (HashEntry<K,V> e = (HashEntry<K,V>)tab[i]; |
355 |
< |
e != null ; |
356 |
< |
e = e.next) { |
362 |
> |
for (HashEntry<K,V> e = tab[i]; e != null; e = e.next) { |
363 |
|
V v = e.value; |
364 |
|
if (v == null) // recheck |
365 |
|
v = readValueUnderLock(e); |
459 |
|
* right now. |
460 |
|
*/ |
461 |
|
|
462 |
< |
HashEntry<K,V>[] newTable = (HashEntry<K,V>[])new HashEntry[oldCapacity << 1]; |
462 |
> |
HashEntry<K,V>[] newTable = HashEntry.newArray(oldCapacity<<1); |
463 |
|
threshold = (int)(newTable.length * loadFactor); |
464 |
|
int sizeMask = newTable.length - 1; |
465 |
|
for (int i = 0; i < oldCapacity ; i++) { |
593 |
|
} |
594 |
|
segmentShift = 32 - sshift; |
595 |
|
segmentMask = ssize - 1; |
596 |
< |
this.segments = (Segment<K,V>[]) new Segment[ssize]; |
596 |
> |
this.segments = Segment.newArray(ssize); |
597 |
|
|
598 |
|
if (initialCapacity > MAXIMUM_CAPACITY) |
599 |
|
initialCapacity = MAXIMUM_CAPACITY; |
1327 |
|
|
1328 |
|
// Initialize each segment to be minimally sized, and let grow. |
1329 |
|
for (int i = 0; i < segments.length; ++i) { |
1330 |
< |
segments[i].setTable(new HashEntry[1]); |
1330 |
> |
segments[i].setTable((HashEntry<K,V>[])HashEntry.newArray(1)); |
1331 |
|
} |
1332 |
|
|
1333 |
|
// Read the keys and values, and put the mappings in the table |