jaroslav@1258: /* jaroslav@1258: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jaroslav@1258: * jaroslav@1258: * This code is free software; you can redistribute it and/or modify it jaroslav@1258: * under the terms of the GNU General Public License version 2 only, as jaroslav@1258: * published by the Free Software Foundation. Oracle designates this jaroslav@1258: * particular file as subject to the "Classpath" exception as provided jaroslav@1258: * by Oracle in the LICENSE file that accompanied this code. jaroslav@1258: * jaroslav@1258: * This code is distributed in the hope that it will be useful, but WITHOUT jaroslav@1258: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jaroslav@1258: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jaroslav@1258: * version 2 for more details (a copy is included in the LICENSE file that jaroslav@1258: * accompanied this code). jaroslav@1258: * jaroslav@1258: * You should have received a copy of the GNU General Public License version jaroslav@1258: * 2 along with this work; if not, write to the Free Software Foundation, jaroslav@1258: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jaroslav@1258: * jaroslav@1258: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA jaroslav@1258: * or visit www.oracle.com if you need additional information or have any jaroslav@1258: * questions. jaroslav@1258: */ jaroslav@1258: jaroslav@1258: /* jaroslav@1258: * This file is available under and governed by the GNU General Public jaroslav@1258: * License version 2 only, as published by the Free Software Foundation. jaroslav@1258: * However, the following notice accompanied the original version of this jaroslav@1258: * file: jaroslav@1258: * jaroslav@1258: * Written by Doug Lea and Josh Bloch with assistance from members of JCP jaroslav@1258: * JSR-166 Expert Group and released to the public domain, as explained at jaroslav@1258: * http://creativecommons.org/publicdomain/zero/1.0/ jaroslav@1258: */ jaroslav@1258: jaroslav@1258: package java.util; jaroslav@1258: jaroslav@1258: /** jaroslav@1258: * A {@link SortedSet} extended with navigation methods reporting jaroslav@1258: * closest matches for given search targets. Methods {@code lower}, jaroslav@1258: * {@code floor}, {@code ceiling}, and {@code higher} return elements jaroslav@1258: * respectively less than, less than or equal, greater than or equal, jaroslav@1258: * and greater than a given element, returning {@code null} if there jaroslav@1258: * is no such element. A {@code NavigableSet} may be accessed and jaroslav@1258: * traversed in either ascending or descending order. The {@code jaroslav@1258: * descendingSet} method returns a view of the set with the senses of jaroslav@1258: * all relational and directional methods inverted. The performance of jaroslav@1258: * ascending operations and views is likely to be faster than that of jaroslav@1258: * descending ones. This interface additionally defines methods jaroslav@1258: * {@code pollFirst} and {@code pollLast} that return and remove the jaroslav@1258: * lowest and highest element, if one exists, else returning {@code jaroslav@1258: * null}. Methods {@code subSet}, {@code headSet}, jaroslav@1258: * and {@code tailSet} differ from the like-named {@code jaroslav@1258: * SortedSet} methods in accepting additional arguments describing jaroslav@1258: * whether lower and upper bounds are inclusive versus exclusive. jaroslav@1258: * Subsets of any {@code NavigableSet} must implement the {@code jaroslav@1258: * NavigableSet} interface. jaroslav@1258: * jaroslav@1258: *
The return values of navigation methods may be ambiguous in jaroslav@1258: * implementations that permit {@code null} elements. However, even jaroslav@1258: * in this case the result can be disambiguated by checking jaroslav@1258: * {@code contains(null)}. To avoid such issues, implementations of jaroslav@1258: * this interface are encouraged to not permit insertion of jaroslav@1258: * {@code null} elements. (Note that sorted sets of {@link jaroslav@1258: * Comparable} elements intrinsically do not permit {@code null}.) jaroslav@1258: * jaroslav@1258: *
Methods jaroslav@1258: * {@link #subSet(Object, Object) subSet(E, E)}, jaroslav@1258: * {@link #headSet(Object) headSet(E)}, and jaroslav@1258: * {@link #tailSet(Object) tailSet(E)} jaroslav@1258: * are specified to return {@code SortedSet} to allow existing jaroslav@1258: * implementations of {@code SortedSet} to be compatibly retrofitted to jaroslav@1258: * implement {@code NavigableSet}, but extensions and implementations jaroslav@1258: * of this interface are encouraged to override these methods to return jaroslav@1258: * {@code NavigableSet}. jaroslav@1258: * jaroslav@1258: *
This interface is a member of the
jaroslav@1258: *
jaroslav@1258: * Java Collections Framework.
jaroslav@1258: *
jaroslav@1258: * @author Doug Lea
jaroslav@1258: * @author Josh Bloch
jaroslav@1258: * @param The returned set has an ordering equivalent to
jaroslav@1258: * {@link Collections#reverseOrder(Comparator) Collections.reverseOrder}(comparator()).
jaroslav@1258: * The expression {@code s.descendingSet().descendingSet()} returns a
jaroslav@1258: * view of {@code s} essentially equivalent to {@code s}.
jaroslav@1258: *
jaroslav@1258: * @return a reverse order view of this set
jaroslav@1258: */
jaroslav@1258: NavigableSet The returned set will throw an {@code IllegalArgumentException}
jaroslav@1258: * on an attempt to insert an element outside its range.
jaroslav@1258: *
jaroslav@1258: * @param fromElement low endpoint of the returned set
jaroslav@1258: * @param fromInclusive {@code true} if the low endpoint
jaroslav@1258: * is to be included in the returned view
jaroslav@1258: * @param toElement high endpoint of the returned set
jaroslav@1258: * @param toInclusive {@code true} if the high endpoint
jaroslav@1258: * is to be included in the returned view
jaroslav@1258: * @return a view of the portion of this set whose elements range from
jaroslav@1258: * {@code fromElement}, inclusive, to {@code toElement}, exclusive
jaroslav@1258: * @throws ClassCastException if {@code fromElement} and
jaroslav@1258: * {@code toElement} cannot be compared to one another using this
jaroslav@1258: * set's comparator (or, if the set has no comparator, using
jaroslav@1258: * natural ordering). Implementations may, but are not required
jaroslav@1258: * to, throw this exception if {@code fromElement} or
jaroslav@1258: * {@code toElement} cannot be compared to elements currently in
jaroslav@1258: * the set.
jaroslav@1258: * @throws NullPointerException if {@code fromElement} or
jaroslav@1258: * {@code toElement} is null and this set does
jaroslav@1258: * not permit null elements
jaroslav@1258: * @throws IllegalArgumentException if {@code fromElement} is
jaroslav@1258: * greater than {@code toElement}; or if this set itself
jaroslav@1258: * has a restricted range, and {@code fromElement} or
jaroslav@1258: * {@code toElement} lies outside the bounds of the range.
jaroslav@1258: */
jaroslav@1258: NavigableSet The returned set will throw an {@code IllegalArgumentException}
jaroslav@1258: * on an attempt to insert an element outside its range.
jaroslav@1258: *
jaroslav@1258: * @param toElement high endpoint of the returned set
jaroslav@1258: * @param inclusive {@code true} if the high endpoint
jaroslav@1258: * is to be included in the returned view
jaroslav@1258: * @return a view of the portion of this set whose elements are less than
jaroslav@1258: * (or equal to, if {@code inclusive} is true) {@code toElement}
jaroslav@1258: * @throws ClassCastException if {@code toElement} is not compatible
jaroslav@1258: * with this set's comparator (or, if the set has no comparator,
jaroslav@1258: * if {@code toElement} does not implement {@link Comparable}).
jaroslav@1258: * Implementations may, but are not required to, throw this
jaroslav@1258: * exception if {@code toElement} cannot be compared to elements
jaroslav@1258: * currently in the set.
jaroslav@1258: * @throws NullPointerException if {@code toElement} is null and
jaroslav@1258: * this set does not permit null elements
jaroslav@1258: * @throws IllegalArgumentException if this set itself has a
jaroslav@1258: * restricted range, and {@code toElement} lies outside the
jaroslav@1258: * bounds of the range
jaroslav@1258: */
jaroslav@1258: NavigableSet The returned set will throw an {@code IllegalArgumentException}
jaroslav@1258: * on an attempt to insert an element outside its range.
jaroslav@1258: *
jaroslav@1258: * @param fromElement low endpoint of the returned set
jaroslav@1258: * @param inclusive {@code true} if the low endpoint
jaroslav@1258: * is to be included in the returned view
jaroslav@1258: * @return a view of the portion of this set whose elements are greater
jaroslav@1258: * than or equal to {@code fromElement}
jaroslav@1258: * @throws ClassCastException if {@code fromElement} is not compatible
jaroslav@1258: * with this set's comparator (or, if the set has no comparator,
jaroslav@1258: * if {@code fromElement} does not implement {@link Comparable}).
jaroslav@1258: * Implementations may, but are not required to, throw this
jaroslav@1258: * exception if {@code fromElement} cannot be compared to elements
jaroslav@1258: * currently in the set.
jaroslav@1258: * @throws NullPointerException if {@code fromElement} is null
jaroslav@1258: * and this set does not permit null elements
jaroslav@1258: * @throws IllegalArgumentException if this set itself has a
jaroslav@1258: * restricted range, and {@code fromElement} lies outside the
jaroslav@1258: * bounds of the range
jaroslav@1258: */
jaroslav@1258: NavigableSet Equivalent to {@code subSet(fromElement, true, toElement, false)}.
jaroslav@1258: *
jaroslav@1258: * @throws ClassCastException {@inheritDoc}
jaroslav@1258: * @throws NullPointerException {@inheritDoc}
jaroslav@1258: * @throws IllegalArgumentException {@inheritDoc}
jaroslav@1258: */
jaroslav@1258: SortedSet Equivalent to {@code headSet(toElement, false)}.
jaroslav@1258: *
jaroslav@1258: * @throws ClassCastException {@inheritDoc}
jaroslav@1258: * @throws NullPointerException {@inheritDoc}
jaroslav@1258: * @throws IllegalArgumentException {@inheritDoc}
jaroslav@1258: na */
jaroslav@1258: SortedSet Equivalent to {@code tailSet(fromElement, true)}.
jaroslav@1258: *
jaroslav@1258: * @throws ClassCastException {@inheritDoc}
jaroslav@1258: * @throws NullPointerException {@inheritDoc}
jaroslav@1258: * @throws IllegalArgumentException {@inheritDoc}
jaroslav@1258: */
jaroslav@1258: SortedSet