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.15 by jsr166, Thu May 19 07:47:49 2005 UTC vs.
Revision 1.17 by jsr166, Fri Jun 24 20:44:49 2005 UTC

# Line 6 | Line 6
6   */
7  
8   package java.util;
9 + import java.util.*; // for javadoc (till 6280605 is fixed)
10  
11   /**
12   * A {@link NavigableSet} implementation based on a {@link TreeMap}.
# Line 166 | Line 167 | public class TreeSet<E>
167       * Returns an iterator over the elements in this set in descending order.
168       *
169       * @return an iterator over the elements in this set in descending order
170 +     * @since 1.6
171       */
172      public Iterator<E> descendingIterator() {
173          return m.descendingKeySet().iterator();
# Line 191 | Line 193 | public class TreeSet<E>
193  
194      /**
195       * Returns <tt>true</tt> if this set contains the specified element.
196 +     * More formally, returns <tt>true</tt> if and only if this set
197 +     * contains an element <tt>e</tt> such that
198 +     * <tt>(o==null&nbsp;?&nbsp;e==null&nbsp;:&nbsp;o.equals(e))</tt>.
199       *
200 <     * @param o the object to be checked for containment in this set
200 >     * @param o object to be checked for containment in this set
201       * @return <tt>true</tt> if this set contains the specified element
202       * @throws ClassCastException if the specified object cannot be compared
203       *         with the elements currently in the set
# Line 206 | Line 211 | public class TreeSet<E>
211  
212      /**
213       * Adds the specified element to this set if it is not already present.
214 +     * More formally, adds the specified element <tt>e</tt> to this set if
215 +     * the set contains no element <tt>e2</tt> such that
216 +     * <tt>(e==null&nbsp;?&nbsp;e2==null&nbsp;:&nbsp;e.equals(e2))</tt>.
217 +     * If this set already contains the element, the call leaves the set
218 +     * unchanged and returns <tt>false</tt>.
219       *
220       * @param e element to be added to this set
221 <     * @return <tt>true</tt> if the set did not already contain the specified
221 >     * @return <tt>true</tt> if this set did not already contain the specified
222       *         element
223       * @throws ClassCastException if the specified object cannot be compared
224 <     *         with the elements currently in the set
224 >     *         with the elements currently in this set
225       * @throws NullPointerException if the specified element is null
226       *         and this set uses natural ordering, or its comparator
227       *         does not permit null elements
# Line 222 | Line 232 | public class TreeSet<E>
232  
233      /**
234       * Removes the specified element from this set if it is present.
235 +     * More formally, removes an element <tt>e</tt> such that
236 +     * <tt>(o==null&nbsp;?&nbsp;e==null&nbsp;:&nbsp;o.equals(e))</tt>,
237 +     * if this set contains such an element.  Returns <tt>true</tt> if
238 +     * this set contained the element (or equivalently, if this set
239 +     * changed as a result of the call).  (This set will not contain the
240 +     * element once the call returns.)
241       *
242       * @param o object to be removed from this set, if present
243 <     * @return <tt>true</tt> if the set contained the specified element
243 >     * @return <tt>true</tt> if this set contained the specified element
244       * @throws ClassCastException if the specified object cannot be compared
245 <     *         with the elements currently in the set
245 >     *         with the elements currently in this set
246       * @throws NullPointerException if the specified element is null
247       *         and this set uses natural ordering, or its comparator
248       *         does not permit null elements
# Line 277 | Line 293 | public class TreeSet<E>
293       *         <tt>toElement</tt> is null and this set uses natural ordering,
294       *         or its comparator does not permit null elements
295       * @throws IllegalArgumentException {@inheritDoc}
296 +     * @since 1.6
297       */
298      public NavigableSet<E> navigableSubSet(E fromElement, E toElement) {
299          return new TreeSet<E>(m.navigableSubMap(fromElement, toElement));
# Line 288 | Line 305 | public class TreeSet<E>
305       *         this set uses natural ordering, or its comparator does
306       *         not permit null elements
307       * @throws IllegalArgumentException {@inheritDoc}
308 +     * @since 1.6
309       */
310      public NavigableSet<E> navigableHeadSet(E toElement) {
311          return new TreeSet<E>(m.navigableHeadMap(toElement));
# Line 299 | Line 317 | public class TreeSet<E>
317       *         this set uses natural ordering, or its comparator does
318       *         not permit null elements
319       * @throws IllegalArgumentException {@inheritDoc}
320 +     * @since 1.6
321       */
322      public NavigableSet<E> navigableTailSet(E fromElement) {
323          return new TreeSet<E>(m.navigableTailMap(fromElement));
# Line 377 | Line 396 | public class TreeSet<E>
396       * @throws NullPointerException if the specified element is null
397       *         and this set uses natural ordering, or its comparator
398       *         does not permit null elements
399 +     * @since 1.6
400       */
401      public E lower(E e) {
402          return m.lowerKey(e);
# Line 387 | Line 407 | public class TreeSet<E>
407       * @throws NullPointerException if the specified element is null
408       *         and this set uses natural ordering, or its comparator
409       *         does not permit null elements
410 +     * @since 1.6
411       */
412      public E floor(E e) {
413          return m.floorKey(e);
# Line 397 | Line 418 | public class TreeSet<E>
418       * @throws NullPointerException if the specified element is null
419       *         and this set uses natural ordering, or its comparator
420       *         does not permit null elements
421 +     * @since 1.6
422       */
423      public E ceiling(E e) {
424          return m.ceilingKey(e);
# Line 407 | Line 429 | public class TreeSet<E>
429       * @throws NullPointerException if the specified element is null
430       *         and this set uses natural ordering, or its comparator
431       *         does not permit null elements
432 +     * @since 1.6
433       */
434      public E higher(E e) {
435          return m.higherKey(e);
436      }
437  
438 +    /**
439 +     * @since 1.6
440 +     */
441      public E pollFirst() {
442          Map.Entry<E,?> e = m.pollFirstEntry();
443          return (e == null)? null : e.getKey();
444      }
445  
446 +    /**
447 +     * @since 1.6
448 +     */
449      public E pollLast() {
450          Map.Entry<E,?> e = m.pollLastEntry();
451          return (e == null)? null : e.getKey();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines