< prev index next >

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

Print this page




 317      * (http://www.cl.cam.ac.uk/users/kaf24/), and Hakan Sundell's
 318      * thesis (http://www.cs.chalmers.se/~phs/).
 319      *
 320      * Notation guide for local variables
 321      * Node:         b, n, f, p for  predecessor, node, successor, aux
 322      * Index:        q, r, d    for index node, right, down.
 323      * Head:         h
 324      * Keys:         k, key
 325      * Values:       v, value
 326      * Comparisons:  c
 327      */
 328 
 329     private static final long serialVersionUID = -8627078645895051609L;
 330 
 331     /**
 332      * The comparator used to maintain order in this map, or null if
 333      * using natural ordering.  (Non-private to simplify access in
 334      * nested classes.)
 335      * @serial
 336      */

 337     final Comparator<? super K> comparator;
 338 
 339     /** Lazily initialized topmost index of the skiplist. */
 340     private transient Index<K,V> head;
 341     /** Lazily initialized element count */
 342     private transient LongAdder adder;
 343     /** Lazily initialized key set */
 344     private transient KeySet<K,V> keySet;
 345     /** Lazily initialized values collection */
 346     private transient Values<K,V> values;
 347     /** Lazily initialized entry set */
 348     private transient EntrySet<K,V> entrySet;
 349     /** Lazily initialized descending map */
 350     private transient SubMap<K,V> descendingMap;
 351 
 352     /**
 353      * Nodes hold keys and values, and are singly linked in sorted
 354      * order, possibly with some intervening marker nodes. The list is
 355      * headed by a header node accessible as head.node. Headers and
 356      * marker nodes have null keys. The val field (but currently not


2358 
2359     /**
2360      * Submaps returned by {@link ConcurrentSkipListMap} submap operations
2361      * represent a subrange of mappings of their underlying maps.
2362      * Instances of this class support all methods of their underlying
2363      * maps, differing in that mappings outside their range are ignored,
2364      * and attempts to add mappings outside their ranges result in {@link
2365      * IllegalArgumentException}.  Instances of this class are constructed
2366      * only using the {@code subMap}, {@code headMap}, and {@code tailMap}
2367      * methods of their underlying maps.
2368      *
2369      * @serial include
2370      */
2371     static final class SubMap<K,V> extends AbstractMap<K,V>
2372         implements ConcurrentNavigableMap<K,V>, Serializable {
2373         private static final long serialVersionUID = -7647078645895051609L;
2374 
2375         /** Underlying map */
2376         final ConcurrentSkipListMap<K,V> m;
2377         /** lower bound key, or null if from start */

2378         private final K lo;
2379         /** upper bound key, or null if to end */

2380         private final K hi;
2381         /** inclusion flag for lo */
2382         private final boolean loInclusive;
2383         /** inclusion flag for hi */
2384         private final boolean hiInclusive;
2385         /** direction */
2386         final boolean isDescending;
2387 
2388         // Lazily initialized view holders
2389         private transient KeySet<K,V> keySetView;
2390         private transient Values<K,V> valuesView;
2391         private transient EntrySet<K,V> entrySetView;
2392 
2393         /**
2394          * Creates a new submap, initializing all fields.
2395          */
2396         SubMap(ConcurrentSkipListMap<K,V> map,
2397                K fromKey, boolean fromInclusive,
2398                K toKey, boolean toInclusive,
2399                boolean isDescending) {




 317      * (http://www.cl.cam.ac.uk/users/kaf24/), and Hakan Sundell's
 318      * thesis (http://www.cs.chalmers.se/~phs/).
 319      *
 320      * Notation guide for local variables
 321      * Node:         b, n, f, p for  predecessor, node, successor, aux
 322      * Index:        q, r, d    for index node, right, down.
 323      * Head:         h
 324      * Keys:         k, key
 325      * Values:       v, value
 326      * Comparisons:  c
 327      */
 328 
 329     private static final long serialVersionUID = -8627078645895051609L;
 330 
 331     /**
 332      * The comparator used to maintain order in this map, or null if
 333      * using natural ordering.  (Non-private to simplify access in
 334      * nested classes.)
 335      * @serial
 336      */
 337     @SuppressWarnings("serial") // Conditionally serializable
 338     final Comparator<? super K> comparator;
 339 
 340     /** Lazily initialized topmost index of the skiplist. */
 341     private transient Index<K,V> head;
 342     /** Lazily initialized element count */
 343     private transient LongAdder adder;
 344     /** Lazily initialized key set */
 345     private transient KeySet<K,V> keySet;
 346     /** Lazily initialized values collection */
 347     private transient Values<K,V> values;
 348     /** Lazily initialized entry set */
 349     private transient EntrySet<K,V> entrySet;
 350     /** Lazily initialized descending map */
 351     private transient SubMap<K,V> descendingMap;
 352 
 353     /**
 354      * Nodes hold keys and values, and are singly linked in sorted
 355      * order, possibly with some intervening marker nodes. The list is
 356      * headed by a header node accessible as head.node. Headers and
 357      * marker nodes have null keys. The val field (but currently not


2359 
2360     /**
2361      * Submaps returned by {@link ConcurrentSkipListMap} submap operations
2362      * represent a subrange of mappings of their underlying maps.
2363      * Instances of this class support all methods of their underlying
2364      * maps, differing in that mappings outside their range are ignored,
2365      * and attempts to add mappings outside their ranges result in {@link
2366      * IllegalArgumentException}.  Instances of this class are constructed
2367      * only using the {@code subMap}, {@code headMap}, and {@code tailMap}
2368      * methods of their underlying maps.
2369      *
2370      * @serial include
2371      */
2372     static final class SubMap<K,V> extends AbstractMap<K,V>
2373         implements ConcurrentNavigableMap<K,V>, Serializable {
2374         private static final long serialVersionUID = -7647078645895051609L;
2375 
2376         /** Underlying map */
2377         final ConcurrentSkipListMap<K,V> m;
2378         /** lower bound key, or null if from start */
2379         @SuppressWarnings("serial") // Conditionally serializable
2380         private final K lo;
2381         /** upper bound key, or null if to end */
2382         @SuppressWarnings("serial") // Conditionally serializable
2383         private final K hi;
2384         /** inclusion flag for lo */
2385         private final boolean loInclusive;
2386         /** inclusion flag for hi */
2387         private final boolean hiInclusive;
2388         /** direction */
2389         final boolean isDescending;
2390 
2391         // Lazily initialized view holders
2392         private transient KeySet<K,V> keySetView;
2393         private transient Values<K,V> valuesView;
2394         private transient EntrySet<K,V> entrySetView;
2395 
2396         /**
2397          * Creates a new submap, initializing all fields.
2398          */
2399         SubMap(ConcurrentSkipListMap<K,V> map,
2400                K fromKey, boolean fromInclusive,
2401                K toKey, boolean toInclusive,
2402                boolean isDescending) {


< prev index next >