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

Comparing jsr166/src/main/java/util/TreeSet.java (file contents):
Revision 1.16 by jsr166, Sun Jun 19 23:01:12 2005 UTC vs.
Revision 1.20 by jsr166, Tue Feb 7 20:54:24 2006 UTC

# Line 1 | Line 1
1   /*
2   * %W% %E%
3   *
4 < * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
4 > * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
5   * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6   */
7  
8   package java.util;
9 import java.util.*; // for javadoc (till 6280605 is fixed)
9  
10   /**
11   * A {@link NavigableSet} implementation based on a {@link TreeMap}.
# Line 29 | Line 28 | import java.util.*; // for javadoc (till
28   * <i>is</i> well-defined even if its ordering is inconsistent with equals; it
29   * just fails to obey the general contract of the <tt>Set</tt> interface.
30   *
31 < * <p><b>Note that this implementation is not synchronized.</b> If multiple
32 < * threads access a set concurrently, and at least one of the threads modifies
33 < * the set, it <i>must</i> be synchronized externally.  This is typically
34 < * accomplished by synchronizing on some object that naturally encapsulates
35 < * the set.  If no such object exists, the set should be "wrapped" using the
36 < * <tt>Collections.synchronizedSet</tt> method.  This is best done at creation
37 < * time, to prevent accidental unsynchronized access to the set: <pre>
38 < *     SortedSet s = Collections.synchronizedSortedSet(new TreeSet(...));
39 < * </pre>
31 > * <p><strong>Note that this implementation is not synchronized.</strong>
32 > * If multiple threads access a tree set concurrently, and at least one
33 > * of the threads modifies the set, it <i>must</i> be synchronized
34 > * externally.  This is typically accomplished by synchronizing on some
35 > * object that naturally encapsulates the set.
36 > * If no such object exists, the set should be "wrapped" using the
37 > * {@link Collections#synchronizedSortedSet Collections.synchronizedSortedSet}
38 > * method.  This is best done at creation time, to prevent accidental
39 > * unsynchronized access to the set: <pre>
40 > *   SortedSet s = Collections.synchronizedSortedSet(new TreeSet(...));</pre>
41   *
42   * <p>The iterators returned by this class's <tt>iterator</tt> method are
43   * <i>fail-fast</i>: if the set is modified at any time after the iterator is
# Line 68 | Line 68 | import java.util.*; // for javadoc (till
68   * @see     HashSet
69   * @see     Comparable
70   * @see     Comparator
71 * @see     Collections#synchronizedSortedSet(SortedSet)
71   * @see     TreeMap
72   * @since   1.2
73   */
# Line 167 | Line 166 | public class TreeSet<E>
166       * Returns an iterator over the elements in this set in descending order.
167       *
168       * @return an iterator over the elements in this set in descending order
169 +     * @since 1.6
170       */
171      public Iterator<E> descendingIterator() {
172          return m.descendingKeySet().iterator();
# Line 292 | Line 292 | public class TreeSet<E>
292       *         <tt>toElement</tt> is null and this set uses natural ordering,
293       *         or its comparator does not permit null elements
294       * @throws IllegalArgumentException {@inheritDoc}
295 +     * @since 1.6
296       */
297      public NavigableSet<E> navigableSubSet(E fromElement, E toElement) {
298          return new TreeSet<E>(m.navigableSubMap(fromElement, toElement));
# Line 303 | Line 304 | public class TreeSet<E>
304       *         this set uses natural ordering, or its comparator does
305       *         not permit null elements
306       * @throws IllegalArgumentException {@inheritDoc}
307 +     * @since 1.6
308       */
309      public NavigableSet<E> navigableHeadSet(E toElement) {
310          return new TreeSet<E>(m.navigableHeadMap(toElement));
# Line 314 | Line 316 | public class TreeSet<E>
316       *         this set uses natural ordering, or its comparator does
317       *         not permit null elements
318       * @throws IllegalArgumentException {@inheritDoc}
319 +     * @since 1.6
320       */
321      public NavigableSet<E> navigableTailSet(E fromElement) {
322          return new TreeSet<E>(m.navigableTailMap(fromElement));
# Line 392 | Line 395 | public class TreeSet<E>
395       * @throws NullPointerException if the specified element is null
396       *         and this set uses natural ordering, or its comparator
397       *         does not permit null elements
398 +     * @since 1.6
399       */
400      public E lower(E e) {
401          return m.lowerKey(e);
# Line 402 | Line 406 | public class TreeSet<E>
406       * @throws NullPointerException if the specified element is null
407       *         and this set uses natural ordering, or its comparator
408       *         does not permit null elements
409 +     * @since 1.6
410       */
411      public E floor(E e) {
412          return m.floorKey(e);
# Line 412 | Line 417 | public class TreeSet<E>
417       * @throws NullPointerException if the specified element is null
418       *         and this set uses natural ordering, or its comparator
419       *         does not permit null elements
420 +     * @since 1.6
421       */
422      public E ceiling(E e) {
423          return m.ceilingKey(e);
# Line 422 | Line 428 | public class TreeSet<E>
428       * @throws NullPointerException if the specified element is null
429       *         and this set uses natural ordering, or its comparator
430       *         does not permit null elements
431 +     * @since 1.6
432       */
433      public E higher(E e) {
434          return m.higherKey(e);
435      }
436  
437 +    /**
438 +     * @since 1.6
439 +     */
440      public E pollFirst() {
441          Map.Entry<E,?> e = m.pollFirstEntry();
442          return (e == null)? null : e.getKey();
443      }
444  
445 +    /**
446 +     * @since 1.6
447 +     */
448      public E pollLast() {
449          Map.Entry<E,?> e = m.pollLastEntry();
450          return (e == null)? null : e.getKey();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines