5 |
|
*/ |
6 |
|
|
7 |
|
package extra166y; |
8 |
+ |
|
9 |
|
import java.lang.ref.*; |
10 |
|
import java.lang.reflect.*; |
11 |
|
import java.io.*; |
20 |
|
* user-supplied computational methods for setting and updating |
21 |
|
* values. In particular: <ul> |
22 |
|
* |
23 |
< |
* <li> Identity-based, Equality-based or User-definable {@link |
24 |
< |
* Equivalence}-based comparisons controlling membership. |
23 |
> |
* <li>Identity-based, Equality-based or User-definable {@link |
24 |
> |
* Equivalence}-based comparisons controlling membership. |
25 |
|
* |
26 |
< |
* <li> {@linkplain SoftReference Soft}, {@linkplain |
27 |
< |
* WeakReference weak} or strong (regular) keys and values. |
26 |
> |
* <li>{@linkplain SoftReference Soft}, {@linkplain |
27 |
> |
* WeakReference weak} or strong (regular) keys and values. |
28 |
|
* |
29 |
< |
* <li> User-definable {@code MappingFunctions} that may be |
30 |
< |
* used in method {@link |
31 |
< |
* CustomConcurrentHashMap#computeIfAbsent} to atomically |
32 |
< |
* establish a computed value, along with |
33 |
< |
* {@code RemappingFunctions} that can be used in method |
34 |
< |
* {@link CustomConcurrentHashMap#compute} to atomically |
35 |
< |
* replace values. |
29 |
> |
* <li>User-definable {@code MappingFunctions} that may be |
30 |
> |
* used in method {@link |
31 |
> |
* CustomConcurrentHashMap#computeIfAbsent} to atomically |
32 |
> |
* establish a computed value, along with |
33 |
> |
* {@code RemappingFunctions} that can be used in method |
34 |
> |
* {@link CustomConcurrentHashMap#compute} to atomically |
35 |
> |
* replace values. |
36 |
|
* |
37 |
< |
* <li>Factory methods returning specialized forms for {@code int} |
38 |
< |
* keys and/or values, that may be more space-efficient |
37 |
> |
* <li>Factory methods returning specialized forms for {@code int} |
38 |
> |
* keys and/or values, that may be more space-efficient |
39 |
|
* |
40 |
|
* </ul> |
41 |
|
* |
111 |
|
* @param <K> the type of keys maintained by this map |
112 |
|
* @param <V> the type of mapped values |
113 |
|
*/ |
114 |
< |
public class CustomConcurrentHashMap<K, V> extends AbstractMap<K, V> |
115 |
< |
implements ConcurrentMap<K, V>, Serializable { |
114 |
> |
public class CustomConcurrentHashMap<K,V> extends AbstractMap<K,V> |
115 |
> |
implements ConcurrentMap<K,V>, Serializable { |
116 |
|
private static final long serialVersionUID = 7249069246764182397L; |
117 |
|
|
118 |
|
/* |
227 |
|
* A function computing a mapping from the given key to a value, |
228 |
|
* or {@code null} if there is no mapping. |
229 |
|
*/ |
230 |
< |
public static interface MappingFunction<K, V> { |
230 |
> |
public static interface MappingFunction<K,V> { |
231 |
|
/** |
232 |
|
* Returns a value for the given key, or null if there is no |
233 |
|
* mapping. If this function throws an (unchecked) exception, |
248 |
|
* current value to a new value, or {@code null} if there is |
249 |
|
* no mapping. |
250 |
|
*/ |
251 |
< |
public static interface RemappingFunction<K, V> { |
251 |
> |
public static interface RemappingFunction<K,V> { |
252 |
|
/** |
253 |
|
* Returns a new value for the given key and its current, or |
254 |
|
* null if there is no mapping. |
680 |
|
* Returns {@code true} if this map contains a key equivalent to |
681 |
|
* the given key with respect to this map's key Equivalence. |
682 |
|
* |
683 |
< |
* @param key possible key |
683 |
> |
* @param key possible key |
684 |
|
* @return {@code true} if this map contains the specified key |
685 |
|
* @throws NullPointerException if the specified key is null |
686 |
|
*/ |
698 |
|
* key with respect to this map's key Equivalence, or {@code null} |
699 |
|
* if no such mapping exists. |
700 |
|
* |
701 |
< |
* @param key possible key |
702 |
< |
* @return the value associated with the key or {@code null} if |
701 |
> |
* @param key possible key |
702 |
> |
* @return the value associated with the key, or {@code null} if |
703 |
|
* there is no mapping |
704 |
|
* @throws NullPointerException if the specified key is null |
705 |
|
*/ |