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

Comparing jsr166/src/jsr166x/ConcurrentSkipListSet.java (file contents):
Revision 1.6 by dl, Tue Mar 8 17:51:57 2005 UTC vs.
Revision 1.7 by jsr166, Mon Nov 16 04:16:42 2009 UTC

# Line 4 | Line 4
4   * http://creativecommons.org/licenses/publicdomain
5   */
6  
7 < package jsr166x;
7 > package jsr166x;
8  
9   import java.util.*;
10   import java.util.concurrent.*;
# Line 60 | Line 60 | public class ConcurrentSkipListSet<E>
60       * fields of underlying map, but enables this field to be declared
61       * final, which is necessary for thread safety.
62       */
63 <    private final ConcurrentSkipListMap<E,Object> m;
63 >    private final ConcurrentSkipListMap<E,Object> m;
64  
65      /**
66       * Constructs a new, empty set, sorted according to the elements' natural
67 <     * order.
67 >     * order.
68       */
69      public ConcurrentSkipListSet() {
70          m = new ConcurrentSkipListMap<E,Object>();
# Line 72 | Line 72 | public class ConcurrentSkipListSet<E>
72  
73      /**
74       * Constructs a new, empty set, sorted according to the specified
75 <     * comparator.  
75 >     * comparator.
76       *
77       * @param c the comparator that will be used to sort this set.  A
78       *        <tt>null</tt> value indicates that the elements' <i>natural
# Line 259 | Line 259 | public class ConcurrentSkipListSet<E>
259              return false;
260          }
261      }
262 <    
262 >
263      /**
264       * Removes from this set all of its elements that are contained in
265       * the specified collection.  If the specified collection is also
# Line 269 | Line 269 | public class ConcurrentSkipListSet<E>
269       * @param  c collection that defines which elements will be removed from
270       *           this set.
271       * @return <tt>true</tt> if this set changed as a result of the call.
272 <     *
272 >     *
273       * @throws ClassCastException if the types of one or more elements in this
274       *            set are incompatible with the specified collection
275       * @throws NullPointerException if the specified collection, or any
# Line 283 | Line 283 | public class ConcurrentSkipListSet<E>
283                  modified = true;
284          return modified;
285      }
286 <    
286 >
287      /* ---------------- Relational operations -------------- */
288  
289      /**
290       * Returns an element greater than or equal to the given element, or
291       * <tt>null</tt> if there is no such element.
292 <     *
292 >     *
293       * @param o the value to match
294       * @return an element greater than or equal to given element, or
295       * <tt>null</tt> if there is no such element.
# Line 304 | Line 304 | public class ConcurrentSkipListSet<E>
304      /**
305       * Returns an element strictly less than the given element, or
306       * <tt>null</tt> if there is no such element.
307 <     *
307 >     *
308       * @param o the value to match
309       * @return the greatest element less than the given element, or
310       * <tt>null</tt> if there is no such element.
# Line 319 | Line 319 | public class ConcurrentSkipListSet<E>
319      /**
320       * Returns an element less than or equal to the given element, or
321       * <tt>null</tt> if there is no such element.
322 <     *
322 >     *
323       * @param o the value to match
324       * @return the greatest element less than or equal to given
325       * element, or <tt>null</tt> if there is no such element.
# Line 334 | Line 334 | public class ConcurrentSkipListSet<E>
334      /**
335       * Returns an element strictly greater than the given element, or
336       * <tt>null</tt> if there is no such element.
337 <     *
337 >     *
338       * @param o the value to match
339       * @return the least element greater than the given element, or
340       * <tt>null</tt> if there is no such element.
# Line 407 | Line 407 | public class ConcurrentSkipListSet<E>
407       * <tt>fromElement</tt> and <tt>toElement</tt> are equal, the returned
408       * sorted set is empty.)  The returned sorted set is backed by this set,
409       * so changes in the returned sorted set are reflected in this set, and
410 <     * vice-versa.
410 >     * vice-versa.
411       * @param fromElement low endpoint (inclusive) of the subSet.
412       * @param toElement high endpoint (exclusive) of the subSet.
413       * @return a view of the portion of this set whose elements range from
# Line 430 | Line 430 | public class ConcurrentSkipListSet<E>
430       * Returns a view of the portion of this set whose elements are strictly
431       * less than <tt>toElement</tt>.  The returned sorted set is backed by
432       * this set, so changes in the returned sorted set are reflected in this
433 <     * set, and vice-versa.  
433 >     * set, and vice-versa.
434       * @param toElement high endpoint (exclusive) of the headSet.
435       * @return a view of the portion of this set whose elements are strictly
436       *         less than toElement.
# Line 473 | Line 473 | public class ConcurrentSkipListSet<E>
473       * <tt>tailSet</tt> methods of their underlying sets.
474       *
475       */
476 <    static class ConcurrentSkipListSubSet<E>
477 <        extends AbstractSet<E>
476 >    static class ConcurrentSkipListSubSet<E>
477 >        extends AbstractSet<E>
478          implements NavigableSet<E>, java.io.Serializable {
479  
480          private static final long serialVersionUID = -7647078645896651609L;
481  
482          /** The underlying submap  */
483          private final ConcurrentSkipListMap.ConcurrentSkipListSubMap<E,Object> s;
484 <        
484 >
485          /**
486 <         * Creates a new submap.
486 >         * Creates a new submap.
487           * @param fromElement inclusive least value, or <tt>null</tt> if from start
488           * @param toElement exclusive upper bound or <tt>null</tt> if to end
489           * @throws IllegalArgumentException if fromElement and toElement
490           * nonnull and fromElement greater than toElement
491           */
492 <        ConcurrentSkipListSubSet(ConcurrentSkipListMap<E,Object> map,
492 >        ConcurrentSkipListSubSet(ConcurrentSkipListMap<E,Object> map,
493                                   E fromElement, E toElement) {
494              s = new ConcurrentSkipListMap.ConcurrentSkipListSubMap<E,Object>
495                  (map, fromElement, toElement);
# Line 500 | Line 500 | public class ConcurrentSkipListSet<E>
500          public NavigableSet<E> subSet(E fromElement, E toElement) {
501              if (!s.inOpenRange(fromElement) || !s.inOpenRange(toElement))
502                  throw new IllegalArgumentException("element out of range");
503 <            return new ConcurrentSkipListSubSet<E>(s.getMap(),
503 >            return new ConcurrentSkipListSubSet<E>(s.getMap(),
504                                                     fromElement, toElement);
505          }
506  
# Line 508 | Line 508 | public class ConcurrentSkipListSet<E>
508              E least = s.getLeast();
509              if (!s.inOpenRange(toElement))
510                  throw new IllegalArgumentException("element out of range");
511 <            return new ConcurrentSkipListSubSet<E>(s.getMap(),
511 >            return new ConcurrentSkipListSubSet<E>(s.getMap(),
512                                                     least, toElement);
513          }
514 <        
514 >
515          public NavigableSet<E> tailSet(E fromElement) {
516              E fence = s.getFence();
517              if (!s.inOpenRange(fromElement))
518                  throw new IllegalArgumentException("element out of range");
519 <            return new ConcurrentSkipListSubSet<E>(s.getMap(),
519 >            return new ConcurrentSkipListSubSet<E>(s.getMap(),
520                                                     fromElement, fence);
521          }
522  
# Line 539 | Line 539 | public class ConcurrentSkipListSet<E>
539          public Iterator<E> descendingIterator() {
540              return s.descendingKeySet().iterator();
541          }
542 <        public E pollFirst() {
542 >        public E pollFirst() {
543              Map.Entry<E,?> e = s.pollFirstEntry();
544              return (e == null)? null : e.getKey();
545          }
# Line 549 | Line 549 | public class ConcurrentSkipListSet<E>
549          }
550  
551      }
552 < }    
552 > }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines