| 23 | import java.util.NoSuchElementException; |
| 24 | |
| 25 | public class ConcurrentHashMap<K,V> |
| 26 | extends AbstractMap<K,V> |
| 27 | implements ConcurrentMap<K,V> |
| 28 | { |
| 29 | private static final Unsafe unsafe = Unsafe.getUnsafe(); |
| 30 | private static final long Content; |
| 31 | private static final Content Empty = new Content(new PersistentSet(), 0); |
| 32 | |
| 33 | static { |
| 34 | try { |
| 35 | Content = unsafe.objectFieldOffset |
| 36 | (ConcurrentHashMap.class.getDeclaredField("content")); |
| 37 | } catch (NoSuchFieldException e) { |
| 38 | throw new Error(e); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | private volatile Content<K,V> content; |
| 43 | |
| 44 | public ConcurrentHashMap() { |
| 45 | content = Empty; |
| 46 | } |
| 47 | |
| 48 | public ConcurrentHashMap(int initialCapacity) { |
| 49 | this(); |
| 50 | } |
| 51 | |
| 52 | public ConcurrentHashMap(int initialCapacity, float loadFactor) { |
| 53 | this(); |
| 54 | } |
| 55 | |
| 56 | public ConcurrentHashMap(int initialCapacity, float loadFactor, int concurrencyLevel) { |
| 57 | this(); |
| 58 | } |
| 59 | |
| 60 | public boolean isEmpty() { |
| 61 | return content.size == 0; |
| 62 | } |
| 63 | |
| 64 | public int size() { |
| 65 | return content.size; |
| 66 | } |
| 67 | |
| 68 | public boolean containsKey(Object key) { |
| 69 | return find(key) != null; |
| 70 | } |
| 71 | |
| 72 | public boolean containsValue(Object value) { |
| 73 | for (V v: values()) { |
| 74 | if (value.equals(v)) { |
| 75 | return true; |
| 76 | } |
| 77 | } |
| 78 | return false; |
| 79 | } |
| 80 | |
| 81 | public V get(Object key) { |
| 82 | Cell<K,V> cell = find(key); |
nothing calls this directly
no test coverage detected