jdk/src/java.base/share/classes/java/util/NavigableSet.java
author redestad
Mon, 12 Sep 2016 17:45:55 +0200
changeset 40812 dc3755b63ade
parent 32991 b27c76b82713
child 44743 f0bbd698c486
permissions -rw-r--r--
8165723: JarFile::isMultiRelease() method returns false when it should return true Reviewed-by: alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4670
diff changeset
     6
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4670
diff changeset
     8
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4670
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4670
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4670
diff changeset
    22
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * This file is available under and governed by the GNU General Public
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * License version 2 only, as published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * However, the following notice accompanied the original version of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * file:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * Written by Doug Lea and Josh Bloch with assistance from members of JCP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * JSR-166 Expert Group and released to the public domain, as explained at
9242
ef138d47df58 7034657: Update Creative Commons license URL in legal notices
dl
parents: 5506
diff changeset
    33
 * http://creativecommons.org/publicdomain/zero/1.0/
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
package java.util;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * A {@link SortedSet} extended with navigation methods reporting
32991
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
    40
 * closest matches for given search targets. Methods {@link #lower},
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
    41
 * {@link #floor}, {@link #ceiling}, and {@link #higher} return elements
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * respectively less than, less than or equal, greater than or equal,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * and greater than a given element, returning {@code null} if there
32991
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
    44
 * is no such element.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *
32991
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
    46
 * <p>A {@code NavigableSet} may be accessed and traversed in either
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
    47
 * ascending or descending order.  The {@link #descendingSet} method
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
    48
 * returns a view of the set with the senses of all relational and
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
    49
 * directional methods inverted. The performance of ascending
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
    50
 * operations and views is likely to be faster than that of descending
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
    51
 * ones.  This interface additionally defines methods {@link
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
    52
 * #pollFirst} and {@link #pollLast} that return and remove the lowest
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
    53
 * and highest element, if one exists, else returning {@code null}.
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
    54
 * Methods
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
    55
 * {@link #subSet(Object, boolean, Object, boolean) subSet(E, boolean, E, boolean)},
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
    56
 * {@link #headSet(Object, boolean) headSet(E, boolean)}, and
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
    57
 * {@link #tailSet(Object, boolean) tailSet(E, boolean)}
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
    58
 * differ from the like-named {@code SortedSet} methods in accepting
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
    59
 * additional arguments describing whether lower and upper bounds are
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
    60
 * inclusive versus exclusive.  Subsets of any {@code NavigableSet}
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
    61
 * must implement the {@code NavigableSet} interface.
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
    62
 *
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
    63
 * <p>The return values of navigation methods may be ambiguous in
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * implementations that permit {@code null} elements. However, even
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * in this case the result can be disambiguated by checking
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * {@code contains(null)}. To avoid such issues, implementations of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * this interface are encouraged to <em>not</em> permit insertion of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * {@code null} elements. (Note that sorted sets of {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * Comparable} elements intrinsically do not permit {@code null}.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * <p>Methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * {@link #subSet(Object, Object) subSet(E, E)},
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * {@link #headSet(Object) headSet(E)}, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * {@link #tailSet(Object) tailSet(E)}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * are specified to return {@code SortedSet} to allow existing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * implementations of {@code SortedSet} to be compatibly retrofitted to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * implement {@code NavigableSet}, but extensions and implementations
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * of this interface are encouraged to override these methods to return
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * {@code NavigableSet}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * <p>This interface is a member of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * <a href="{@docRoot}/../technotes/guides/collections/index.html">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * Java Collections Framework</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * @author Doug Lea
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * @author Josh Bloch
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * @param <E> the type of elements maintained by this set
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
public interface NavigableSet<E> extends SortedSet<E> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * Returns the greatest element in this set strictly less than the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * given element, or {@code null} if there is no such element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * @param e the value to match
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * @return the greatest element less than {@code e},
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     *         or {@code null} if there is no such element
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * @throws ClassCastException if the specified element cannot be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     *         compared with the elements currently in the set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * @throws NullPointerException if the specified element is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     *         and this set does not permit null elements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    E lower(E e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * Returns the greatest element in this set less than or equal to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * the given element, or {@code null} if there is no such element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * @param e the value to match
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * @return the greatest element less than or equal to {@code e},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     *         or {@code null} if there is no such element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * @throws ClassCastException if the specified element cannot be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     *         compared with the elements currently in the set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * @throws NullPointerException if the specified element is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     *         and this set does not permit null elements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    E floor(E e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * Returns the least element in this set greater than or equal to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * the given element, or {@code null} if there is no such element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * @param e the value to match
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * @return the least element greater than or equal to {@code e},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     *         or {@code null} if there is no such element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * @throws ClassCastException if the specified element cannot be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     *         compared with the elements currently in the set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * @throws NullPointerException if the specified element is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     *         and this set does not permit null elements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    E ceiling(E e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * Returns the least element in this set strictly greater than the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * given element, or {@code null} if there is no such element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * @param e the value to match
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * @return the least element greater than {@code e},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     *         or {@code null} if there is no such element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * @throws ClassCastException if the specified element cannot be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     *         compared with the elements currently in the set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * @throws NullPointerException if the specified element is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     *         and this set does not permit null elements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    E higher(E e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * Retrieves and removes the first (lowest) element,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * or returns {@code null} if this set is empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * @return the first element, or {@code null} if this set is empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    E pollFirst();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * Retrieves and removes the last (highest) element,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * or returns {@code null} if this set is empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * @return the last element, or {@code null} if this set is empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    E pollLast();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * Returns an iterator over the elements in this set, in ascending order.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * @return an iterator over the elements in this set, in ascending order
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    Iterator<E> iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * Returns a reverse order view of the elements contained in this set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * The descending set is backed by this set, so changes to the set are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * reflected in the descending set, and vice-versa.  If either set is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * modified while an iteration over either set is in progress (except
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * through the iterator's own {@code remove} operation), the results of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * the iteration are undefined.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * <p>The returned set has an ordering equivalent to
32991
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   179
     * {@link Collections#reverseOrder(Comparator) Collections.reverseOrder}{@code (comparator())}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * The expression {@code s.descendingSet().descendingSet()} returns a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * view of {@code s} essentially equivalent to {@code s}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * @return a reverse order view of this set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    NavigableSet<E> descendingSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * Returns an iterator over the elements in this set, in descending order.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * Equivalent in effect to {@code descendingSet().iterator()}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * @return an iterator over the elements in this set, in descending order
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    Iterator<E> descendingIterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * Returns a view of the portion of this set whose elements range from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * {@code fromElement} to {@code toElement}.  If {@code fromElement} and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * {@code toElement} are equal, the returned set is empty unless {@code
4670
fb58a0e847a6 6828204: NavigableSet.subSet() documentation refers to nonexistent parameters
darcy
parents: 2
diff changeset
   199
     * fromInclusive} and {@code toInclusive} are both true.  The returned set
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * is backed by this set, so changes in the returned set are reflected in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * this set, and vice-versa.  The returned set supports all optional set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * operations that this set supports.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * <p>The returned set will throw an {@code IllegalArgumentException}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * on an attempt to insert an element outside its range.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * @param fromElement low endpoint of the returned set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * @param fromInclusive {@code true} if the low endpoint
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     *        is to be included in the returned view
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * @param toElement high endpoint of the returned set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * @param toInclusive {@code true} if the high endpoint
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     *        is to be included in the returned view
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * @return a view of the portion of this set whose elements range from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     *         {@code fromElement}, inclusive, to {@code toElement}, exclusive
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * @throws ClassCastException if {@code fromElement} and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     *         {@code toElement} cannot be compared to one another using this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     *         set's comparator (or, if the set has no comparator, using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     *         natural ordering).  Implementations may, but are not required
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     *         to, throw this exception if {@code fromElement} or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     *         {@code toElement} cannot be compared to elements currently in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     *         the set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * @throws NullPointerException if {@code fromElement} or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     *         {@code toElement} is null and this set does
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     *         not permit null elements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * @throws IllegalArgumentException if {@code fromElement} is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     *         greater than {@code toElement}; or if this set itself
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     *         has a restricted range, and {@code fromElement} or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     *         {@code toElement} lies outside the bounds of the range.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    NavigableSet<E> subSet(E fromElement, boolean fromInclusive,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                           E toElement,   boolean toInclusive);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * Returns a view of the portion of this set whose elements are less than
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * (or equal to, if {@code inclusive} is true) {@code toElement}.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * returned set is backed by this set, so changes in the returned set are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * reflected in this set, and vice-versa.  The returned set supports all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * optional set operations that this set supports.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * <p>The returned set will throw an {@code IllegalArgumentException}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * on an attempt to insert an element outside its range.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * @param toElement high endpoint of the returned set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * @param inclusive {@code true} if the high endpoint
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     *        is to be included in the returned view
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * @return a view of the portion of this set whose elements are less than
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     *         (or equal to, if {@code inclusive} is true) {@code toElement}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * @throws ClassCastException if {@code toElement} is not compatible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     *         with this set's comparator (or, if the set has no comparator,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     *         if {@code toElement} does not implement {@link Comparable}).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     *         Implementations may, but are not required to, throw this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     *         exception if {@code toElement} cannot be compared to elements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     *         currently in the set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * @throws NullPointerException if {@code toElement} is null and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     *         this set does not permit null elements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * @throws IllegalArgumentException if this set itself has a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     *         restricted range, and {@code toElement} lies outside the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     *         bounds of the range
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    NavigableSet<E> headSet(E toElement, boolean inclusive);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * Returns a view of the portion of this set whose elements are greater
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * than (or equal to, if {@code inclusive} is true) {@code fromElement}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * The returned set is backed by this set, so changes in the returned set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * are reflected in this set, and vice-versa.  The returned set supports
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * all optional set operations that this set supports.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * <p>The returned set will throw an {@code IllegalArgumentException}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * on an attempt to insert an element outside its range.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * @param fromElement low endpoint of the returned set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * @param inclusive {@code true} if the low endpoint
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     *        is to be included in the returned view
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * @return a view of the portion of this set whose elements are greater
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     *         than or equal to {@code fromElement}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * @throws ClassCastException if {@code fromElement} is not compatible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     *         with this set's comparator (or, if the set has no comparator,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     *         if {@code fromElement} does not implement {@link Comparable}).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     *         Implementations may, but are not required to, throw this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     *         exception if {@code fromElement} cannot be compared to elements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     *         currently in the set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * @throws NullPointerException if {@code fromElement} is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     *         and this set does not permit null elements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * @throws IllegalArgumentException if this set itself has a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     *         restricted range, and {@code fromElement} lies outside the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     *         bounds of the range
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    NavigableSet<E> tailSet(E fromElement, boolean inclusive);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * <p>Equivalent to {@code subSet(fromElement, true, toElement, false)}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * @throws ClassCastException       {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * @throws NullPointerException     {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * @throws IllegalArgumentException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    SortedSet<E> subSet(E fromElement, E toElement);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * <p>Equivalent to {@code headSet(toElement, false)}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * @throws ClassCastException       {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * @throws NullPointerException     {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * @throws IllegalArgumentException {@inheritDoc}
18818
a9ceff754226 7129185: Add Collections.{checked|empty|unmodifiable}Navigable{Map|Set}
mduigou
parents: 9242
diff changeset
   310
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    SortedSet<E> headSet(E toElement);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * <p>Equivalent to {@code tailSet(fromElement, true)}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * @throws ClassCastException       {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * @throws NullPointerException     {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * @throws IllegalArgumentException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    SortedSet<E> tailSet(E fromElement);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
}