jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java
changeset 42320 bfc781c5078f
parent 39725 9548f8d846e9
child 44589 64d9270bd24c
child 44743 f0bbd698c486
equal deleted inserted replaced
42319:0193886267c3 42320:bfc781c5078f
  1648 
  1648 
  1649     /**
  1649     /**
  1650      * Removes all of the mappings from this map.
  1650      * Removes all of the mappings from this map.
  1651      */
  1651      */
  1652     public void clear() {
  1652     public void clear() {
  1653         initialize();
  1653         for (;;) {
       
  1654             Node<K,V> b, n;
       
  1655             HeadIndex<K,V> h = head, d = (HeadIndex<K,V>)h.down;
       
  1656             if (d != null)
       
  1657                 casHead(h, d);            // remove levels
       
  1658             else if ((b = h.node) != null && (n = b.next) != null) {
       
  1659                 Node<K,V> f = n.next;     // remove values
       
  1660                 if (n == b.next) {
       
  1661                     Object v = n.value;
       
  1662                     if (v == null)
       
  1663                         n.helpDelete(b, f);
       
  1664                     else if (n.casValue(v, null) && n.appendMarker(f))
       
  1665                         b.casNext(n, f);
       
  1666                 }
       
  1667             }
       
  1668             else
       
  1669                 break;
       
  1670         }
  1654     }
  1671     }
  1655 
  1672 
  1656     /**
  1673     /**
  1657      * If the specified key is not already associated with a value,
  1674      * If the specified key is not already associated with a value,
  1658      * attempts to compute its value using the given mapping function
  1675      * attempts to compute its value using the given mapping function