256 |
|
|
257 |
if (initialCapacity == 0) |
if (initialCapacity == 0) |
258 |
initialCapacity = 1; |
initialCapacity = 1; |
259 |
buckets = new HashEntry[initialCapacity]; |
buckets = new HashEntry<K, V>[initialCapacity]; |
260 |
this.loadFactor = loadFactor; |
this.loadFactor = loadFactor; |
261 |
threshold = (int) (initialCapacity * loadFactor); |
threshold = (int) (initialCapacity * loadFactor); |
262 |
} |
} |
385 |
{ |
{ |
386 |
Map.Entry<? extends K, ? extends V> e = itr.next(); |
Map.Entry<? extends K, ? extends V> e = itr.next(); |
387 |
// Optimize in case the Entry is one of our own. |
// Optimize in case the Entry is one of our own. |
388 |
if (e instanceof AbstractMap.BasicMapEntry) |
if (e instanceof AbstractMap.BasicMapEntry<K, V>) |
389 |
{ |
{ |
390 |
AbstractMap.BasicMapEntry<? extends K, ? extends V> entry |
AbstractMap.BasicMapEntry<? extends K, ? extends V> entry |
391 |
= (AbstractMap.BasicMapEntry<? extends K, ? extends V>) e; |
= (AbstractMap.BasicMapEntry<? extends K, ? extends V>) e; |
456 |
{ |
{ |
457 |
for (int i = buckets.length - 1; i >= 0; i--) |
for (int i = buckets.length - 1; i >= 0; i--) |
458 |
{ |
{ |
459 |
HashEntry e = buckets[i]; |
HashEntry<K, V> e = buckets[i]; |
460 |
while (e != null) |
while (e != null) |
461 |
{ |
{ |
462 |
if (equals(value, e.value)) |
if (equals(value, e.value)) |
475 |
*/ |
*/ |
476 |
public Object clone() |
public Object clone() |
477 |
{ |
{ |
478 |
HashMap copy = null; |
HashMap<K, V> copy = null; |
479 |
try |
try |
480 |
{ |
{ |
481 |
copy = (HashMap) super.clone(); |
copy = (HashMap<K, V>) super.clone(); |
482 |
} |
} |
483 |
catch (CloneNotSupportedException x) |
catch (CloneNotSupportedException x) |
484 |
{ |
{ |
485 |
// This is impossible. |
// This is impossible. |
486 |
} |
} |
487 |
copy.buckets = new HashEntry[buckets.length]; |
copy.buckets = new HashEntry<K, V>[buckets.length]; |
488 |
copy.putAllInternal(this); |
copy.putAllInternal(this); |
489 |
// Clear the entry cache. AbstractMap.clone() does the others. |
// Clear the entry cache. AbstractMap.clone() does the others. |
490 |
copy.entries = null; |
copy.entries = null; |
660 |
// Package visible, for use in nested classes. |
// Package visible, for use in nested classes. |
661 |
final HashEntry<K, V> getEntry(Object o) |
final HashEntry<K, V> getEntry(Object o) |
662 |
{ |
{ |
663 |
if (! (o instanceof Map.Entry)) |
if (! (o instanceof Map.Entry<K, V>)) |
664 |
return null; |
return null; |
665 |
Map.Entry<K, V> me = (Map.Entry<K, V>) o; |
Map.Entry<K, V> me = (Map.Entry<K, V>) o; |
666 |
K key = me.getKey(); |
K key = me.getKey(); |