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

Comparing jsr166/src/main/java/util/NavigableSet.java (file contents):
Revision 1.22 by jsr166, Fri Apr 21 23:11:14 2006 UTC vs.
Revision 1.30 by jsr166, Sun Sep 6 04:29:42 2015 UTC

# Line 1 | Line 1
1   /*
2   * Written by Doug Lea and Josh Bloch with assistance from members of JCP
3   * JSR-166 Expert Group and released to the public domain, as explained at
4 < * http://creativecommons.org/licenses/publicdomain
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6  
7   package java.util;
8  
9   /**
10   * A {@link SortedSet} extended with navigation methods reporting
11 < * closest matches for given search targets. Methods {@code lower},
12 < * {@code floor}, {@code ceiling}, and {@code higher} return elements
11 > * closest matches for given search targets. Methods {@link #lower},
12 > * {@link #floor}, {@link #ceiling}, and {@link #higher} return elements
13   * respectively less than, less than or equal, greater than or equal,
14   * and greater than a given element, returning {@code null} if there
15   * is no such element.  A {@code NavigableSet} may be accessed and
# Line 18 | Line 18 | package java.util;
18   * all relational and directional methods inverted. The performance of
19   * ascending operations and views is likely to be faster than that of
20   * descending ones.  This interface additionally defines methods
21 < * {@code pollFirst} and {@code pollLast} that return and remove the
21 > * {@link #pollFirst} and {@link #pollLast} that return and remove the
22   * lowest and highest element, if one exists, else returning {@code
23   * null}.  Methods {@code subSet}, {@code headSet},
24   * and {@code tailSet} differ from the like-named {@code
# Line 27 | Line 27 | package java.util;
27   * Subsets of any {@code NavigableSet} must implement the {@code
28   * NavigableSet} interface.
29   *
30 < * <p> The return values of navigation methods may be ambiguous in
30 > * <p>The return values of navigation methods may be ambiguous in
31   * implementations that permit {@code null} elements. However, even
32   * in this case the result can be disambiguated by checking
33   * {@code contains(null)}. To avoid such issues, implementations of
# Line 35 | Line 35 | package java.util;
35   * {@code null} elements. (Note that sorted sets of {@link
36   * Comparable} elements intrinsically do not permit {@code null}.)
37   *
38 + * <p>Methods
39 + * {@link #subSet(Object, Object) subSet(E, E)},
40 + * {@link #headSet(Object) headSet(E)}, and
41 + * {@link #tailSet(Object) tailSet(E)}
42 + * are specified to return {@code SortedSet} to allow existing
43 + * implementations of {@code SortedSet} to be compatibly retrofitted to
44 + * implement {@code NavigableSet}, but extensions and implementations
45 + * of this interface are encouraged to override these methods to return
46 + * {@code NavigableSet}.
47 + *
48   * <p>This interface is a member of the
49 < * <a href="{@docRoot}/../guide/collections/index.html">
49 > * <a href="{@docRoot}/../technotes/guides/collections/index.html">
50   * Java Collections Framework</a>.
51   *
52   * @author Doug Lea
# Line 125 | Line 135 | public interface NavigableSet<E> extends
135      Iterator<E> iterator();
136  
137      /**
138 <     * Returns a {@link NavigableSet} view of the elements contained in this
139 <     * set in descending order.  The descending set is backed by this set, so
140 <     * changes to the set are reflected in the descending set, and vice-versa.
141 <     * If either set is modified while an iteration over the other set is in
142 <     * progress (except through the iterator's own {@code remove} operation),
143 <     * the results of the iteration are undefined.
138 >     * Returns a reverse order view of the elements contained in this set.
139 >     * The descending set is backed by this set, so changes to the set are
140 >     * reflected in the descending set, and vice-versa.  If either set is
141 >     * modified while an iteration over either set is in progress (except
142 >     * through the iterator's own {@code remove} operation), the results of
143 >     * the iteration are undefined.
144 >     *
145 >     * <p>The returned set has an ordering equivalent to
146 >     * {@link Collections#reverseOrder(Comparator) Collections.reverseOrder}{@code (comparator())}.
147 >     * The expression {@code s.descendingSet().descendingSet()} returns a
148 >     * view of {@code s} essentially equivalent to {@code s}.
149       *
150 <     * @return a navigable set view of the elements contained in this set,
136 <     *         sorted in descending order
150 >     * @return a reverse order view of this set
151       */
152      NavigableSet<E> descendingSet();
153  
# Line 149 | Line 163 | public interface NavigableSet<E> extends
163       * Returns a view of the portion of this set whose elements range from
164       * {@code fromElement} to {@code toElement}.  If {@code fromElement} and
165       * {@code toElement} are equal, the returned set is empty unless {@code
166 <     * fromExclusive} and {@code toExclusive} are both true.  The returned set
166 >     * fromInclusive} and {@code toInclusive} are both true.  The returned set
167       * is backed by this set, so changes in the returned set are reflected in
168       * this set, and vice-versa.  The returned set supports all optional set
169       * operations that this set supports.
# Line 242 | Line 256 | public interface NavigableSet<E> extends
256      NavigableSet<E> tailSet(E fromElement, boolean inclusive);
257  
258      /**
259 <     * Equivalent to {@code subSet(fromElement, true, toElement, false)}
246 <     * but with a return type conforming to the {@code SortedSet} interface.
259 >     * {@inheritDoc}
260       *
261 <     * <p>{@inheritDoc}
261 >     * <p>Equivalent to {@code subSet(fromElement, true, toElement, false)}.
262       *
263       * @throws ClassCastException       {@inheritDoc}
264       * @throws NullPointerException     {@inheritDoc}
# Line 254 | Line 267 | public interface NavigableSet<E> extends
267      SortedSet<E> subSet(E fromElement, E toElement);
268  
269      /**
270 <     * Equivalent to {@code headSet(toElement, false)}
258 <     * but with a return type conforming to the {@code SortedSet} interface.
270 >     * {@inheritDoc}
271       *
272 <     * <p>{@inheritDoc}
272 >     * <p>Equivalent to {@code headSet(toElement, false)}.
273       *
274       * @throws ClassCastException       {@inheritDoc}
275       * @throws NullPointerException     {@inheritDoc}
# Line 266 | Line 278 | public interface NavigableSet<E> extends
278      SortedSet<E> headSet(E toElement);
279  
280      /**
281 <     * Equivalent to {@code tailSet(fromElement, true)}
270 <     * but with a return type conforming to the {@code SortedSet} interface.
281 >     * {@inheritDoc}
282       *
283 <     * <p>{@inheritDoc}
283 >     * <p>Equivalent to {@code tailSet(fromElement, true)}.
284       *
285       * @throws ClassCastException       {@inheritDoc}
286       * @throws NullPointerException     {@inheritDoc}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines