src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java

Print this page
rev 16851 : 8176402: parameter name switcharoo in ConcurrentHashMap
Reviewed-by: martin, chegar


3451                     ConcurrentHashMap<K,V> map) {
3452             super(tab, size, index, limit);
3453             this.map = map;
3454             advance();
3455         }
3456 
3457         public final boolean hasNext() { return next != null; }
3458         public final boolean hasMoreElements() { return next != null; }
3459 
3460         public final void remove() {
3461             Node<K,V> p;
3462             if ((p = lastReturned) == null)
3463                 throw new IllegalStateException();
3464             lastReturned = null;
3465             map.replaceNode(p.key, null, null);
3466         }
3467     }
3468 
3469     static final class KeyIterator<K,V> extends BaseIterator<K,V>
3470         implements Iterator<K>, Enumeration<K> {
3471         KeyIterator(Node<K,V>[] tab, int index, int size, int limit,
3472                     ConcurrentHashMap<K,V> map) {
3473             super(tab, index, size, limit, map);
3474         }
3475 
3476         public final K next() {
3477             Node<K,V> p;
3478             if ((p = next) == null)
3479                 throw new NoSuchElementException();
3480             K k = p.key;
3481             lastReturned = p;
3482             advance();
3483             return k;
3484         }
3485 
3486         public final K nextElement() { return next(); }
3487     }
3488 
3489     static final class ValueIterator<K,V> extends BaseIterator<K,V>
3490         implements Iterator<V>, Enumeration<V> {
3491         ValueIterator(Node<K,V>[] tab, int index, int size, int limit,
3492                       ConcurrentHashMap<K,V> map) {
3493             super(tab, index, size, limit, map);
3494         }
3495 
3496         public final V next() {
3497             Node<K,V> p;
3498             if ((p = next) == null)
3499                 throw new NoSuchElementException();
3500             V v = p.val;
3501             lastReturned = p;
3502             advance();
3503             return v;
3504         }
3505 
3506         public final V nextElement() { return next(); }
3507     }
3508 
3509     static final class EntryIterator<K,V> extends BaseIterator<K,V>
3510         implements Iterator<Map.Entry<K,V>> {
3511         EntryIterator(Node<K,V>[] tab, int index, int size, int limit,
3512                       ConcurrentHashMap<K,V> map) {
3513             super(tab, index, size, limit, map);
3514         }
3515 
3516         public final Map.Entry<K,V> next() {
3517             Node<K,V> p;
3518             if ((p = next) == null)
3519                 throw new NoSuchElementException();
3520             K k = p.key;
3521             V v = p.val;
3522             lastReturned = p;
3523             advance();
3524             return new MapEntry<K,V>(k, v, map);
3525         }
3526     }
3527 
3528     /**
3529      * Exported Entry for EntryIterator.
3530      */
3531     static final class MapEntry<K,V> implements Map.Entry<K,V> {
3532         final K key; // non-null
3533         V val;       // non-null




3451                     ConcurrentHashMap<K,V> map) {
3452             super(tab, size, index, limit);
3453             this.map = map;
3454             advance();
3455         }
3456 
3457         public final boolean hasNext() { return next != null; }
3458         public final boolean hasMoreElements() { return next != null; }
3459 
3460         public final void remove() {
3461             Node<K,V> p;
3462             if ((p = lastReturned) == null)
3463                 throw new IllegalStateException();
3464             lastReturned = null;
3465             map.replaceNode(p.key, null, null);
3466         }
3467     }
3468 
3469     static final class KeyIterator<K,V> extends BaseIterator<K,V>
3470         implements Iterator<K>, Enumeration<K> {
3471         KeyIterator(Node<K,V>[] tab, int size, int index, int limit,
3472                     ConcurrentHashMap<K,V> map) {
3473             super(tab, size, index, limit, map);
3474         }
3475 
3476         public final K next() {
3477             Node<K,V> p;
3478             if ((p = next) == null)
3479                 throw new NoSuchElementException();
3480             K k = p.key;
3481             lastReturned = p;
3482             advance();
3483             return k;
3484         }
3485 
3486         public final K nextElement() { return next(); }
3487     }
3488 
3489     static final class ValueIterator<K,V> extends BaseIterator<K,V>
3490         implements Iterator<V>, Enumeration<V> {
3491         ValueIterator(Node<K,V>[] tab, int size, int index, int limit,
3492                       ConcurrentHashMap<K,V> map) {
3493             super(tab, size, index, limit, map);
3494         }
3495 
3496         public final V next() {
3497             Node<K,V> p;
3498             if ((p = next) == null)
3499                 throw new NoSuchElementException();
3500             V v = p.val;
3501             lastReturned = p;
3502             advance();
3503             return v;
3504         }
3505 
3506         public final V nextElement() { return next(); }
3507     }
3508 
3509     static final class EntryIterator<K,V> extends BaseIterator<K,V>
3510         implements Iterator<Map.Entry<K,V>> {
3511         EntryIterator(Node<K,V>[] tab, int size, int index, int limit,
3512                       ConcurrentHashMap<K,V> map) {
3513             super(tab, size, index, limit, map);
3514         }
3515 
3516         public final Map.Entry<K,V> next() {
3517             Node<K,V> p;
3518             if ((p = next) == null)
3519                 throw new NoSuchElementException();
3520             K k = p.key;
3521             V v = p.val;
3522             lastReturned = p;
3523             advance();
3524             return new MapEntry<K,V>(k, v, map);
3525         }
3526     }
3527 
3528     /**
3529      * Exported Entry for EntryIterator.
3530      */
3531     static final class MapEntry<K,V> implements Map.Entry<K,V> {
3532         final K key; // non-null
3533         V val;       // non-null