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.14 by jsr166, Sun Oct 21 06:14:11 2012 UTC vs.
Revision 1.15 by jsr166, Sat Dec 29 23:55:19 2012 UTC

# Line 86 | Line 86 | public class ConcurrentSkipListSet<E>
86       * Constructs a new set containing the elements in the specified
87       * collection, sorted according to the elements' <i>natural order</i>.
88       *
89 <     * @param c The elements that will comprise the new set.
89 >     * @param c The elements that will comprise the new set
90       *
91       * @throws ClassCastException if the elements in the specified
92 <     * collection are not comparable, or are not mutually comparable.
92 >     * collection are not comparable, or are not mutually comparable
93       * @throws NullPointerException if the specified collection is
94 <     * <tt>null</tt>.
94 >     * <tt>null</tt>
95       */
96      public ConcurrentSkipListSet(Collection<? extends E> c) {
97          m = new ConcurrentSkipListMap<E,Object>();
# Line 102 | Line 102 | public class ConcurrentSkipListSet<E>
102       * Constructs a new set containing the same elements as the specified
103       * sorted set, sorted according to the same ordering.
104       *
105 <     * @param s sorted set whose elements will comprise the new set.
105 >     * @param s sorted set whose elements will comprise the new set
106       * @throws NullPointerException if the specified sorted set is
107 <     * <tt>null</tt>.
107 >     * <tt>null</tt>
108       */
109      public ConcurrentSkipListSet(SortedSet<E> s) {
110          m = new ConcurrentSkipListMap<E,Object>(s.comparator());
# Line 115 | Line 115 | public class ConcurrentSkipListSet<E>
115       * Returns a shallow copy of this set. (The elements themselves
116       * are not cloned.)
117       *
118 <     * @return a shallow copy of this set.
118 >     * @return a shallow copy of this set
119       */
120      public Object clone() {
121          ConcurrentSkipListSet<E> clone = null;
# Line 146 | Line 146 | public class ConcurrentSkipListSet<E>
146       * will be inaccurate. Thus, this method is typically not very
147       * useful in concurrent applications.
148       *
149 <     * @return  the number of elements in this set.
149 >     * @return  the number of elements in this set
150       */
151      public int size() {
152          return m.size();
# Line 154 | Line 154 | public class ConcurrentSkipListSet<E>
154  
155      /**
156       * Returns <tt>true</tt> if this set contains no elements.
157 <     * @return <tt>true</tt> if this set contains no elements.
157 >     * @return <tt>true</tt> if this set contains no elements
158       */
159      public boolean isEmpty() {
160          return m.isEmpty();
# Line 163 | Line 163 | public class ConcurrentSkipListSet<E>
163      /**
164       * Returns <tt>true</tt> if this set contains the specified element.
165       *
166 <     * @param o the object to be checked for containment in this set.
167 <     * @return <tt>true</tt> if this set contains the specified element.
166 >     * @param o the object to be checked for containment in this set
167 >     * @return <tt>true</tt> if this set contains the specified element
168       *
169       * @throws ClassCastException if the specified object cannot be compared
170 <     *            with the elements currently in the set.
171 <     * @throws NullPointerException if o is <tt>null</tt>.
170 >     *            with the elements currently in the set
171 >     * @throws NullPointerException if o is <tt>null</tt>
172       */
173      public boolean contains(Object o) {
174          return m.containsKey(o);
# Line 177 | Line 177 | public class ConcurrentSkipListSet<E>
177      /**
178       * Adds the specified element to this set if it is not already present.
179       *
180 <     * @param o element to be added to this set.
180 >     * @param o element to be added to this set
181       * @return <tt>true</tt> if the set did not already contain the specified
182 <     *         element.
182 >     *         element
183       *
184       * @throws ClassCastException if the specified object cannot be compared
185 <     *            with the elements currently in the set.
186 <     * @throws NullPointerException if o is <tt>null</tt>.
185 >     *            with the elements currently in the set
186 >     * @throws NullPointerException if o is <tt>null</tt>
187       */
188      public boolean add(E o) {
189          return m.putIfAbsent(o, Boolean.TRUE) == null;
# Line 192 | Line 192 | public class ConcurrentSkipListSet<E>
192      /**
193       * Removes the specified element from this set if it is present.
194       *
195 <     * @param o object to be removed from this set, if present.
196 <     * @return <tt>true</tt> if the set contained the specified element.
195 >     * @param o object to be removed from this set, if present
196 >     * @return <tt>true</tt> if the set contained the specified element
197       *
198       * @throws ClassCastException if the specified object cannot be compared
199 <     *            with the elements currently in the set.
200 <     * @throws NullPointerException if o is <tt>null</tt>.
199 >     *            with the elements currently in the set
200 >     * @throws NullPointerException if o is <tt>null</tt>
201       */
202      public boolean remove(Object o) {
203          return m.removep(o);
# Line 214 | Line 214 | public class ConcurrentSkipListSet<E>
214       * Returns an iterator over the elements in this set.  The elements
215       * are returned in ascending order.
216       *
217 <     * @return an iterator over the elements in this set.
217 >     * @return an iterator over the elements in this set
218       */
219      public Iterator<E> iterator() {
220          return m.keyIterator();
# Line 224 | Line 224 | public class ConcurrentSkipListSet<E>
224       * Returns an iterator over the elements in this set.  The elements
225       * are returned in descending order.
226       *
227 <     * @return an iterator over the elements in this set.
227 >     * @return an iterator over the elements in this set
228       */
229      public Iterator<E> descendingIterator() {
230          return m.descendingKeyIterator();
# Line 241 | Line 241 | public class ConcurrentSkipListSet<E>
241       * equals method works properly across different implementations of the
242       * set interface.
243       *
244 <     * @param o Object to be compared for equality with this set.
245 <     * @return <tt>true</tt> if the specified Object is equal to this set.
244 >     * @param o Object to be compared for equality with this set
245 >     * @return <tt>true</tt> if the specified Object is equal to this set
246       */
247      public boolean equals(Object o) {
248          // Override AbstractSet version to avoid calling size()
# Line 267 | Line 267 | public class ConcurrentSkipListSet<E>
267       * value is the <i>asymmetric set difference</i> of the two sets.
268       *
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.
270 >     *           this set
271 >     * @return <tt>true</tt> if this set changed as a result of the call
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
276 <     * of its elements are <tt>null</tt>.
276 >     * of its elements are <tt>null</tt>
277       */
278      public boolean removeAll(Collection<?> c) {
279          // Override AbstractSet version to avoid unnecessary call to size()
# Line 292 | Line 292 | public class ConcurrentSkipListSet<E>
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.
295 >     * <tt>null</tt> if there is no such element
296       * @throws ClassCastException if o cannot be compared with the elements
297 <     *            currently in the set.
297 >     *            currently in the set
298       * @throws NullPointerException if o is <tt>null</tt>
299       */
300      public E ceiling(E o) {
# Line 307 | Line 307 | public class ConcurrentSkipListSet<E>
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.
310 >     * <tt>null</tt> if there is no such element
311       * @throws ClassCastException if o cannot be compared with the elements
312 <     *            currently in the set.
313 <     * @throws NullPointerException if o is <tt>null</tt>.
312 >     *            currently in the set
313 >     * @throws NullPointerException if o is <tt>null</tt>
314       */
315      public E lower(E o) {
316          return m.lowerKey(o);
# Line 322 | Line 322 | public class ConcurrentSkipListSet<E>
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.
325 >     * element, or <tt>null</tt> if there is no such element
326       * @throws ClassCastException if o cannot be compared with the elements
327 <     *            currently in the set.
328 <     * @throws NullPointerException if o is <tt>null</tt>.
327 >     *            currently in the set
328 >     * @throws NullPointerException if o is <tt>null</tt>
329       */
330      public E floor(E o) {
331          return m.floorKey(o);
# Line 337 | Line 337 | public class ConcurrentSkipListSet<E>
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.
340 >     * <tt>null</tt> if there is no such element
341       * @throws ClassCastException if o cannot be compared with the elements
342 <     *            currently in the set.
343 <     * @throws NullPointerException if o is <tt>null</tt>.
342 >     *            currently in the set
343 >     * @throws NullPointerException if o is <tt>null</tt>
344       */
345      public E higher(E o) {
346          return m.higherKey(o);
# Line 349 | Line 349 | public class ConcurrentSkipListSet<E>
349      /**
350       * Retrieves and removes the first (lowest) element.
351       *
352 <     * @return the least element, or <tt>null</tt> if empty.
352 >     * @return the least element, or <tt>null</tt> if empty
353       */
354      public E pollFirst() {
355          return m.pollFirstKey();
# Line 358 | Line 358 | public class ConcurrentSkipListSet<E>
358      /**
359       * Retrieves and removes the last (highest) element.
360       *
361 <     * @return the last element, or <tt>null</tt> if empty.
361 >     * @return the last element, or <tt>null</tt> if empty
362       */
363      public E pollLast() {
364          return m.pollLastKey();
# Line 373 | Line 373 | public class ConcurrentSkipListSet<E>
373       * if this set uses its elements natural ordering.
374       *
375       * @return the comparator used to order this set, or <tt>null</tt>
376 <     * if this set uses its elements natural ordering.
376 >     * if this set uses its elements natural ordering
377       */
378      public Comparator<? super E> comparator() {
379          return m.comparator();
# Line 382 | Line 382 | public class ConcurrentSkipListSet<E>
382      /**
383       * Returns the first (lowest) element currently in this set.
384       *
385 <     * @return the first (lowest) element currently in this set.
386 <     * @throws    NoSuchElementException sorted set is empty.
385 >     * @return the first (lowest) element currently in this set
386 >     * @throws    NoSuchElementException sorted set is empty
387       */
388      public E first() {
389          return m.firstKey();
# Line 392 | Line 392 | public class ConcurrentSkipListSet<E>
392      /**
393       * Returns the last (highest) element currently in this set.
394       *
395 <     * @return the last (highest) element currently in this set.
396 <     * @throws    NoSuchElementException sorted set is empty.
395 >     * @return the last (highest) element currently in this set
396 >     * @throws    NoSuchElementException sorted set is empty
397       */
398      public E last() {
399          return m.lastKey();
# Line 408 | Line 408 | public class ConcurrentSkipListSet<E>
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.
411 <     * @param fromElement low endpoint (inclusive) of the subSet.
412 <     * @param toElement high endpoint (exclusive) of the subSet.
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
414       *         <tt>fromElement</tt>, inclusive, to <tt>toElement</tt>,
415 <     *         exclusive.
415 >     *         exclusive
416       * @throws ClassCastException if <tt>fromElement</tt> and
417       *         <tt>toElement</tt> cannot be compared to one another using
418       *         this set's comparator (or, if the set has no comparator,
419 <     *         using natural ordering).
419 >     *         using natural ordering)
420       * @throws IllegalArgumentException if <tt>fromElement</tt> is
421 <     * greater than <tt>toElement</tt>.
421 >     * greater than <tt>toElement</tt>
422       * @throws NullPointerException if <tt>fromElement</tt> or
423 <     *         <tt>toElement</tt> is <tt>null</tt>.
423 >     *         <tt>toElement</tt> is <tt>null</tt>
424       */
425      public NavigableSet<E> subSet(E fromElement, E toElement) {
426          return new ConcurrentSkipListSubSet<E>(m, fromElement, toElement);
# Line 431 | Line 431 | public class ConcurrentSkipListSet<E>
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.
434 <     * @param toElement high endpoint (exclusive) of the headSet.
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.
436 >     *         less than toElement
437       * @throws ClassCastException if <tt>toElement</tt> is not compatible
438       *         with this set's comparator (or, if the set has no comparator,
439 <     *         if <tt>toElement</tt> does not implement <tt>Comparable</tt>).
440 <     * @throws NullPointerException if <tt>toElement</tt> is <tt>null</tt>.
439 >     *         if <tt>toElement</tt> does not implement <tt>Comparable</tt>)
440 >     * @throws NullPointerException if <tt>toElement</tt> is <tt>null</tt>
441       */
442      public NavigableSet<E> headSet(E toElement) {
443          return new ConcurrentSkipListSubSet<E>(m, null, toElement);
# Line 449 | Line 449 | public class ConcurrentSkipListSet<E>
449       * greater than or equal to <tt>fromElement</tt>.  The returned
450       * sorted set is backed by this set, so changes in the returned
451       * sorted set are reflected in this set, and vice-versa.
452 <     * @param fromElement low endpoint (inclusive) of the tailSet.
452 >     * @param fromElement low endpoint (inclusive) of the tailSet
453       * @return a view of the portion of this set whose elements are
454 <     * greater than or equal to <tt>fromElement</tt>.
454 >     * greater than or equal to <tt>fromElement</tt>
455       * @throws ClassCastException if <tt>fromElement</tt> is not
456       * compatible with this set's comparator (or, if the set has no
457       * comparator, if <tt>fromElement</tt> does not implement
458 <     * <tt>Comparable</tt>).
459 <     * @throws NullPointerException if <tt>fromElement</tt> is <tt>null</tt>.
458 >     * <tt>Comparable</tt>)
459 >     * @throws NullPointerException if <tt>fromElement</tt> is <tt>null</tt>
460       */
461      public NavigableSet<E> tailSet(E fromElement) {
462          return new ConcurrentSkipListSubSet<E>(m, fromElement, null);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines