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.12 by jsr166, Tue May 17 04:10:23 2005 UTC vs.
Revision 1.16 by jsr166, Sun Jun 19 23:01:12 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 154 | Line 155 | public class TreeSet<E>
155      }
156  
157      /**
158 <     * Returns an iterator over the elements in this set.  The elements
158 <     * are returned in ascending order.
158 >     * Returns an iterator over the elements in this set in ascending order.
159       *
160 <     * @return an iterator over the elements in this set
160 >     * @return an iterator over the elements in this set in ascending order
161       */
162      public Iterator<E> iterator() {
163          return m.keySet().iterator();
164      }
165  
166      /**
167 <     * Returns an iterator over the elements in this set.  The elements
168 <     * are returned in descending order.
167 >     * Returns an iterator over the elements in this set in descending order.
168       *
169 <     * @return an iterator over the elements in this set
169 >     * @return an iterator over the elements in this set in descending order
170       */
171      public Iterator<E> descendingIterator() {
172          return m.descendingKeySet().iterator();
# Line 193 | Line 192 | public class TreeSet<E>
192  
193      /**
194       * Returns <tt>true</tt> if this set contains the specified element.
195 +     * More formally, returns <tt>true</tt> if and only if this set
196 +     * contains an element <tt>e</tt> such that
197 +     * <tt>(o==null&nbsp;?&nbsp;e==null&nbsp;:&nbsp;o.equals(e))</tt>.
198       *
199 <     * @param o the object to be checked for containment in this set
199 >     * @param o object to be checked for containment in this set
200       * @return <tt>true</tt> if this set contains the specified element
201       * @throws ClassCastException if the specified object cannot be compared
202       *         with the elements currently in the set
203 <     * @throws NullPointerException if the specified element is null and
204 <     *         this set uses natural ordering and is non-empty, or its
205 <     *         comparator does not permit null elements
203 >     * @throws NullPointerException if the specified element is null
204 >     *         and this set uses natural ordering, or its comparator
205 >     *         does not permit null elements
206       */
207      public boolean contains(Object o) {
208          return m.containsKey(o);
# Line 208 | Line 210 | public class TreeSet<E>
210  
211      /**
212       * Adds the specified element to this set if it is not already present.
213 +     * More formally, adds the specified element <tt>e</tt> to this set if
214 +     * the set contains no element <tt>e2</tt> such that
215 +     * <tt>(e==null&nbsp;?&nbsp;e2==null&nbsp;:&nbsp;e.equals(e2))</tt>.
216 +     * If this set already contains the element, the call leaves the set
217 +     * unchanged and returns <tt>false</tt>.
218       *
219       * @param e element to be added to this set
220 <     * @return <tt>true</tt> if the set did not already contain the specified
220 >     * @return <tt>true</tt> if this set did not already contain the specified
221       *         element
222       * @throws ClassCastException if the specified object cannot be compared
223 <     *         with the elements currently in the set
224 <     * @throws NullPointerException if the specified element is null and
225 <     *         this set uses natural ordering and is non-empty, or its
226 <     *         comparator does not permit null elements
223 >     *         with the elements currently in this set
224 >     * @throws NullPointerException if the specified element is null
225 >     *         and this set uses natural ordering, or its comparator
226 >     *         does not permit null elements
227       */
228      public boolean add(E e) {
229          return m.put(e, PRESENT)==null;
# Line 224 | Line 231 | public class TreeSet<E>
231  
232      /**
233       * Removes the specified element from this set if it is present.
234 +     * More formally, removes an element <tt>e</tt> such that
235 +     * <tt>(o==null&nbsp;?&nbsp;e==null&nbsp;:&nbsp;o.equals(e))</tt>,
236 +     * if this set contains such an element.  Returns <tt>true</tt> if
237 +     * this set contained the element (or equivalently, if this set
238 +     * changed as a result of the call).  (This set will not contain the
239 +     * element once the call returns.)
240       *
241       * @param o object to be removed from this set, if present
242 <     * @return <tt>true</tt> if the set contained the specified element
242 >     * @return <tt>true</tt> if this set contained the specified element
243       * @throws ClassCastException if the specified object cannot be compared
244 <     *         with the elements currently in the set
245 <     * @throws NullPointerException if the specified element is null and
246 <     *         this set uses natural ordering and is non-empty, or its
247 <     *         comparator does not permit null elements
244 >     *         with the elements currently in this set
245 >     * @throws NullPointerException if the specified element is null
246 >     *         and this set uses natural ordering, or its comparator
247 >     *         does not permit null elements
248       */
249      public boolean remove(Object o) {
250          return m.remove(o)==PRESENT;
# Line 248 | Line 261 | public class TreeSet<E>
261      /**
262       * Adds all of the elements in the specified collection to this set.
263       *
264 <     * @param c elements to be added
264 >     * @param c collection containing elements to be added to this set
265       * @return <tt>true</tt> if this set changed as a result of the call
266       * @throws ClassCastException if the elements provided cannot be compared
267       *         with the elements currently in the set
# Line 376 | Line 389 | public class TreeSet<E>
389  
390      /**
391       * @throws ClassCastException {@inheritDoc}
392 <     * @throws NullPointerException if the specified element is null and
393 <     *         this set uses natural ordering and is non-empty,
394 <     *         or its comparator does not permit null elements
392 >     * @throws NullPointerException if the specified element is null
393 >     *         and this set uses natural ordering, or its comparator
394 >     *         does not permit null elements
395       */
396      public E lower(E e) {
397          return m.lowerKey(e);
# Line 386 | Line 399 | public class TreeSet<E>
399  
400      /**
401       * @throws ClassCastException {@inheritDoc}
402 <     * @throws NullPointerException if the specified element is null and
403 <     *         this set uses natural ordering and is non-empty,
404 <     *         or its comparator does not permit null elements
402 >     * @throws NullPointerException if the specified element is null
403 >     *         and this set uses natural ordering, or its comparator
404 >     *         does not permit null elements
405       */
406      public E floor(E e) {
407          return m.floorKey(e);
# Line 396 | Line 409 | public class TreeSet<E>
409  
410      /**
411       * @throws ClassCastException {@inheritDoc}
412 <     * @throws NullPointerException if the specified element is null and
413 <     *         this set uses natural ordering and is non-empty,
414 <     *         or its comparator does not permit null elements
412 >     * @throws NullPointerException if the specified element is null
413 >     *         and this set uses natural ordering, or its comparator
414 >     *         does not permit null elements
415       */
416      public E ceiling(E e) {
417          return m.ceilingKey(e);
# Line 406 | Line 419 | public class TreeSet<E>
419  
420      /**
421       * @throws ClassCastException {@inheritDoc}
422 <     * @throws NullPointerException if the specified element is null and
423 <     *         this set uses natural ordering and is non-empty,
424 <     *         or its comparator does not permit null elements
422 >     * @throws NullPointerException if the specified element is null
423 >     *         and this set uses natural ordering, or its comparator
424 >     *         does not permit null elements
425       */
426      public E higher(E e) {
427          return m.higherKey(e);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines