ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/jsr166x/ConcurrentSkipListMap.java
(Generate patch)

Comparing jsr166/src/jsr166x/ConcurrentSkipListMap.java (file contents):
Revision 1.8 by jsr166, Mon Nov 16 04:16:42 2009 UTC vs.
Revision 1.35 by jsr166, Thu Sep 3 22:54:46 2015 UTC

# Line 1 | Line 1
1   /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
4 < * http://creativecommons.org/licenses/publicdomain
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6  
7   package jsr166x;
# Line 20 | Line 20 | import java.util.concurrent.atomic.*;
20   * <p>This class implements a concurrent variant of <a
21   * href="http://www.cs.umd.edu/~pugh/">SkipLists</a> providing
22   * expected average <i>log(n)</i> time cost for the
23 < * <tt>containsKey</tt>, <tt>get</tt>, <tt>put</tt> and
24 < * <tt>remove</tt> operations and their variants.  Insertion, removal,
23 > * {@code containsKey}, {@code get}, {@code put} and
24 > * {@code remove} operations and their variants.  Insertion, removal,
25   * update, and access operations safely execute concurrently by
26   * multiple threads. Iterators are <i>weakly consistent</i>, returning
27   * elements reflecting the state of the map at some point at or since
# Line 30 | Line 30 | import java.util.concurrent.atomic.*;
30   * other operations. Ascending key ordered views and their iterators
31   * are faster than descending ones.
32   *
33 < * <p>All <tt>Map.Entry</tt> pairs returned by methods in this class
33 > * <p>All {@code Map.Entry} pairs returned by methods in this class
34   * and its views represent snapshots of mappings at the time they were
35 < * produced. They do <em>not</em> support the <tt>Entry.setValue</tt>
35 > * produced. They do <em>not</em> support the {@code Entry.setValue}
36   * method. (Note however that it is possible to change mappings in the
37 < * associated map using <tt>put</tt>, <tt>putIfAbsent</tt>, or
38 < * <tt>replace</tt>, depending on exactly which effect you need.)
37 > * associated map using {@code put}, {@code putIfAbsent}, or
38 > * {@code replace}, depending on exactly which effect you need.)
39   *
40 < * <p>Beware that, unlike in most collections, the <tt>size</tt>
40 > * <p>Beware that, unlike in most collections, the {@code size}
41   * method is <em>not</em> a constant-time operation. Because of the
42   * asynchronous nature of these maps, determining the current number
43   * of elements requires a traversal of the elements.  Additionally,
44 < * the bulk operations <tt>putAll</tt>, <tt>equals</tt>, and
45 < * <tt>clear</tt> are <em>not</em> guaranteed to be performed
44 > * the bulk operations {@code putAll}, {@code equals}, and
45 > * {@code clear} are <em>not</em> guaranteed to be performed
46   * atomically. For example, an iterator operating concurrently with a
47 < * <tt>putAll</tt> operation might view only some of the added
47 > * {@code putAll} operation might view only some of the added
48   * elements.
49   *
50   * <p>This class and its views and iterators implement all of the
51   * <em>optional</em> methods of the {@link Map} and {@link Iterator}
52   * interfaces. Like most other concurrent collections, this class does
53 < * not permit the use of <tt>null</tt> keys or values because some
53 > * not permit the use of {@code null} keys or values because some
54   * null return values cannot be reliably distinguished from the
55   * absence of elements.
56   *
# Line 212 | Line 212 | public class ConcurrentSkipListMap<K,V>
212       * highly contended cases.
213       *
214       * Unlike most skip-list implementations, index insertion and
215 <     * deletion here require a separate traversal pass occuring after
215 >     * deletion here require a separate traversal pass occurring after
216       * the base-level action, to add or remove index nodes.  This adds
217       * to single-threaded overhead, but improves contended
218       * multithreaded performance by narrowing interference windows,
# Line 325 | Line 325 | public class ConcurrentSkipListMap<K,V>
325      private transient DescendingEntrySet descendingEntrySet;
326  
327      /**
328 <     * Initialize or reset state. Needed by constructors, clone,
328 >     * Initializes or resets state. Needed by constructors, clone,
329       * clear, readObject. and ConcurrentSkipListSet.clone.
330       * (Note that comparator must be separately initialized.)
331       */
# Line 414 | Line 414 | public class ConcurrentSkipListMap<K,V>
414          }
415  
416          /**
417 <         * Return true if this node is a marker. This method isn't
417 >         * Returns true if this node is a marker. This method isn't
418           * actually called in an any current code checking for markers
419           * because callers will have already read value field and need
420           * to use that read (not another done here) and so directly
421           * test if value points to node.
422 <         * @param n a possibly null reference to a node
422 >         *
423           * @return true if this node is a marker node
424           */
425          boolean isMarker() {
# Line 427 | Line 427 | public class ConcurrentSkipListMap<K,V>
427          }
428  
429          /**
430 <         * Return true if this node is the header of base-level list.
430 >         * Returns true if this node is the header of base-level list.
431           * @return true if this node is header node
432           */
433          boolean isBaseHeader() {
# Line 465 | Line 465 | public class ConcurrentSkipListMap<K,V>
465          }
466  
467          /**
468 <         * Return value if this node contains a valid key-value pair,
468 >         * Returns value if this node contains a valid key-value pair,
469           * else null.
470           * @return this node's value if it isn't a marker or header or
471 <         * is deleted, else null.
471 >         * is deleted, else null
472           */
473          V getValidValue() {
474              Object v = value;
# Line 478 | Line 478 | public class ConcurrentSkipListMap<K,V>
478          }
479  
480          /**
481 <         * Create and return a new SnapshotEntry holding current
482 <         * mapping if this node holds a valid value, else null
481 >         * Creates and returns a new SnapshotEntry holding current
482 >         * mapping if this node holds a valid value, else null.
483           * @return new entry or null
484           */
485          SnapshotEntry<K,V> createSnapshot() {
# Line 507 | Line 507 | public class ConcurrentSkipListMap<K,V>
507          volatile Index<K,V> right;
508  
509          /**
510 <         * Creates index node with given values
510 >         * Creates index node with given values.
511           */
512          Index(Node<K,V> node, Index<K,V> down, Index<K,V> right) {
513              this.node = node;
# Line 580 | Line 580 | public class ConcurrentSkipListMap<K,V>
580      /**
581       * An immutable representation of a key-value mapping as it
582       * existed at some point in time. This class does <em>not</em>
583 <     * support the <tt>Map.Entry.setValue</tt> method.
583 >     * support the {@code Map.Entry.setValue} method.
584       */
585      static class SnapshotEntry<K,V> implements Map.Entry<K,V> {
586 <        private final K key;
587 <        private final V value;
586 >        private final K key;
587 >        private final V value;
588  
589          /**
590           * Creates a new entry representing the given key and value.
# Line 592 | Line 592 | public class ConcurrentSkipListMap<K,V>
592           * @param value the value
593           */
594          SnapshotEntry(K key, V value) {
595 <            this.key = key;
596 <            this.value = value;
597 <        }
598 <
599 <        /**
600 <         * Returns the key corresponding to this entry.
601 <         *
602 <         * @return the key corresponding to this entry.
603 <         */
595 >            this.key = key;
596 >            this.value = value;
597 >        }
598 >
599 >        /**
600 >         * Returns the key corresponding to this entry.
601 >         *
602 >         * @return the key corresponding to this entry
603 >         */
604          public K getKey() {
605              return key;
606          }
607  
608 <        /**
609 <         * Returns the value corresponding to this entry.
610 <         *
611 <         * @return the value corresponding to this entry.
612 <         */
608 >        /**
609 >         * Returns the value corresponding to this entry.
610 >         *
611 >         * @return the value corresponding to this entry
612 >         */
613          public V getValue() {
614 <            return value;
614 >            return value;
615          }
616  
617 <        /**
618 <         * Always fails, throwing <tt>UnsupportedOperationException</tt>.
619 <         * @throws UnsupportedOperationException always.
617 >        /**
618 >         * Always fails, throwing {@code UnsupportedOperationException}.
619 >         * @throws UnsupportedOperationException always
620           */
621          public V setValue(V value) {
622              throw new UnsupportedOperationException();
# Line 644 | Line 644 | public class ConcurrentSkipListMap<K,V>
644  
645          /**
646           * Returns a String consisting of the key followed by an
647 <         * equals sign (<tt>"="</tt>) followed by the associated
647 >         * equals sign ({@code "="}) followed by the associated
648           * value.
649 <         * @return a String representation of this entry.
649 >         * @return a String representation of this entry
650           */
651          public String toString() {
652 <            return getKey() + "=" + getValue();
652 >            return getKey() + "=" + getValue();
653          }
654      }
655  
# Line 696 | Line 696 | public class ConcurrentSkipListMap<K,V>
696      }
697  
698      /**
699 <     * Compare using comparator or natural ordering. Used when the
699 >     * Compares using comparator or natural ordering. Used when the
700       * ComparableUsingComparator approach doesn't apply.
701       */
702      int compare(K k1, K k2) throws ClassCastException {
# Line 708 | Line 708 | public class ConcurrentSkipListMap<K,V>
708      }
709  
710      /**
711 <     * Return true if given key greater than or equal to least and
711 >     * Returns true if given key greater than or equal to least and
712       * strictly less than fence, bypassing either test if least or
713 <     * fence oare null. Needed mainly in submap operations.
713 >     * fence are null. Needed mainly in submap operations.
714       */
715      boolean inHalfOpenRange(K key, K least, K fence) {
716          if (key == null)
# Line 720 | Line 720 | public class ConcurrentSkipListMap<K,V>
720      }
721  
722      /**
723 <     * Return true if given key greater than or equal to least and less
723 >     * Returns true if given key greater than or equal to least and less
724       * or equal to fence. Needed mainly in submap operations.
725       */
726      boolean inOpenRange(K key, K least, K fence) {
# Line 733 | Line 733 | public class ConcurrentSkipListMap<K,V>
733      /* ---------------- Traversal -------------- */
734  
735      /**
736 <     * Return a base-level node with key strictly less than given key,
736 >     * Returns a base-level node with key strictly less than given key,
737       * or the base-level header if there is no such node.  Also
738       * unlinks indexes to deleted nodes found along the way.  Callers
739       * rely on this side-effect of clearing indices to deleted nodes.
# Line 766 | Line 766 | public class ConcurrentSkipListMap<K,V>
766      }
767  
768      /**
769 <     * Return node holding key or null if no such, clearing out any
769 >     * Returns node holding key, or null if no such, clearing out any
770       * deleted nodes seen along the way.  Repeatedly traverses at
771       * base-level looking for key starting at predecessor returned
772       * from findPredecessor, processing base-level deletions as
# Line 807 | Line 807 | public class ConcurrentSkipListMap<K,V>
807       * were performed.
808       *
809       * @param key the key
810 <     * @return node holding key, or null if no such.
810 >     * @return node holding key, or null if no such
811       */
812      private Node<K,V> findNode(Comparable<K> key) {
813          for (;;) {
# Line 865 | Line 865 | public class ConcurrentSkipListMap<K,V>
865                  }
866                  if (c == 0) {
867                      Object v = r.node.value;
868 <                    return (v != null)? (V)v : getUsingFindNode(key);
868 >                    return (v != null) ? (V)v : getUsingFindNode(key);
869                  }
870                  bound = rk;
871              }
# Line 878 | Line 878 | public class ConcurrentSkipListMap<K,V>
878                          int c = key.compareTo(nk);
879                          if (c == 0) {
880                              Object v = n.value;
881 <                            return (v != null)? (V)v : getUsingFindNode(key);
881 >                            return (v != null) ? (V)v : getUsingFindNode(key);
882                          }
883                          if (c < 0)
884                              return null;
# Line 890 | Line 890 | public class ConcurrentSkipListMap<K,V>
890      }
891  
892      /**
893 <     * Perform map.get via findNode.  Used as a backup if doGet
893 >     * Performs map.get via findNode.  Used as a backup if doGet
894       * encounters an in-progress deletion.
895       * @param key the key
896       * @return the value, or null if absent
# Line 917 | Line 917 | public class ConcurrentSkipListMap<K,V>
917       * Main insertion method.  Adds element if not present, or
918       * replaces value if present and onlyIfAbsent is false.
919       * @param kkey the key
920 <     * @param value  the value that must be associated with key
920 >     * @param value the value that must be associated with key
921       * @param onlyIfAbsent if should not insert if already present
922       * @return the old value, or null if newly inserted
923       */
# Line 965 | Line 965 | public class ConcurrentSkipListMap<K,V>
965      }
966  
967      /**
968 <     * Return a random level for inserting a new node.
968 >     * Returns a random level for inserting a new node.
969       * Hardwired to k=1, p=0.5, max 31.
970       *
971       * This uses a cheap pseudo-random function that according to
# Line 987 | Line 987 | public class ConcurrentSkipListMap<K,V>
987      }
988  
989      /**
990 <     * Create and add index nodes for given node.
990 >     * Creates and adds index nodes for given node.
991       * @param z the node
992       * @param level the level of the index
993       */
# Line 1039 | Line 1039 | public class ConcurrentSkipListMap<K,V>
1039      }
1040  
1041      /**
1042 <     * Add given index nodes from given level down to 1.
1042 >     * Adds given index nodes from given level down to 1.
1043       * @param idx the topmost index node being inserted
1044       * @param h the value of head to use to insert. This must be
1045 <     * snapshotted by callers to provide correct insertion level
1045 >     * snapshotted by callers to provide correct insertion level.
1046       * @param indexLevel the level of the index
1047       */
1048      private void addIndex(Index<K,V> idx, HeadIndex<K,V> h, int indexLevel) {
# Line 1196 | Line 1196 | public class ConcurrentSkipListMap<K,V>
1196      }
1197  
1198      /**
1199 <     * Version of remove with boolean return. Needed by view classes
1199 >     * Version of remove with boolean return. Needed by view classes.
1200       */
1201      boolean removep(Object key) {
1202          return doRemove(key, null) != null;
# Line 1221 | Line 1221 | public class ConcurrentSkipListMap<K,V>
1221      }
1222  
1223      /**
1224 <     * Remove first entry; return either its key or a snapshot.
1224 >     * Removes first entry; return either its key or a snapshot.
1225       * @param keyOnly if true return key, else return SnapshotEntry
1226       * (This is a little ugly, but avoids code duplication.)
1227       * @return null if empty, first key if keyOnly true, else key,value entry
# Line 1246 | Line 1246 | public class ConcurrentSkipListMap<K,V>
1246                  findFirst(); // retry
1247              clearIndexToFirst();
1248              K key = n.key;
1249 <            return (keyOnly)? key : new SnapshotEntry<K,V>(key, (V)v);
1249 >            return keyOnly ? key : new SnapshotEntry<K,V>(key, (V)v);
1250          }
1251      }
1252  
1253      /**
1254 <     * Clear out index nodes associated with deleted first entry.
1255 <     * Needed by doRemoveFirst
1254 >     * Clears out index nodes associated with deleted first entry.
1255 >     * Needed by doRemoveFirst.
1256       */
1257      private void clearIndexToFirst() {
1258          for (;;) {
# Line 1270 | Line 1270 | public class ConcurrentSkipListMap<K,V>
1270          }
1271      }
1272  
1273 <   /**
1274 <     * Remove first entry; return key or null if empty.
1273 >    /**
1274 >     * Removes first entry; return key or null if empty.
1275       */
1276      K pollFirstKey() {
1277          return (K)doRemoveFirst(true);
# Line 1306 | Line 1306 | public class ConcurrentSkipListMap<K,V>
1306                  Node<K,V> n = b.next;
1307                  for (;;) {
1308                      if (n == null)
1309 <                        return (b.isBaseHeader())? null : b;
1309 >                        return b.isBaseHeader() ? null : b;
1310                      Node<K,V> f = n.next;            // inconsistent read
1311                      if (n != b.next)
1312                          break;
# Line 1368 | Line 1368 | public class ConcurrentSkipListMap<K,V>
1368                      if (head.right == null)
1369                          tryReduceLevel();
1370                  }
1371 <                return (keyOnly)? key : new SnapshotEntry<K,V>(key, (V)v);
1371 >                return keyOnly ? key : new SnapshotEntry<K,V>(key, (V)v);
1372              }
1373          }
1374      }
# Line 1378 | Line 1378 | public class ConcurrentSkipListMap<K,V>
1378       * last valid node. Needed by doRemoveLast. It is possible that
1379       * all successors of returned node will have been deleted upon
1380       * return, in which case this method can be retried.
1381 <     * @return likely predecessor of last node.
1381 >     * @return likely predecessor of last node
1382       */
1383      private Node<K,V> findPredecessorOfLast() {
1384          for (;;) {
# Line 1405 | Line 1405 | public class ConcurrentSkipListMap<K,V>
1405      }
1406  
1407      /**
1408 <     * Remove last entry; return key or null if empty.
1408 >     * Removes last entry; return key or null if empty.
1409       */
1410      K pollLastKey() {
1411          return (K)doRemoveLast(true);
# Line 1432 | Line 1432 | public class ConcurrentSkipListMap<K,V>
1432              Node<K,V> n = b.next;
1433              for (;;) {
1434                  if (n == null)
1435 <                    return ((rel & LT) == 0 || b.isBaseHeader())? null : b;
1435 >                    return ((rel & LT) == 0 || b.isBaseHeader()) ? null : b;
1436                  Node<K,V> f = n.next;
1437                  if (n != b.next)                  // inconsistent read
1438                      break;
# Line 1448 | Line 1448 | public class ConcurrentSkipListMap<K,V>
1448                      (c <  0 && (rel & LT) == 0))
1449                      return n;
1450                  if ( c <= 0 && (rel & LT) != 0)
1451 <                    return (b.isBaseHeader())? null : b;
1451 >                    return b.isBaseHeader() ? null : b;
1452                  b = n;
1453                  n = f;
1454              }
# Line 1456 | Line 1456 | public class ConcurrentSkipListMap<K,V>
1456      }
1457  
1458      /**
1459 <     * Return SnapshotEntry for results of findNear.
1459 >     * Returns SnapshotEntry for results of findNear.
1460       * @param kkey the key
1461       * @param rel the relation -- OR'ed combination of EQ, LT, GT
1462       * @return Entry fitting relation, or null if no such
# Line 1473 | Line 1473 | public class ConcurrentSkipListMap<K,V>
1473      }
1474  
1475      /**
1476 <     * Return ceiling, or first node if key is <tt>null</tt>
1476 >     * Returns ceiling, or first node if key is {@code null}.
1477       */
1478      Node<K,V> findCeiling(K key) {
1479 <        return (key == null)? findFirst() : findNear(key, GT|EQ);
1479 >        return (key == null) ? findFirst() : findNear(key, GT|EQ);
1480      }
1481  
1482      /**
1483 <     * Return lower node, or last node if key is <tt>null</tt>
1483 >     * Returns lower node, or last node if key is {@code null}.
1484       */
1485      Node<K,V> findLower(K key) {
1486 <        return (key == null)? findLast() : findNear(key, LT);
1486 >        return (key == null) ? findLast() : findNear(key, LT);
1487      }
1488  
1489      /**
1490 <     * Return SnapshotEntry or key for results of findNear ofter screening
1490 >     * Returns SnapshotEntry or key for results of findNear ofter screening
1491       * to ensure result is in given range. Needed by submaps.
1492       * @param kkey the key
1493       * @param rel the relation -- OR'ed combination of EQ, LT, GT
1494       * @param least minimum allowed key value
1495       * @param fence key greater than maximum allowed key value
1496       * @param keyOnly if true return key, else return SnapshotEntry
1497 <     * @return Key or Entry fitting relation, or <tt>null</tt> if no such
1497 >     * @return Key or Entry fitting relation, or {@code null} if no such
1498       */
1499      Object getNear(K kkey, int rel, K least, K fence, boolean keyOnly) {
1500          K key = kkey;
# Line 1513 | Line 1513 | public class ConcurrentSkipListMap<K,V>
1513              K k = n.key;
1514              V v = n.getValidValue();
1515              if (v != null)
1516 <                return keyOnly? k : new SnapshotEntry<K,V>(k, v);
1516 >                return keyOnly ? k : new SnapshotEntry<K,V>(k, v);
1517          }
1518      }
1519  
1520      /**
1521 <     * Find and remove least element of subrange.
1521 >     * Finds and removes least element of subrange.
1522       * @param least minimum allowed key value
1523       * @param fence key greater than maximum allowed key value
1524       * @param keyOnly if true return key, else return SnapshotEntry
1525 <     * @return least Key or Entry, or <tt>null</tt> if no such
1525 >     * @return least Key or Entry, or {@code null} if no such
1526       */
1527      Object removeFirstEntryOfSubrange(K least, K fence, boolean keyOnly) {
1528          for (;;) {
# Line 1534 | Line 1534 | public class ConcurrentSkipListMap<K,V>
1534                  return null;
1535              V v = doRemove(k, null);
1536              if (v != null)
1537 <                return (keyOnly)? k : new SnapshotEntry<K,V>(k, v);
1537 >                return keyOnly ? k : new SnapshotEntry<K,V>(k, v);
1538          }
1539      }
1540  
1541      /**
1542 <     * Find and remove greatest element of subrange.
1542 >     * Finds and removes greatest element of subrange.
1543       * @param least minimum allowed key value
1544       * @param fence key greater than maximum allowed key value
1545       * @param keyOnly if true return key, else return SnapshotEntry
1546 <     * @return least Key or Entry, or <tt>null</tt> if no such
1546 >     * @return least Key or Entry, or {@code null} if no such
1547       */
1548      Object removeLastEntryOfSubrange(K least, K fence, boolean keyOnly) {
1549          for (;;) {
# Line 1555 | Line 1555 | public class ConcurrentSkipListMap<K,V>
1555                  return null;
1556              V v = doRemove(k, null);
1557              if (v != null)
1558 <                return (keyOnly)? k : new SnapshotEntry<K,V>(k, v);
1558 >                return keyOnly ? k : new SnapshotEntry<K,V>(k, v);
1559          }
1560      }
1561  
# Line 1574 | Line 1574 | public class ConcurrentSkipListMap<K,V>
1574       * Constructs a new empty map, sorted according to the given comparator.
1575       *
1576       * @param c the comparator that will be used to sort this map.  A
1577 <     *        <tt>null</tt> value indicates that the keys' <i>natural
1577 >     *        {@code null} value indicates that the keys' <i>natural
1578       *        ordering</i> should be used.
1579       */
1580      public ConcurrentSkipListMap(Comparator<? super K> c) {
# Line 1586 | Line 1586 | public class ConcurrentSkipListMap<K,V>
1586       * Constructs a new map containing the same mappings as the given map,
1587       * sorted according to the keys' <i>natural order</i>.
1588       *
1589 <     * @param  m the map whose mappings are to be placed in this map.
1589 >     * @param  m the map whose mappings are to be placed in this map
1590       * @throws ClassCastException if the keys in m are not Comparable, or
1591 <     *         are not mutually comparable.
1592 <     * @throws NullPointerException if the specified map is <tt>null</tt>.
1591 >     *         are not mutually comparable
1592 >     * @throws NullPointerException if the specified map is {@code null}
1593       */
1594      public ConcurrentSkipListMap(Map<? extends K, ? extends V> m) {
1595          this.comparator = null;
# Line 1599 | Line 1599 | public class ConcurrentSkipListMap<K,V>
1599  
1600      /**
1601       * Constructs a new map containing the same mappings as the given
1602 <     * <tt>SortedMap</tt>, sorted according to the same ordering.
1602 >     * {@code SortedMap}, sorted according to the same ordering.
1603       * @param m the sorted map whose mappings are to be placed in this
1604 <     * map, and whose comparator is to be used to sort this map.
1604 >     * map, and whose comparator is to be used to sort this map
1605       * @throws NullPointerException if the specified sorted map is
1606 <     * <tt>null</tt>.
1606 >     * {@code null}
1607       */
1608      public ConcurrentSkipListMap(SortedMap<K, ? extends V> m) {
1609          this.comparator = m.comparator();
# Line 1612 | Line 1612 | public class ConcurrentSkipListMap<K,V>
1612      }
1613  
1614      /**
1615 <     * Returns a shallow copy of this <tt>Map</tt> instance. (The keys and
1615 >     * Returns a shallow copy of this {@code Map} instance. (The keys and
1616       * values themselves are not cloned.)
1617       *
1618 <     * @return a shallow copy of this Map.
1618 >     * @return a shallow copy of this Map
1619       */
1620      public Object clone() {
1621          ConcurrentSkipListMap<K,V> clone = null;
# Line 1689 | Line 1689 | public class ConcurrentSkipListMap<K,V>
1689      /* ---------------- Serialization -------------- */
1690  
1691      /**
1692 <     * Save the state of the <tt>Map</tt> instance to a stream.
1692 >     * Saves the state of the {@code Map} instance to a stream.
1693       *
1694       * @serialData The key (Object) and value (Object) for each
1695       * key-value mapping represented by the Map, followed by
1696 <     * <tt>null</tt>. The key-value mappings are emitted in key-order
1696 >     * {@code null}. The key-value mappings are emitted in key-order
1697       * (as determined by the Comparator, or by the keys' natural
1698       * ordering if no Comparator).
1699       */
# Line 1714 | Line 1714 | public class ConcurrentSkipListMap<K,V>
1714      }
1715  
1716      /**
1717 <     * Reconstitute the <tt>Map</tt> instance from a stream.
1717 >     * Reconstitutes the {@code Map} instance from a stream.
1718       */
1719      private void readObject(final java.io.ObjectInputStream s)
1720          throws java.io.IOException, ClassNotFoundException {
# Line 1728 | Line 1728 | public class ConcurrentSkipListMap<K,V>
1728           * distinct because readObject calls can't be nicely adapted
1729           * as the kind of iterator needed by buildFromSorted. (They
1730           * can be, but doing so requires type cheats and/or creation
1731 <         * of adaptor classes.) It is simpler to just adapt the code.
1731 >         * of adapter classes.) It is simpler to just adapt the code.
1732           */
1733  
1734          HeadIndex<K,V> h = head;
# Line 1777 | Line 1777 | public class ConcurrentSkipListMap<K,V>
1777      /* ------ Map API methods ------ */
1778  
1779      /**
1780 <     * Returns <tt>true</tt> if this map contains a mapping for the specified
1780 >     * Returns {@code true} if this map contains a mapping for the specified
1781       * key.
1782 <     * @param key key whose presence in this map is to be tested.
1783 <     * @return <tt>true</tt> if this map contains a mapping for the
1784 <     *            specified key.
1782 >     * @param key key whose presence in this map is to be tested
1783 >     * @return {@code true} if this map contains a mapping for the
1784 >     *            specified key
1785       * @throws ClassCastException if the key cannot be compared with the keys
1786 <     *                  currently in the map.
1787 <     * @throws NullPointerException if the key is <tt>null</tt>.
1786 >     *                  currently in the map
1787 >     * @throws NullPointerException if the key is {@code null}
1788       */
1789      public boolean containsKey(Object key) {
1790          return doGet(key) != null;
# Line 1792 | Line 1792 | public class ConcurrentSkipListMap<K,V>
1792  
1793      /**
1794       * Returns the value to which this map maps the specified key.  Returns
1795 <     * <tt>null</tt> if the map contains no mapping for this key.
1795 >     * {@code null} if the map contains no mapping for this key.
1796       *
1797 <     * @param key key whose associated value is to be returned.
1797 >     * @param key key whose associated value is to be returned
1798       * @return the value to which this map maps the specified key, or
1799 <     *               <tt>null</tt> if the map contains no mapping for the key.
1799 >     *               {@code null} if the map contains no mapping for the key
1800       * @throws ClassCastException if the key cannot be compared with the keys
1801 <     *                  currently in the map.
1802 <     * @throws NullPointerException if the key is <tt>null</tt>.
1801 >     *                  currently in the map
1802 >     * @throws NullPointerException if the key is {@code null}
1803       */
1804      public V get(Object key) {
1805          return doGet(key);
# Line 1810 | Line 1810 | public class ConcurrentSkipListMap<K,V>
1810       * If the map previously contained a mapping for this key, the old
1811       * value is replaced.
1812       *
1813 <     * @param key key with which the specified value is to be associated.
1814 <     * @param value value to be associated with the specified key.
1813 >     * @param key key with which the specified value is to be associated
1814 >     * @param value value to be associated with the specified key
1815       *
1816 <     * @return previous value associated with specified key, or <tt>null</tt>
1817 <     *         if there was no mapping for key.
1816 >     * @return previous value associated with specified key, or {@code null}
1817 >     *         if there was no mapping for key
1818       * @throws ClassCastException if the key cannot be compared with the keys
1819 <     *            currently in the map.
1820 <     * @throws NullPointerException if the key or value are <tt>null</tt>.
1819 >     *            currently in the map
1820 >     * @throws NullPointerException if the key or value are {@code null}
1821       */
1822      public V put(K key, V value) {
1823          if (value == null)
# Line 1829 | Line 1829 | public class ConcurrentSkipListMap<K,V>
1829       * Removes the mapping for this key from this Map if present.
1830       *
1831       * @param  key key for which mapping should be removed
1832 <     * @return previous value associated with specified key, or <tt>null</tt>
1833 <     *         if there was no mapping for key.
1832 >     * @return previous value associated with specified key, or {@code null}
1833 >     *         if there was no mapping for key
1834       *
1835       * @throws ClassCastException if the key cannot be compared with the keys
1836 <     *            currently in the map.
1837 <     * @throws NullPointerException if the key is <tt>null</tt>.
1836 >     *            currently in the map
1837 >     * @throws NullPointerException if the key is {@code null}
1838       */
1839      public V remove(Object key) {
1840          return doRemove(key, null);
1841      }
1842  
1843      /**
1844 <     * Returns <tt>true</tt> if this map maps one or more keys to the
1844 >     * Returns {@code true} if this map maps one or more keys to the
1845       * specified value.  This operation requires time linear in the
1846       * Map size.
1847       *
1848 <     * @param value value whose presence in this Map is to be tested.
1849 <     * @return  <tt>true</tt> if a mapping to <tt>value</tt> exists;
1850 <     *          <tt>false</tt> otherwise.
1851 <     * @throws  NullPointerException  if the value is <tt>null</tt>.
1848 >     * @param value value whose presence in this Map is to be tested
1849 >     * @return  {@code true} if a mapping to {@code value} exists;
1850 >     *          {@code false} otherwise
1851 >     * @throws  NullPointerException  if the value is {@code null}
1852       */
1853      public boolean containsValue(Object value) {
1854          if (value == null)
# Line 1863 | Line 1863 | public class ConcurrentSkipListMap<K,V>
1863  
1864      /**
1865       * Returns the number of elements in this map.  If this map
1866 <     * contains more than <tt>Integer.MAX_VALUE</tt> elements, it
1867 <     * returns <tt>Integer.MAX_VALUE</tt>.
1866 >     * contains more than {@code Integer.MAX_VALUE} elements, it
1867 >     * returns {@code Integer.MAX_VALUE}.
1868       *
1869       * <p>Beware that, unlike in most collections, this method is
1870       * <em>NOT</em> a constant-time operation. Because of the
# Line 1875 | Line 1875 | public class ConcurrentSkipListMap<K,V>
1875       * will be inaccurate. Thus, this method is typically not very
1876       * useful in concurrent applications.
1877       *
1878 <     * @return  the number of elements in this map.
1878 >     * @return  the number of elements in this map
1879       */
1880      public int size() {
1881          long count = 0;
# Line 1883 | Line 1883 | public class ConcurrentSkipListMap<K,V>
1883              if (n.getValidValue() != null)
1884                  ++count;
1885          }
1886 <        return (count >= Integer.MAX_VALUE)? Integer.MAX_VALUE : (int)count;
1886 >        return (count >= Integer.MAX_VALUE) ? Integer.MAX_VALUE : (int)count;
1887      }
1888  
1889      /**
1890 <     * Returns <tt>true</tt> if this map contains no key-value mappings.
1891 <     * @return <tt>true</tt> if this map contains no key-value mappings.
1890 >     * Returns {@code true} if this map contains no key-value mappings.
1891 >     * @return {@code true} if this map contains no key-value mappings
1892       */
1893      public boolean isEmpty() {
1894          return findFirst() == null;
# Line 1905 | Line 1905 | public class ConcurrentSkipListMap<K,V>
1905       * Returns a set view of the keys contained in this map.  The set is
1906       * backed by the map, so changes to the map are reflected in the set, and
1907       * vice-versa.  The set supports element removal, which removes the
1908 <     * corresponding mapping from this map, via the <tt>Iterator.remove</tt>,
1909 <     * <tt>Set.remove</tt>, <tt>removeAll</tt>, <tt>retainAll</tt>, and
1910 <     * <tt>clear</tt> operations.  It does not support the <tt>add</tt> or
1911 <     * <tt>addAll</tt> operations.
1912 <     * The view's <tt>iterator</tt> is a "weakly consistent" iterator that
1908 >     * corresponding mapping from this map, via the {@code Iterator.remove},
1909 >     * {@code Set.remove}, {@code removeAll}, {@code retainAll}, and
1910 >     * {@code clear} operations.  It does not support the {@code add} or
1911 >     * {@code addAll} operations.
1912 >     * The view's {@code iterator} is a "weakly consistent" iterator that
1913       * will never throw {@link java.util.ConcurrentModificationException},
1914       * and guarantees to traverse elements as they existed upon
1915       * construction of the iterator, and may (but is not guaranteed to)
1916       * reflect any modifications subsequent to construction.
1917       *
1918 <     * @return a set view of the keys contained in this map.
1918 >     * @return a set view of the keys contained in this map
1919       */
1920      public Set<K> keySet() {
1921          /*
# Line 1936 | Line 1936 | public class ConcurrentSkipListMap<K,V>
1936       * descending order.  The set is backed by the map, so changes to
1937       * the map are reflected in the set, and vice-versa.  The set
1938       * supports element removal, which removes the corresponding
1939 <     * mapping from this map, via the <tt>Iterator.remove</tt>,
1940 <     * <tt>Set.remove</tt>, <tt>removeAll</tt>, <tt>retainAll</tt>,
1941 <     * and <tt>clear</tt> operations.  It does not support the
1942 <     * <tt>add</tt> or <tt>addAll</tt> operations.  The view's
1943 <     * <tt>iterator</tt> is a "weakly consistent" iterator that will
1939 >     * mapping from this map, via the {@code Iterator.remove},
1940 >     * {@code Set.remove}, {@code removeAll}, {@code retainAll},
1941 >     * and {@code clear} operations.  It does not support the
1942 >     * {@code add} or {@code addAll} operations.  The view's
1943 >     * {@code iterator} is a "weakly consistent" iterator that will
1944       * never throw {@link java.util.ConcurrentModificationException},
1945       * and guarantees to traverse elements as they existed upon
1946       * construction of the iterator, and may (but is not guaranteed
1947       * to) reflect any modifications subsequent to construction.
1948       *
1949 <     * @return a set view of the keys contained in this map.
1949 >     * @return a set view of the keys contained in this map
1950       */
1951      public Set<K> descendingKeySet() {
1952          /*
# Line 1967 | Line 1967 | public class ConcurrentSkipListMap<K,V>
1967       * The collection is backed by the map, so changes to the map are
1968       * reflected in the collection, and vice-versa.  The collection
1969       * supports element removal, which removes the corresponding
1970 <     * mapping from this map, via the <tt>Iterator.remove</tt>,
1971 <     * <tt>Collection.remove</tt>, <tt>removeAll</tt>,
1972 <     * <tt>retainAll</tt>, and <tt>clear</tt> operations.  It does not
1973 <     * support the <tt>add</tt> or <tt>addAll</tt> operations.  The
1974 <     * view's <tt>iterator</tt> is a "weakly consistent" iterator that
1970 >     * mapping from this map, via the {@code Iterator.remove},
1971 >     * {@code Collection.remove}, {@code removeAll},
1972 >     * {@code retainAll}, and {@code clear} operations.  It does not
1973 >     * support the {@code add} or {@code addAll} operations.  The
1974 >     * view's {@code iterator} is a "weakly consistent" iterator that
1975       * will never throw {@link
1976       * java.util.ConcurrentModificationException}, and guarantees to
1977       * traverse elements as they existed upon construction of the
1978       * iterator, and may (but is not guaranteed to) reflect any
1979       * modifications subsequent to construction.
1980       *
1981 <     * @return a collection view of the values contained in this map.
1981 >     * @return a collection view of the values contained in this map
1982       */
1983      public Collection<V> values() {
1984          Values vs = values;
# Line 1988 | Line 1988 | public class ConcurrentSkipListMap<K,V>
1988      /**
1989       * Returns a collection view of the mappings contained in this
1990       * map.  Each element in the returned collection is a
1991 <     * <tt>Map.Entry</tt>.  The collection is backed by the map, so
1991 >     * {@code Map.Entry}.  The collection is backed by the map, so
1992       * changes to the map are reflected in the collection, and
1993       * vice-versa.  The collection supports element removal, which
1994       * removes the corresponding mapping from the map, via the
1995 <     * <tt>Iterator.remove</tt>, <tt>Collection.remove</tt>,
1996 <     * <tt>removeAll</tt>, <tt>retainAll</tt>, and <tt>clear</tt>
1997 <     * operations.  It does not support the <tt>add</tt> or
1998 <     * <tt>addAll</tt> operations.  The view's <tt>iterator</tt> is a
1995 >     * {@code Iterator.remove}, {@code Collection.remove},
1996 >     * {@code removeAll}, {@code retainAll}, and {@code clear}
1997 >     * operations.  It does not support the {@code add} or
1998 >     * {@code addAll} operations.  The view's {@code iterator} is a
1999       * "weakly consistent" iterator that will never throw {@link
2000       * java.util.ConcurrentModificationException}, and guarantees to
2001       * traverse elements as they existed upon construction of the
2002       * iterator, and may (but is not guaranteed to) reflect any
2003       * modifications subsequent to construction. The
2004 <     * <tt>Map.Entry</tt> elements returned by
2005 <     * <tt>iterator.next()</tt> do <em>not</em> support the
2006 <     * <tt>setValue</tt> operation.
2004 >     * {@code Map.Entry} elements returned by
2005 >     * {@code iterator.next()} do <em>not</em> support the
2006 >     * {@code setValue} operation.
2007       *
2008 <     * @return a collection view of the mappings contained in this map.
2008 >     * @return a collection view of the mappings contained in this map
2009       */
2010      public Set<Map.Entry<K,V>> entrySet() {
2011          EntrySet es = entrySet;
# Line 2015 | Line 2015 | public class ConcurrentSkipListMap<K,V>
2015      /**
2016       * Returns a collection view of the mappings contained in this
2017       * map, in descending order.  Each element in the returned
2018 <     * collection is a <tt>Map.Entry</tt>.  The collection is backed
2018 >     * collection is a {@code Map.Entry}.  The collection is backed
2019       * by the map, so changes to the map are reflected in the
2020       * collection, and vice-versa.  The collection supports element
2021       * removal, which removes the corresponding mapping from the map,
2022 <     * via the <tt>Iterator.remove</tt>, <tt>Collection.remove</tt>,
2023 <     * <tt>removeAll</tt>, <tt>retainAll</tt>, and <tt>clear</tt>
2024 <     * operations.  It does not support the <tt>add</tt> or
2025 <     * <tt>addAll</tt> operations.  The view's <tt>iterator</tt> is a
2022 >     * via the {@code Iterator.remove}, {@code Collection.remove},
2023 >     * {@code removeAll}, {@code retainAll}, and {@code clear}
2024 >     * operations.  It does not support the {@code add} or
2025 >     * {@code addAll} operations.  The view's {@code iterator} is a
2026       * "weakly consistent" iterator that will never throw {@link
2027       * java.util.ConcurrentModificationException}, and guarantees to
2028       * traverse elements as they existed upon construction of the
2029       * iterator, and may (but is not guaranteed to) reflect any
2030       * modifications subsequent to construction. The
2031 <     * <tt>Map.Entry</tt> elements returned by
2032 <     * <tt>iterator.next()</tt> do <em>not</em> support the
2033 <     * <tt>setValue</tt> operation.
2031 >     * {@code Map.Entry} elements returned by
2032 >     * {@code iterator.next()} do <em>not</em> support the
2033 >     * {@code setValue} operation.
2034       *
2035 <     * @return a collection view of the mappings contained in this map.
2035 >     * @return a collection view of the mappings contained in this map
2036       */
2037      public Set<Map.Entry<K,V>> descendingEntrySet() {
2038          DescendingEntrySet es = descendingEntrySet;
# Line 2043 | Line 2043 | public class ConcurrentSkipListMap<K,V>
2043  
2044      /**
2045       * Compares the specified object with this map for equality.
2046 <     * Returns <tt>true</tt> if the given object is also a map and the
2046 >     * Returns {@code true} if the given object is also a map and the
2047       * two maps represent the same mappings.  More formally, two maps
2048 <     * <tt>t1</tt> and <tt>t2</tt> represent the same mappings if
2049 <     * <tt>t1.keySet().equals(t2.keySet())</tt> and for every key
2050 <     * <tt>k</tt> in <tt>t1.keySet()</tt>, <tt> (t1.get(k)==null ?
2051 <     * t2.get(k)==null : t1.get(k).equals(t2.get(k))) </tt>.  This
2048 >     * {@code t1} and {@code t2} represent the same mappings if
2049 >     * {@code t1.keySet().equals(t2.keySet())} and for every key
2050 >     * {@code k} in {@code t1.keySet()}, {@code  (t1.get(k)==null ?
2051 >     * t2.get(k)==null : t1.get(k).equals(t2.get(k))) }.  This
2052       * operation may return misleading results if either map is
2053       * concurrently modified during execution of this method.
2054       *
2055 <     * @param o object to be compared for equality with this map.
2056 <     * @return <tt>true</tt> if the specified object is equal to this map.
2055 >     * @param o object to be compared for equality with this map
2056 >     * @return {@code true} if the specified object is equal to this map
2057       */
2058      public boolean equals(Object o) {
2059 <        if (o == this)
2060 <            return true;
2061 <        if (!(o instanceof Map))
2062 <            return false;
2063 <        Map<K,V> t = (Map<K,V>) o;
2059 >        if (o == this)
2060 >            return true;
2061 >        if (!(o instanceof Map))
2062 >            return false;
2063 >        Map<K,V> t = (Map<K,V>) o;
2064          try {
2065              return (containsAllMappings(this, t) &&
2066                      containsAllMappings(t, this));
2067 <        } catch(ClassCastException unused) {
2067 >        } catch (ClassCastException unused) {
2068              return false;
2069 <        } catch(NullPointerException unused) {
2069 >        } catch (NullPointerException unused) {
2070              return false;
2071          }
2072      }
# Line 2094 | Line 2094 | public class ConcurrentSkipListMap<K,V>
2094       * This is equivalent to
2095       * <pre>
2096       *   if (!map.containsKey(key))
2097 <     *      return map.put(key, value);
2097 >     *     return map.put(key, value);
2098       *   else
2099 <     *      return map.get(key);
2099 >     *     return map.get(key);
2100       * </pre>
2101       * except that the action is performed atomically.
2102 <     * @param key key with which the specified value is to be associated.
2103 <     * @param value value to be associated with the specified key.
2104 <     * @return previous value associated with specified key, or <tt>null</tt>
2105 <     *         if there was no mapping for key.
2102 >     * @param key key with which the specified value is to be associated
2103 >     * @param value value to be associated with the specified key
2104 >     * @return previous value associated with specified key, or {@code null}
2105 >     *         if there was no mapping for key
2106       *
2107       * @throws ClassCastException if the key cannot be compared with the keys
2108 <     *            currently in the map.
2109 <     * @throws NullPointerException if the key or value are <tt>null</tt>.
2108 >     *            currently in the map
2109 >     * @throws NullPointerException if the key or value are {@code null}
2110       */
2111      public V putIfAbsent(K key, V value) {
2112          if (value == null)
# Line 2115 | Line 2115 | public class ConcurrentSkipListMap<K,V>
2115      }
2116  
2117      /**
2118 <     * Remove entry for key only if currently mapped to given value.
2118 >     * Removes entry for key only if currently mapped to given value.
2119       * Acts as
2120       * <pre>
2121       *  if ((map.containsKey(key) && map.get(key).equals(value)) {
# Line 2124 | Line 2124 | public class ConcurrentSkipListMap<K,V>
2124       * } else return false;
2125       * </pre>
2126       * except that the action is performed atomically.
2127 <     * @param key key with which the specified value is associated.
2128 <     * @param value value associated with the specified key.
2127 >     * @param key key with which the specified value is associated
2128 >     * @param value value associated with the specified key
2129       * @return true if the value was removed, false otherwise
2130       * @throws ClassCastException if the key cannot be compared with the keys
2131 <     *            currently in the map.
2132 <     * @throws NullPointerException if the key or value are <tt>null</tt>.
2131 >     *            currently in the map
2132 >     * @throws NullPointerException if the key or value are {@code null}
2133       */
2134      public boolean remove(Object key, Object value) {
2135          if (value == null)
# Line 2138 | Line 2138 | public class ConcurrentSkipListMap<K,V>
2138      }
2139  
2140      /**
2141 <     * Replace entry for key only if currently mapped to given value.
2141 >     * Replaces entry for key only if currently mapped to given value.
2142       * Acts as
2143       * <pre>
2144       *  if ((map.containsKey(key) && map.get(key).equals(oldValue)) {
# Line 2147 | Line 2147 | public class ConcurrentSkipListMap<K,V>
2147       * } else return false;
2148       * </pre>
2149       * except that the action is performed atomically.
2150 <     * @param key key with which the specified value is associated.
2151 <     * @param oldValue value expected to be associated with the specified key.
2152 <     * @param newValue value to be associated with the specified key.
2150 >     * @param key key with which the specified value is associated
2151 >     * @param oldValue value expected to be associated with the specified key
2152 >     * @param newValue value to be associated with the specified key
2153       * @return true if the value was replaced
2154       * @throws ClassCastException if the key cannot be compared with the keys
2155 <     *            currently in the map.
2155 >     *            currently in the map
2156       * @throws NullPointerException if key, oldValue or newValue are
2157 <     * <tt>null</tt>.
2157 >     * {@code null}
2158       */
2159      public boolean replace(K key, V oldValue, V newValue) {
2160          if (oldValue == null || newValue == null)
# Line 2175 | Line 2175 | public class ConcurrentSkipListMap<K,V>
2175      }
2176  
2177      /**
2178 <     * Replace entry for key only if currently mapped to some value.
2178 >     * Replaces entry for key only if currently mapped to some value.
2179       * Acts as
2180       * <pre>
2181       *  if ((map.containsKey(key)) {
# Line 2183 | Line 2183 | public class ConcurrentSkipListMap<K,V>
2183       * } else return null;
2184       * </pre>
2185       * except that the action is performed atomically.
2186 <     * @param key key with which the specified value is associated.
2187 <     * @param value value to be associated with the specified key.
2188 <     * @return previous value associated with specified key, or <tt>null</tt>
2189 <     *         if there was no mapping for key.
2186 >     * @param key key with which the specified value is associated
2187 >     * @param value value to be associated with the specified key
2188 >     * @return previous value associated with specified key, or {@code null}
2189 >     *         if there was no mapping for key
2190       * @throws ClassCastException if the key cannot be compared with the keys
2191 <     *            currently in the map.
2192 <     * @throws NullPointerException if the key or value are <tt>null</tt>.
2191 >     *            currently in the map
2192 >     * @throws NullPointerException if the key or value are {@code null}
2193       */
2194      public V replace(K key, V value) {
2195          if (value == null)
# Line 2208 | Line 2208 | public class ConcurrentSkipListMap<K,V>
2208      /* ------ SortedMap API methods ------ */
2209  
2210      /**
2211 <     * Returns the comparator used to order this map, or <tt>null</tt>
2211 >     * Returns the comparator used to order this map, or {@code null}
2212       * if this map uses its keys' natural order.
2213       *
2214       * @return the comparator associated with this map, or
2215 <     * <tt>null</tt> if it uses its keys' natural sort method.
2215 >     * {@code null} if it uses its keys' natural sort method
2216       */
2217      public Comparator<? super K> comparator() {
2218          return comparator;
# Line 2221 | Line 2221 | public class ConcurrentSkipListMap<K,V>
2221      /**
2222       * Returns the first (lowest) key currently in this map.
2223       *
2224 <     * @return the first (lowest) key currently in this map.
2225 <     * @throws    NoSuchElementException Map is empty.
2224 >     * @return the first (lowest) key currently in this map
2225 >     * @throws    NoSuchElementException Map is empty
2226       */
2227      public K firstKey() {
2228          Node<K,V> n = findFirst();
# Line 2234 | Line 2234 | public class ConcurrentSkipListMap<K,V>
2234      /**
2235       * Returns the last (highest) key currently in this map.
2236       *
2237 <     * @return the last (highest) key currently in this map.
2238 <     * @throws    NoSuchElementException Map is empty.
2237 >     * @return the last (highest) key currently in this map
2238 >     * @throws    NoSuchElementException Map is empty
2239       */
2240      public K lastKey() {
2241          Node<K,V> n = findLast();
# Line 2246 | Line 2246 | public class ConcurrentSkipListMap<K,V>
2246  
2247      /**
2248       * Returns a view of the portion of this map whose keys range from
2249 <     * <tt>fromKey</tt>, inclusive, to <tt>toKey</tt>, exclusive.  (If
2250 <     * <tt>fromKey</tt> and <tt>toKey</tt> are equal, the returned sorted map
2249 >     * {@code fromKey}, inclusive, to {@code toKey}, exclusive.  (If
2250 >     * {@code fromKey} and {@code toKey} are equal, the returned sorted map
2251       * is empty.)  The returned sorted map is backed by this map, so changes
2252       * in the returned sorted map are reflected in this map, and vice-versa.
2253 <
2254 <     * @param fromKey low endpoint (inclusive) of the subMap.
2255 <     * @param toKey high endpoint (exclusive) of the subMap.
2253 >     *
2254 >     * @param fromKey low endpoint (inclusive) of the subMap
2255 >     * @param toKey high endpoint (exclusive) of the subMap
2256       *
2257       * @return a view of the portion of this map whose keys range from
2258 <     * <tt>fromKey</tt>, inclusive, to <tt>toKey</tt>, exclusive.
2258 >     * {@code fromKey}, inclusive, to {@code toKey}, exclusive
2259       *
2260 <     * @throws ClassCastException if <tt>fromKey</tt> and <tt>toKey</tt>
2260 >     * @throws ClassCastException if {@code fromKey} and {@code toKey}
2261       *         cannot be compared to one another using this map's comparator
2262 <     *         (or, if the map has no comparator, using natural ordering).
2263 <     * @throws IllegalArgumentException if <tt>fromKey</tt> is greater than
2264 <     *         <tt>toKey</tt>.
2265 <     * @throws NullPointerException if <tt>fromKey</tt> or <tt>toKey</tt> is
2266 <     *               <tt>null</tt>.
2262 >     *         (or, if the map has no comparator, using natural ordering)
2263 >     * @throws IllegalArgumentException if {@code fromKey} is greater than
2264 >     *         {@code toKey}
2265 >     * @throws NullPointerException if {@code fromKey} or {@code toKey} is
2266 >     *               {@code null}
2267       */
2268      public ConcurrentNavigableMap<K,V> subMap(K fromKey, K toKey) {
2269          if (fromKey == null || toKey == null)
# Line 2273 | Line 2273 | public class ConcurrentSkipListMap<K,V>
2273  
2274      /**
2275       * Returns a view of the portion of this map whose keys are
2276 <     * strictly less than <tt>toKey</tt>.  The returned sorted map is
2276 >     * strictly less than {@code toKey}.  The returned sorted map is
2277       * backed by this map, so changes in the returned sorted map are
2278       * reflected in this map, and vice-versa.
2279 <     * @param toKey high endpoint (exclusive) of the headMap.
2279 >     * @param toKey high endpoint (exclusive) of the headMap
2280       * @return a view of the portion of this map whose keys are
2281 <     * strictly less than <tt>toKey</tt>.
2281 >     * strictly less than {@code toKey}
2282       *
2283 <     * @throws ClassCastException if <tt>toKey</tt> is not compatible
2283 >     * @throws ClassCastException if {@code toKey} is not compatible
2284       * with this map's comparator (or, if the map has no comparator,
2285 <     * if <tt>toKey</tt> does not implement <tt>Comparable</tt>).
2286 <     * @throws NullPointerException if <tt>toKey</tt> is <tt>null</tt>.
2285 >     * if {@code toKey} does not implement {@code Comparable})
2286 >     * @throws NullPointerException if {@code toKey} is {@code null}
2287       */
2288      public ConcurrentNavigableMap<K,V> headMap(K toKey) {
2289          if (toKey == null)
# Line 2293 | Line 2293 | public class ConcurrentSkipListMap<K,V>
2293  
2294      /**
2295       * Returns a view of the portion of this map whose keys are
2296 <     * greater than or equal to <tt>fromKey</tt>.  The returned sorted
2296 >     * greater than or equal to {@code fromKey}.  The returned sorted
2297       * map is backed by this map, so changes in the returned sorted
2298       * map are reflected in this map, and vice-versa.
2299 <     * @param fromKey low endpoint (inclusive) of the tailMap.
2299 >     * @param fromKey low endpoint (inclusive) of the tailMap
2300       * @return a view of the portion of this map whose keys are
2301 <     * greater than or equal to <tt>fromKey</tt>.
2302 <     * @throws ClassCastException if <tt>fromKey</tt> is not
2301 >     * greater than or equal to {@code fromKey}
2302 >     * @throws ClassCastException if {@code fromKey} is not
2303       * compatible with this map's comparator (or, if the map has no
2304 <     * comparator, if <tt>fromKey</tt> does not implement
2305 <     * <tt>Comparable</tt>).
2306 <     * @throws NullPointerException if <tt>fromKey</tt> is <tt>null</tt>.
2304 >     * comparator, if {@code fromKey} does not implement
2305 >     * {@code Comparable})
2306 >     * @throws NullPointerException if {@code fromKey} is {@code null}
2307       */
2308 <    public ConcurrentNavigableMap<K,V>  tailMap(K fromKey) {
2308 >    public ConcurrentNavigableMap<K,V> tailMap(K fromKey) {
2309          if (fromKey == null)
2310              throw new NullPointerException();
2311          return new ConcurrentSkipListSubMap(this, fromKey, null);
# Line 2315 | Line 2315 | public class ConcurrentSkipListMap<K,V>
2315  
2316      /**
2317       * Returns a key-value mapping associated with the least key
2318 <     * greater than or equal to the given key, or <tt>null</tt> if
2318 >     * greater than or equal to the given key, or {@code null} if
2319       * there is no such entry. The returned entry does <em>not</em>
2320 <     * support the <tt>Entry.setValue</tt> method.
2320 >     * support the {@code Entry.setValue} method.
2321       *
2322 <     * @param key the key.
2322 >     * @param key the key
2323       * @return an Entry associated with ceiling of given key, or
2324 <     * <tt>null</tt> if there is no such Entry.
2324 >     * {@code null} if there is no such Entry
2325       * @throws ClassCastException if key cannot be compared with the
2326 <     * keys currently in the map.
2327 <     * @throws NullPointerException if key is <tt>null</tt>.
2326 >     * keys currently in the map
2327 >     * @throws NullPointerException if key is {@code null}
2328       */
2329      public Map.Entry<K,V> ceilingEntry(K key) {
2330          return getNear(key, GT|EQ);
# Line 2332 | Line 2332 | public class ConcurrentSkipListMap<K,V>
2332  
2333      /**
2334       * Returns least key greater than or equal to the given key, or
2335 <     * <tt>null</tt> if there is no such key.
2335 >     * {@code null} if there is no such key.
2336       *
2337 <     * @param key the key.
2338 <     * @return the ceiling key, or <tt>null</tt>
2339 <     * if there is no such key.
2337 >     * @param key the key
2338 >     * @return the ceiling key, or {@code null}
2339 >     * if there is no such key
2340       * @throws ClassCastException if key cannot be compared with the keys
2341 <     *            currently in the map.
2342 <     * @throws NullPointerException if key is <tt>null</tt>.
2341 >     *            currently in the map
2342 >     * @throws NullPointerException if key is {@code null}
2343       */
2344      public K ceilingKey(K key) {
2345          Node<K,V> n = findNear(key, GT|EQ);
2346 <        return (n == null)? null : n.key;
2346 >        return (n == null) ? null : n.key;
2347      }
2348  
2349      /**
2350       * Returns a key-value mapping associated with the greatest
2351 <     * key strictly less than the given key, or <tt>null</tt> if there is no
2351 >     * key strictly less than the given key, or {@code null} if there is no
2352       * such entry. The returned entry does <em>not</em> support
2353 <     * the <tt>Entry.setValue</tt> method.
2353 >     * the {@code Entry.setValue} method.
2354       *
2355 <     * @param key the key.
2355 >     * @param key the key
2356       * @return an Entry with greatest key less than the given
2357 <     * key, or <tt>null</tt> if there is no such Entry.
2357 >     * key, or {@code null} if there is no such Entry
2358       * @throws ClassCastException if key cannot be compared with the keys
2359 <     *            currently in the map.
2360 <     * @throws NullPointerException if key is <tt>null</tt>.
2359 >     *            currently in the map
2360 >     * @throws NullPointerException if key is {@code null}
2361       */
2362      public Map.Entry<K,V> lowerEntry(K key) {
2363          return getNear(key, LT);
# Line 2365 | Line 2365 | public class ConcurrentSkipListMap<K,V>
2365  
2366      /**
2367       * Returns the greatest key strictly less than the given key, or
2368 <     * <tt>null</tt> if there is no such key.
2368 >     * {@code null} if there is no such key.
2369       *
2370 <     * @param key the key.
2370 >     * @param key the key
2371       * @return the greatest key less than the given
2372 <     * key, or <tt>null</tt> if there is no such key.
2372 >     * key, or {@code null} if there is no such key
2373       * @throws ClassCastException if key cannot be compared with the keys
2374 <     *            currently in the map.
2375 <     * @throws NullPointerException if key is <tt>null</tt>.
2374 >     *            currently in the map
2375 >     * @throws NullPointerException if key is {@code null}
2376       */
2377      public K lowerKey(K key) {
2378          Node<K,V> n = findNear(key, LT);
2379 <        return (n == null)? null : n.key;
2379 >        return (n == null) ? null : n.key;
2380      }
2381  
2382      /**
2383       * Returns a key-value mapping associated with the greatest key
2384 <     * less than or equal to the given key, or <tt>null</tt> if there
2384 >     * less than or equal to the given key, or {@code null} if there
2385       * is no such entry. The returned entry does <em>not</em> support
2386 <     * the <tt>Entry.setValue</tt> method.
2386 >     * the {@code Entry.setValue} method.
2387       *
2388 <     * @param key the key.
2389 <     * @return an Entry associated with floor of given key, or <tt>null</tt>
2390 <     * if there is no such Entry.
2388 >     * @param key the key
2389 >     * @return an Entry associated with floor of given key, or {@code null}
2390 >     * if there is no such Entry
2391       * @throws ClassCastException if key cannot be compared with the keys
2392 <     *            currently in the map.
2393 <     * @throws NullPointerException if key is <tt>null</tt>.
2392 >     *            currently in the map
2393 >     * @throws NullPointerException if key is {@code null}
2394       */
2395      public Map.Entry<K,V> floorEntry(K key) {
2396          return getNear(key, LT|EQ);
# Line 2398 | Line 2398 | public class ConcurrentSkipListMap<K,V>
2398  
2399      /**
2400       * Returns the greatest key
2401 <     * less than or equal to the given key, or <tt>null</tt> if there
2401 >     * less than or equal to the given key, or {@code null} if there
2402       * is no such key.
2403       *
2404 <     * @param key the key.
2405 <     * @return the floor of given key, or <tt>null</tt> if there is no
2406 <     * such key.
2404 >     * @param key the key
2405 >     * @return the floor of given key, or {@code null} if there is no
2406 >     * such key
2407       * @throws ClassCastException if key cannot be compared with the keys
2408 <     *            currently in the map.
2409 <     * @throws NullPointerException if key is <tt>null</tt>.
2408 >     *            currently in the map
2409 >     * @throws NullPointerException if key is {@code null}
2410       */
2411      public K floorKey(K key) {
2412          Node<K,V> n = findNear(key, LT|EQ);
2413 <        return (n == null)? null : n.key;
2413 >        return (n == null) ? null : n.key;
2414      }
2415  
2416      /**
2417       * Returns a key-value mapping associated with the least key
2418 <     * strictly greater than the given key, or <tt>null</tt> if there
2418 >     * strictly greater than the given key, or {@code null} if there
2419       * is no such entry. The returned entry does <em>not</em> support
2420 <     * the <tt>Entry.setValue</tt> method.
2420 >     * the {@code Entry.setValue} method.
2421       *
2422 <     * @param key the key.
2422 >     * @param key the key
2423       * @return an Entry with least key greater than the given key, or
2424 <     * <tt>null</tt> if there is no such Entry.
2424 >     * {@code null} if there is no such Entry
2425       * @throws ClassCastException if key cannot be compared with the keys
2426 <     *            currently in the map.
2427 <     * @throws NullPointerException if key is <tt>null</tt>.
2426 >     *            currently in the map
2427 >     * @throws NullPointerException if key is {@code null}
2428       */
2429      public Map.Entry<K,V> higherEntry(K key) {
2430          return getNear(key, GT);
# Line 2432 | Line 2432 | public class ConcurrentSkipListMap<K,V>
2432  
2433      /**
2434       * Returns the least key strictly greater than the given key, or
2435 <     * <tt>null</tt> if there is no such key.
2435 >     * {@code null} if there is no such key.
2436       *
2437 <     * @param key the key.
2437 >     * @param key the key
2438       * @return the least key greater than the given key, or
2439 <     * <tt>null</tt> if there is no such key.
2439 >     * {@code null} if there is no such key
2440       * @throws ClassCastException if key cannot be compared with the keys
2441 <     *            currently in the map.
2442 <     * @throws NullPointerException if key is <tt>null</tt>.
2441 >     *            currently in the map
2442 >     * @throws NullPointerException if key is {@code null}
2443       */
2444      public K higherKey(K key) {
2445          Node<K,V> n = findNear(key, GT);
2446 <        return (n == null)? null : n.key;
2446 >        return (n == null) ? null : n.key;
2447      }
2448  
2449      /**
2450       * Returns a key-value mapping associated with the least
2451 <     * key in this map, or <tt>null</tt> if the map is empty.
2451 >     * key in this map, or {@code null} if the map is empty.
2452       * The returned entry does <em>not</em> support
2453 <     * the <tt>Entry.setValue</tt> method.
2453 >     * the {@code Entry.setValue} method.
2454       *
2455 <     * @return an Entry with least key, or <tt>null</tt>
2456 <     * if the map is empty.
2455 >     * @return an Entry with least key, or {@code null}
2456 >     * if the map is empty
2457       */
2458      public Map.Entry<K,V> firstEntry() {
2459          for (;;) {
# Line 2468 | Line 2468 | public class ConcurrentSkipListMap<K,V>
2468  
2469      /**
2470       * Returns a key-value mapping associated with the greatest
2471 <     * key in this map, or <tt>null</tt> if the map is empty.
2471 >     * key in this map, or {@code null} if the map is empty.
2472       * The returned entry does <em>not</em> support
2473 <     * the <tt>Entry.setValue</tt> method.
2473 >     * the {@code Entry.setValue} method.
2474       *
2475 <     * @return an Entry with greatest key, or <tt>null</tt>
2476 <     * if the map is empty.
2475 >     * @return an Entry with greatest key, or {@code null}
2476 >     * if the map is empty
2477       */
2478      public Map.Entry<K,V> lastEntry() {
2479          for (;;) {
# Line 2488 | Line 2488 | public class ConcurrentSkipListMap<K,V>
2488  
2489      /**
2490       * Removes and returns a key-value mapping associated with
2491 <     * the least key in this map, or <tt>null</tt> if the map is empty.
2491 >     * the least key in this map, or {@code null} if the map is empty.
2492       * The returned entry does <em>not</em> support
2493 <     * the <tt>Entry.setValue</tt> method.
2493 >     * the {@code Entry.setValue} method.
2494       *
2495 <     * @return the removed first entry of this map, or <tt>null</tt>
2496 <     * if the map is empty.
2495 >     * @return the removed first entry of this map, or {@code null}
2496 >     * if the map is empty
2497       */
2498      public Map.Entry<K,V> pollFirstEntry() {
2499          return (SnapshotEntry<K,V>)doRemoveFirst(false);
# Line 2501 | Line 2501 | public class ConcurrentSkipListMap<K,V>
2501  
2502      /**
2503       * Removes and returns a key-value mapping associated with
2504 <     * the greatest key in this map, or <tt>null</tt> if the map is empty.
2504 >     * the greatest key in this map, or {@code null} if the map is empty.
2505       * The returned entry does <em>not</em> support
2506 <     * the <tt>Entry.setValue</tt> method.
2506 >     * the {@code Entry.setValue} method.
2507       *
2508 <     * @return the removed last entry of this map, or <tt>null</tt>
2509 <     * if the map is empty.
2508 >     * @return the removed last entry of this map, or {@code null}
2509 >     * if the map is empty
2510       */
2511      public Map.Entry<K,V> pollLastEntry() {
2512          return (SnapshotEntry<K,V>)doRemoveLast(false);
# Line 2525 | Line 2525 | public class ConcurrentSkipListMap<K,V>
2525          Node<K,V> last;
2526          /** the next node to return from next(); */
2527          Node<K,V> next;
2528 <        /** Cache of next value field to maintain weak consistency */
2529 <        Object nextValue;
2528 >        /** Cache of next value field to maintain weak consistency */
2529 >        Object nextValue;
2530  
2531          Iter() {}
2532  
# Line 2537 | Line 2537 | public class ConcurrentSkipListMap<K,V>
2537          /** initialize ascending iterator for entire range  */
2538          final void initAscending() {
2539              for (;;) {
2540 <                next = findFirst();
2540 >                next = findFirst();
2541                  if (next == null)
2542                      break;
2543                  nextValue = next.value;
# Line 2548 | Line 2548 | public class ConcurrentSkipListMap<K,V>
2548  
2549          /**
2550           * initialize ascending iterator starting at given least key,
2551 <         * or first node if least is <tt>null</tt>, but not greater or
2552 <         * equal to fence, or end if fence is <tt>null</tt>.
2551 >         * or first node if least is {@code null}, but not greater or
2552 >         * equal to fence, or end if fence is {@code null}.
2553           */
2554          final void initAscending(K least, K fence) {
2555              for (;;) {
2556 <                next = findCeiling(least);
2556 >                next = findCeiling(least);
2557                  if (next == null)
2558                      break;
2559                  nextValue = next.value;
# Line 2571 | Line 2571 | public class ConcurrentSkipListMap<K,V>
2571              if ((last = next) == null)
2572                  throw new NoSuchElementException();
2573              for (;;) {
2574 <                next = next.next;
2574 >                next = next.next;
2575                  if (next == null)
2576                      break;
2577                  nextValue = next.value;
# Line 2587 | Line 2587 | public class ConcurrentSkipListMap<K,V>
2587              if ((last = next) == null)
2588                  throw new NoSuchElementException();
2589              for (;;) {
2590 <                next = next.next;
2590 >                next = next.next;
2591                  if (next == null)
2592                      break;
2593                  nextValue = next.value;
# Line 2604 | Line 2604 | public class ConcurrentSkipListMap<K,V>
2604          /** initialize descending iterator for entire range  */
2605          final void initDescending() {
2606              for (;;) {
2607 <                next = findLast();
2607 >                next = findLast();
2608                  if (next == null)
2609                      break;
2610                  nextValue = next.value;
# Line 2616 | Line 2616 | public class ConcurrentSkipListMap<K,V>
2616          /**
2617           * initialize descending iterator starting at key less
2618           * than or equal to given fence key, or
2619 <         * last node if fence is <tt>null</tt>, but not less than
2620 <         * least, or beginning if lest is <tt>null</tt>.
2619 >         * last node if fence is {@code null}, but not less than
2620 >         * least, or beginning if lest is {@code null}.
2621           */
2622          final void initDescending(K least, K fence) {
2623              for (;;) {
2624 <                next = findLower(fence);
2624 >                next = findLower(fence);
2625                  if (next == null)
2626                      break;
2627                  nextValue = next.value;
# Line 2641 | Line 2641 | public class ConcurrentSkipListMap<K,V>
2641                  throw new NoSuchElementException();
2642              K k = last.key;
2643              for (;;) {
2644 <                next = findNear(k, LT);
2644 >                next = findNear(k, LT);
2645                  if (next == null)
2646                      break;
2647                  nextValue = next.value;
# Line 2658 | Line 2658 | public class ConcurrentSkipListMap<K,V>
2658                  throw new NoSuchElementException();
2659              K k = last.key;
2660              for (;;) {
2661 <                next = findNear(k, LT);
2661 >                next = findNear(k, LT);
2662                  if (next == null)
2663                      break;
2664                  nextValue = next.value;
# Line 2781 | Line 2781 | public class ConcurrentSkipListMap<K,V>
2781              Object v = lastValue;
2782              if (last == null || v == null)
2783                  throw new IllegalStateException();
2784 <            return (V)v;
2784 >            return (V)v;
2785          }
2786  
2787          public V setValue(V value) {
# Line 2810 | Line 2810 | public class ConcurrentSkipListMap<K,V>
2810              // If not acting as entry, just use default.
2811              if (last == null)
2812                  return super.toString();
2813 <            return getKey() + "=" + getValue();
2813 >            return getKey() + "=" + getValue();
2814          }
2815      }
2816  
# Line 2842 | Line 2842 | public class ConcurrentSkipListMap<K,V>
2842      }
2843  
2844      final class DescendingEntryIterator extends EntryIter
2845 <        implements Iterator<Map.Entry<K,V>>  {
2845 >        implements Iterator<Map.Entry<K,V>> {
2846          DescendingEntryIterator() {
2847              initDescending();
2848          }
# Line 2854 | Line 2854 | public class ConcurrentSkipListMap<K,V>
2854      }
2855  
2856      final class DescendingSubMapEntryIterator extends EntryIter
2857 <        implements Iterator<Map.Entry<K,V>>  {
2857 >        implements Iterator<Map.Entry<K,V>> {
2858          final K least;
2859          DescendingSubMapEntryIterator(K least, K fence) {
2860              initDescending(least, fence);
# Line 3025 | Line 3025 | public class ConcurrentSkipListMap<K,V>
3025       * underlying maps, differing in that mappings outside their range are
3026       * ignored, and attempts to add mappings outside their ranges result
3027       * in {@link IllegalArgumentException}.  Instances of this class are
3028 <     * constructed only using the <tt>subMap</tt>, <tt>headMap</tt>, and
3029 <     * <tt>tailMap</tt> methods of their underlying maps.
3028 >     * constructed only using the {@code subMap}, {@code headMap}, and
3029 >     * {@code tailMap} methods of their underlying maps.
3030       */
3031      static class ConcurrentSkipListSubMap<K,V> extends AbstractMap<K,V>
3032          implements ConcurrentNavigableMap<K,V>, java.io.Serializable {
# Line 3048 | Line 3048 | public class ConcurrentSkipListMap<K,V>
3048  
3049          /**
3050           * Creates a new submap.
3051 <         * @param least inclusive least value, or <tt>null</tt> if from start
3052 <         * @param fence exclusive upper bound or <tt>null</tt> if to end
3053 <         * @throws IllegalArgumentException if least and fence nonnull
3051 >         * @param least inclusive least value, or {@code null} if from start
3052 >         * @param fence exclusive upper bound, or {@code null} if to end
3053 >         * @throws IllegalArgumentException if least and fence non-null
3054           *  and least greater than fence
3055           */
3056          ConcurrentSkipListSubMap(ConcurrentSkipListMap<K,V> map,
# Line 3095 | Line 3095 | public class ConcurrentSkipListMap<K,V>
3095          }
3096  
3097          /**
3098 <         * Returns underlying map. Needed by ConcurrentSkipListSet
3098 >         * Returns underlying map. Needed by ConcurrentSkipListSet.
3099           * @return the backing map
3100           */
3101          ConcurrentSkipListMap<K,V> getMap() {
# Line 3103 | Line 3103 | public class ConcurrentSkipListMap<K,V>
3103          }
3104  
3105          /**
3106 <         * Returns least key. Needed by ConcurrentSkipListSet
3107 <         * @return least key or <tt>null</tt> if from start
3106 >         * Returns least key. Needed by ConcurrentSkipListSet.
3107 >         * @return least key, or {@code null} if from start
3108           */
3109          K getLeast() {
3110              return least;
3111          }
3112  
3113          /**
3114 <         * Returns fence key. Needed by ConcurrentSkipListSet
3115 <         * @return fence key or <tt>null</tt> of to end
3114 >         * Returns fence key. Needed by ConcurrentSkipListSet.
3115 >         * @return fence key, or {@code null} if to end
3116           */
3117          K getFence() {
3118              return fence;
# Line 3128 | Line 3128 | public class ConcurrentSkipListMap<K,V>
3128  
3129          public V get(Object key) {
3130              K k = (K)key;
3131 <            return ((!inHalfOpenRange(k)) ? null : m.get(k));
3131 >            return (!inHalfOpenRange(k)) ? null : m.get(k);
3132          }
3133  
3134          public V put(K key, V value) {
# Line 3138 | Line 3138 | public class ConcurrentSkipListMap<K,V>
3138  
3139          public V remove(Object key) {
3140              K k = (K)key;
3141 <            return (!inHalfOpenRange(k))? null : m.remove(k);
3141 >            return (!inHalfOpenRange(k)) ? null : m.remove(k);
3142          }
3143  
3144          public int size() {
# Line 3149 | Line 3149 | public class ConcurrentSkipListMap<K,V>
3149                  if (n.getValidValue() != null)
3150                      ++count;
3151              }
3152 <            return count >= Integer.MAX_VALUE? Integer.MAX_VALUE : (int)count;
3152 >            return (count >= Integer.MAX_VALUE) ?
3153 >                Integer.MAX_VALUE : (int)count;
3154          }
3155  
3156          public boolean isEmpty() {
# Line 3240 | Line 3241 | public class ConcurrentSkipListMap<K,V>
3241              return new ConcurrentSkipListSubMap(m, least, toKey);
3242          }
3243  
3244 <        public  ConcurrentNavigableMap<K,V> tailMap(K fromKey) {
3244 >        public ConcurrentNavigableMap<K,V> tailMap(K fromKey) {
3245              if (fromKey == null)
3246                  throw new NullPointerException();
3247              if (!inOpenRange(fromKey))
# Line 3252 | Line 3253 | public class ConcurrentSkipListMap<K,V>
3253  
3254          public Map.Entry<K,V> ceilingEntry(K key) {
3255              return (SnapshotEntry<K,V>)
3256 <                m.getNear(key, m.GT|m.EQ, least, fence, false);
3256 >                m.getNear(key, GT|EQ, least, fence, false);
3257          }
3258  
3259          public K ceilingKey(K key) {
3260              return (K)
3261 <                m.getNear(key, m.GT|m.EQ, least, fence, true);
3261 >                m.getNear(key, GT|EQ, least, fence, true);
3262          }
3263  
3264          public Map.Entry<K,V> lowerEntry(K key) {
3265              return (SnapshotEntry<K,V>)
3266 <                m.getNear(key, m.LT, least, fence, false);
3266 >                m.getNear(key, LT, least, fence, false);
3267          }
3268  
3269          public K lowerKey(K key) {
3270              return (K)
3271 <                m.getNear(key, m.LT, least, fence, true);
3271 >                m.getNear(key, LT, least, fence, true);
3272          }
3273  
3274          public Map.Entry<K,V> floorEntry(K key) {
3275              return (SnapshotEntry<K,V>)
3276 <                m.getNear(key, m.LT|m.EQ, least, fence, false);
3276 >                m.getNear(key, LT|EQ, least, fence, false);
3277          }
3278  
3279          public K floorKey(K key) {
3280              return (K)
3281 <                m.getNear(key, m.LT|m.EQ, least, fence, true);
3281 >                m.getNear(key, LT|EQ, least, fence, true);
3282          }
3283  
3284  
3285          public Map.Entry<K,V> higherEntry(K key) {
3286              return (SnapshotEntry<K,V>)
3287 <                m.getNear(key, m.GT, least, fence, false);
3287 >                m.getNear(key, GT, least, fence, false);
3288          }
3289  
3290          public K higherKey(K key) {
3291              return (K)
3292 <                m.getNear(key, m.GT, least, fence, true);
3292 >                m.getNear(key, GT, least, fence, true);
3293          }
3294  
3295          public Map.Entry<K,V> firstEntry() {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines