256 |
|
|
257 |
if (initialCapacity == 0) |
if (initialCapacity == 0) |
258 |
initialCapacity = 1; |
initialCapacity = 1; |
259 |
buckets = new HashEntry<K, V>[initialCapacity]; |
buckets = (HashEntry<K, V>[]) new HashEntry[initialCapacity]; |
260 |
this.loadFactor = loadFactor; |
this.loadFactor = loadFactor; |
261 |
threshold = (int) (initialCapacity * loadFactor); |
threshold = (int) (initialCapacity * loadFactor); |
262 |
} |
} |
386 |
{ |
{ |
387 |
Map.Entry<? extends K, ? extends V> e = itr.next(); |
Map.Entry<? extends K, ? extends V> e = itr.next(); |
388 |
// Optimize in case the Entry is one of our own. |
// Optimize in case the Entry is one of our own. |
389 |
if (e instanceof AbstractMap.BasicMapEntry<K, V>) |
if (e instanceof AbstractMap.BasicMapEntry) |
390 |
{ |
{ |
391 |
AbstractMap.BasicMapEntry<? extends K, ? extends V> entry |
AbstractMap.BasicMapEntry<? extends K, ? extends V> entry |
392 |
= (AbstractMap.BasicMapEntry<? extends K, ? extends V>) e; |
= (AbstractMap.BasicMapEntry<? extends K, ? extends V>) e; |
485 |
{ |
{ |
486 |
// This is impossible. |
// This is impossible. |
487 |
} |
} |
488 |
copy.buckets = new HashEntry<K, V>[buckets.length]; |
copy.buckets = (HashEntry<K, V>[]) new HashEntry[buckets.length]; |
489 |
copy.putAllInternal(this); |
copy.putAllInternal(this); |
490 |
// Clear the entry cache. AbstractMap.clone() does the others. |
// Clear the entry cache. AbstractMap.clone() does the others. |
491 |
copy.entries = null; |
copy.entries = null; |
661 |
// Package visible, for use in nested classes. |
// Package visible, for use in nested classes. |
662 |
final HashEntry<K, V> getEntry(Object o) |
final HashEntry<K, V> getEntry(Object o) |
663 |
{ |
{ |
664 |
if (! (o instanceof Map.Entry<K, V>)) |
if (! (o instanceof Map.Entry)) |
665 |
return null; |
return null; |
666 |
Map.Entry<K, V> me = (Map.Entry<K, V>) o; |
Map.Entry<K, V> me = (Map.Entry<K, V>) o; |
667 |
K key = me.getKey(); |
K key = me.getKey(); |
716 |
while (itr.hasNext()) |
while (itr.hasNext()) |
717 |
{ |
{ |
718 |
size++; |
size++; |
719 |
Map.Entry<K, V> e = itr.next(); |
Map.Entry<? extends K, ? extends V> e = itr.next(); |
720 |
K key = e.getKey(); |
K key = e.getKey(); |
721 |
int idx = hash(key); |
int idx = hash(key); |
722 |
addEntry(key, e.getValue(), idx, false); |
addEntry(key, e.getValue(), idx, false); |
738 |
|
|
739 |
int newcapacity = (buckets.length * 2) + 1; |
int newcapacity = (buckets.length * 2) + 1; |
740 |
threshold = (int) (newcapacity * loadFactor); |
threshold = (int) (newcapacity * loadFactor); |
741 |
buckets = new HashEntry<K, V>[newcapacity]; |
buckets = (HashEntry<K, V>[]) new HashEntry[newcapacity]; |
742 |
|
|
743 |
for (int i = oldBuckets.length - 1; i >= 0; i--) |
for (int i = oldBuckets.length - 1; i >= 0; i--) |
744 |
{ |
{ |
800 |
s.defaultReadObject(); |
s.defaultReadObject(); |
801 |
|
|
802 |
// Read and use capacity, followed by key/value pairs. |
// Read and use capacity, followed by key/value pairs. |
803 |
buckets = new HashEntry<K, V>[s.readInt()]; |
buckets = (HashEntry<K, V>[]) new HashEntry[s.readInt()]; |
804 |
int len = s.readInt(); |
int len = s.readInt(); |
805 |
size = len; |
size = len; |
806 |
while (len-- > 0) |
while (len-- > 0) |
868 |
* @throws ConcurrentModificationException if the HashMap was modified |
* @throws ConcurrentModificationException if the HashMap was modified |
869 |
* @throws NoSuchElementException if there is none |
* @throws NoSuchElementException if there is none |
870 |
*/ |
*/ |
871 |
public Object next() |
public T next() |
872 |
{ |
{ |
873 |
if (knownMod != modCount) |
if (knownMod != modCount) |
874 |
throw new ConcurrentModificationException(); |
throw new ConcurrentModificationException(); |
883 |
next = e.next; |
next = e.next; |
884 |
last = e; |
last = e; |
885 |
if (type == VALUES) |
if (type == VALUES) |
886 |
return e.value; |
return (T) e.value; |
887 |
if (type == KEYS) |
if (type == KEYS) |
888 |
return e.key; |
return (T) e.key; |
889 |
return e; |
return (T) e; |
890 |
} |
} |
891 |
|
|
892 |
/** |
/** |