602 |
|
} |
603 |
|
|
604 |
|
/** |
605 |
+ |
* Creates a new, empty map with the specified initial capacity |
606 |
+ |
* and load factor and with the default concurrencyLevel (16). |
607 |
+ |
* |
608 |
+ |
* @param initialCapacity The implementation performs internal |
609 |
+ |
* sizing to accommodate this many elements. |
610 |
+ |
* @param loadFactor the load factor threshold, used to control resizing. |
611 |
+ |
* @throws IllegalArgumentException if the initial capacity of |
612 |
+ |
* elements is negative or the load factor is nonpositive |
613 |
+ |
*/ |
614 |
+ |
public ConcurrentHashMap(int initialCapacity, float loadFactor) { |
615 |
+ |
this(initialCapacity, loadFactor, DEFAULT_SEGMENTS); |
616 |
+ |
} |
617 |
+ |
|
618 |
+ |
/** |
619 |
|
* Creates a new, empty map with the specified initial |
620 |
< |
* capacity, and with default load factor and concurrencyLevel. |
620 |
> |
* capacity, and with default load factor (0.75f) and |
621 |
> |
* concurrencyLevel (16). |
622 |
|
* |
623 |
|
* @param initialCapacity The implementation performs internal |
624 |
|
* sizing to accommodate this many elements. |
630 |
|
} |
631 |
|
|
632 |
|
/** |
633 |
< |
* Creates a new, empty map with a default initial capacity, |
634 |
< |
* load factor, and concurrencyLevel. |
633 |
> |
* Creates a new, empty map with a default initial capacity (16), |
634 |
> |
* load factor (0.75f), and concurrencyLevel (16). |
635 |
|
*/ |
636 |
|
public ConcurrentHashMap() { |
637 |
|
this(DEFAULT_INITIAL_CAPACITY, DEFAULT_LOAD_FACTOR, DEFAULT_SEGMENTS); |
639 |
|
|
640 |
|
/** |
641 |
|
* Creates a new map with the same mappings as the given map. The |
642 |
< |
* map is created with a capacity of twice the number of mappings in |
643 |
< |
* the given map or 11 (whichever is greater), and a default load factor |
644 |
< |
* and concurrencyLevel. |
642 |
> |
* map is created with a capacity of 1.5 times the number of |
643 |
> |
* mappings in the given map or 16 (whichever is greater), and a |
644 |
> |
* default load factor (0.75f) and concurrencyLevel(16). |
645 |
|
* @param t the map |
646 |
|
*/ |
647 |
|
public ConcurrentHashMap(Map<? extends K, ? extends V> t) { |
648 |
|
this(Math.max((int) (t.size() / DEFAULT_LOAD_FACTOR) + 1, |
649 |
< |
11), |
649 |
> |
16), |
650 |
|
DEFAULT_LOAD_FACTOR, DEFAULT_SEGMENTS); |
651 |
|
putAll(t); |
652 |
|
} |