64 |
|
/* ---------------- Constants -------------- */ |
65 |
|
|
66 |
|
/** |
67 |
< |
* The default initial number of table slots for this table (32). |
67 |
> |
* The default initial number of table slots for this table (16). |
68 |
|
* Used when not otherwise specified in constructor. |
69 |
|
*/ |
70 |
|
private static int DEFAULT_INITIAL_CAPACITY = 16; |
609 |
|
} |
610 |
|
/** |
611 |
|
* Tests if some key maps into the specified value in this table. |
612 |
< |
* This operation is more expensive than the <code>containsKey</code> |
613 |
< |
* method.<p> |
614 |
< |
* |
615 |
< |
* Note that this method is identical in functionality to containsValue, |
616 |
< |
* (which is part of the Map interface in the collections framework). |
617 |
< |
* |
612 |
> |
* This operation is more expensive than the |
613 |
> |
* <code>containsKey</code> method. |
614 |
> |
* |
615 |
> |
* <p> Note that this method is identical in functionality to |
616 |
> |
* containsValue, This method esists solely to ensure plug-in |
617 |
> |
* compatibility with class <tt>Hashtable</tt>, which supported |
618 |
> |
* this method prior to introduction of the collections framework. |
619 |
> |
|
620 |
|
* @param value a value to search for. |
621 |
|
* @return <code>true</code> if and only if some key maps to the |
622 |
|
* <code>value</code> argument in this table as |
660 |
|
* with a value, associate it with the given value. |
661 |
|
* This is equivalent to |
662 |
|
* <pre> |
663 |
< |
* if (!map.containsKey(key)) map.put(key, value); |
664 |
< |
* return get(key); |
663 |
> |
* if (!map.containsKey(key)) |
664 |
> |
* return map.put(key, value); |
665 |
> |
* else |
666 |
> |
* return map.get(key); |
667 |
|
* </pre> |
668 |
|
* Except that the action is performed atomically. |
669 |
|
* @param key key with which the specified value is to be associated. |
674 |
|
* with the specified key, if the implementation supports |
675 |
|
* <tt>null</tt> values. |
676 |
|
* |
677 |
< |
* @throws NullPointerException this map does not permit <tt>null</tt> |
678 |
< |
* keys or values, and the specified key or value is |
677 |
> |
* @throws UnsupportedOperationException if the <tt>put</tt> operation is |
678 |
> |
* not supported by this map. |
679 |
> |
* @throws ClassCastException if the class of the specified key or value |
680 |
> |
* prevents it from being stored in this map. |
681 |
> |
* @throws NullPointerException if the specified key or value is |
682 |
|
* <tt>null</tt>. |
683 |
|
* |
684 |
|
**/ |
722 |
|
} |
723 |
|
|
724 |
|
/** |
725 |
< |
* Removes the (key, value) pair from this |
726 |
< |
* table. This method does nothing if the key is not in the table, |
727 |
< |
* or if the key is associated with a different value. |
728 |
< |
* |
729 |
< |
* @param key the key that needs to be removed. |
730 |
< |
* @param value the associated value. If the value is null, |
731 |
< |
* it means "any value". |
732 |
< |
* @return the value to which the key had been mapped in this table, |
733 |
< |
* or <code>null</code> if the key did not have a mapping. |
734 |
< |
* @throws NullPointerException if the key is |
735 |
< |
* <code>null</code>. |
725 |
> |
* Remove entry for key only if currently mapped to given value. |
726 |
> |
* Acts as |
727 |
> |
* <pre> |
728 |
> |
* if (map.get(key).equals(value)) { |
729 |
> |
* map.remove(key); |
730 |
> |
* return true; |
731 |
> |
* } else return false; |
732 |
> |
* </pre> |
733 |
> |
* except that the action is performed atomically. |
734 |
> |
* @param key key with which the specified value is associated. |
735 |
> |
* @param value value associated with the specified key. |
736 |
> |
* @return true if the value was removed |
737 |
> |
* @throws NullPointerException if the specified key is |
738 |
> |
* <tt>null</tt>. |
739 |
|
*/ |
740 |
|
public boolean remove(Object key, Object value) { |
741 |
|
int hash = hash(key); |