73 |
|
* @param <V> the type of mapped values |
74 |
|
*/ |
75 |
|
public class ConcurrentHashMap<K, V> extends AbstractMap<K, V> |
76 |
< |
implements ConcurrentMap<K, V>, Cloneable, Serializable { |
76 |
> |
implements ConcurrentMap<K, V>, Serializable { |
77 |
|
private static final long serialVersionUID = 7249069246763182397L; |
78 |
|
|
79 |
|
/* |
987 |
|
segments[i].clear(); |
988 |
|
} |
989 |
|
|
990 |
– |
|
991 |
– |
/** |
992 |
– |
* Returns a shallow copy of this |
993 |
– |
* <tt>ConcurrentHashMap</tt> instance: the keys and |
994 |
– |
* values themselves are not cloned. |
995 |
– |
* |
996 |
– |
* @return a shallow copy of this map. |
997 |
– |
*/ |
998 |
– |
public Object clone() { |
999 |
– |
// We cannot call super.clone, since it would share final |
1000 |
– |
// segments array, and there's no way to reassign finals. |
1001 |
– |
|
1002 |
– |
float lf = segments[0].loadFactor; |
1003 |
– |
int segs = segments.length; |
1004 |
– |
int cap = (int)(size() / lf); |
1005 |
– |
if (cap < segs) cap = segs; |
1006 |
– |
ConcurrentHashMap<K,V> t = new ConcurrentHashMap<K,V>(cap, lf, segs); |
1007 |
– |
t.putAll(this); |
1008 |
– |
return t; |
1009 |
– |
} |
1010 |
– |
|
990 |
|
/** |
991 |
|
* Returns a set view of the keys contained in this map. The set is |
992 |
|
* backed by the map, so changes to the map are reflected in the set, and |