jdk/src/java.base/share/classes/java/util/NavigableMap.java
author mchung
Fri, 22 May 2015 16:43:39 -0700
changeset 30789 9eca83469588
parent 25859 3317bb8137f4
child 32991 b27c76b82713
permissions -rw-r--r--
8074431: Remove native2ascii tool Reviewed-by: erikj, alanb, okutsu, mfang, naoto
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 SortedMap} extended with navigation methods returning the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * closest matches for given search targets. Methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * {@code lowerEntry}, {@code floorEntry}, {@code ceilingEntry},
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * and {@code higherEntry} return {@code Map.Entry} objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * associated with keys respectively less than, less than or equal,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * greater than or equal, and greater than a given key, returning
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * {@code null} if there is no such key.  Similarly, methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * {@code lowerKey}, {@code floorKey}, {@code ceilingKey}, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * {@code higherKey} return only the associated keys. All of these
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * methods are designed for locating, not traversing entries.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * <p>A {@code NavigableMap} may be accessed and traversed in either
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * ascending or descending key order.  The {@code descendingMap}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * method returns a view of the map with the senses of all relational
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * and directional methods inverted. The performance of ascending
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * operations and views is likely to be faster than that of descending
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * ones.  Methods {@code subMap}, {@code headMap},
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * and {@code tailMap} differ from the like-named {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * SortedMap} methods in accepting additional arguments describing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * whether lower and upper bounds are inclusive versus exclusive.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * Submaps of any {@code NavigableMap} must implement the {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * NavigableMap} interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * <p>This interface additionally defines methods {@code firstEntry},
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * {@code pollFirstEntry}, {@code lastEntry}, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * {@code pollLastEntry} that return and/or remove the least and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * greatest mappings, if any exist, else returning {@code null}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * <p>Implementations of entry-returning methods are expected to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * return {@code Map.Entry} pairs representing snapshots of mappings
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * at the time they were produced, and thus generally do <em>not</em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * support the optional {@code Entry.setValue} method. Note however
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * that it is possible to change mappings in the associated map using
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * method {@code put}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * <p>Methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * {@link #subMap(Object, Object) subMap(K, K)},
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * {@link #headMap(Object) headMap(K)}, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * {@link #tailMap(Object) tailMap(K)}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * are specified to return {@code SortedMap} to allow existing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * implementations of {@code SortedMap} to be compatibly retrofitted to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * implement {@code NavigableMap}, but extensions and implementations
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * of this interface are encouraged to override these methods to return
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * {@code NavigableMap}.  Similarly,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * {@link #keySet()} can be overriden to return {@code NavigableSet}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * <p>This interface is a member of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * <a href="{@docRoot}/../technotes/guides/collections/index.html">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * Java Collections Framework</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * @author Doug Lea
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * @author Josh Bloch
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * @param <K> the type of keys maintained by this map
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * @param <V> the type of mapped values
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
public interface NavigableMap<K,V> extends SortedMap<K,V> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * Returns a key-value mapping associated with the greatest key
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * strictly less than the given key, or {@code null} if there is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * no such key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * @param key the key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * @return an entry with the greatest key less than {@code key},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     *         or {@code null} if there is no such key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * @throws ClassCastException if the specified key cannot be compared
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     *         with the keys currently in the map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * @throws NullPointerException if the specified key is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     *         and this map does not permit null keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    Map.Entry<K,V> lowerEntry(K key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * Returns the greatest key strictly less than the given key, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * {@code null} if there is no such key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * @param key the key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * @return the greatest key less than {@code key},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     *         or {@code null} if there is no such key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * @throws ClassCastException if the specified key cannot be compared
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     *         with the keys currently in the map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * @throws NullPointerException if the specified key is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     *         and this map does not permit null keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    K lowerKey(K key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * Returns a key-value mapping associated with the greatest key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * less than or equal to the given key, or {@code null} if there
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * is no such key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @param key the key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @return an entry with the greatest key less than or equal to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     *         {@code key}, or {@code null} if there is no such key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * @throws ClassCastException if the specified key cannot be compared
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     *         with the keys currently in the map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * @throws NullPointerException if the specified key is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     *         and this map does not permit null keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    Map.Entry<K,V> floorEntry(K key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * Returns the greatest key less than or equal to the given key,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * or {@code null} if there is no such key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * @param key the key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * @return the greatest key less than or equal to {@code key},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     *         or {@code null} if there is no such key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * @throws ClassCastException if the specified key cannot be compared
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     *         with the keys currently in the map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * @throws NullPointerException if the specified key is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     *         and this map does not permit null keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    K floorKey(K key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * Returns a key-value mapping associated with the least key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * greater than or equal to the given key, or {@code null} if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * there is no such key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * @param key the key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * @return an entry with the least key greater than or equal to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     *         {@code key}, or {@code null} if there is no such key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * @throws ClassCastException if the specified key cannot be compared
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     *         with the keys currently in the map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * @throws NullPointerException if the specified key is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     *         and this map does not permit null keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    Map.Entry<K,V> ceilingEntry(K key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * Returns the least key greater than or equal to the given key,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * or {@code null} if there is no such key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * @param key the key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * @return the least key greater than or equal to {@code key},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     *         or {@code null} if there is no such key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * @throws ClassCastException if the specified key cannot be compared
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     *         with the keys currently in the map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * @throws NullPointerException if the specified key is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     *         and this map does not permit null keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    K ceilingKey(K key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * Returns a key-value mapping associated with the least key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * strictly greater than the given key, or {@code null} if there
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * is no such key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * @param key the key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * @return an entry with the least key greater than {@code key},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     *         or {@code null} if there is no such key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * @throws ClassCastException if the specified key cannot be compared
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     *         with the keys currently in the map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * @throws NullPointerException if the specified key is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     *         and this map does not permit null keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    Map.Entry<K,V> higherEntry(K key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * Returns the least key strictly greater than the given key, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * {@code null} if there is no such key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * @param key the key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * @return the least key greater than {@code key},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     *         or {@code null} if there is no such key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * @throws ClassCastException if the specified key cannot be compared
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     *         with the keys currently in the map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * @throws NullPointerException if the specified key is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     *         and this map does not permit null keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    K higherKey(K key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * Returns a key-value mapping associated with the least
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * key in this map, or {@code null} if the map is empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * @return an entry with the least key,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     *         or {@code null} if this map is empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    Map.Entry<K,V> firstEntry();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * Returns a key-value mapping associated with the greatest
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * key in this map, or {@code null} if the map is empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * @return an entry with the greatest key,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     *         or {@code null} if this map is empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    Map.Entry<K,V> lastEntry();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * Removes and returns a key-value mapping associated with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * the least key in this map, or {@code null} if the map is empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * @return the removed first entry of this map,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     *         or {@code null} if this map is empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    Map.Entry<K,V> pollFirstEntry();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * Removes and returns a key-value mapping associated with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * the greatest key in this map, or {@code null} if the map is empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * @return the removed last entry of this map,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     *         or {@code null} if this map is empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    Map.Entry<K,V> pollLastEntry();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * Returns a reverse order view of the mappings contained in this map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * The descending map is backed by this map, so changes to the map are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * reflected in the descending map, and vice-versa.  If either map is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * modified while an iteration over a collection view of either map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * is in progress (except through the iterator's own {@code remove}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * operation), the results of the iteration are undefined.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * <p>The returned map has an ordering equivalent to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * <tt>{@link Collections#reverseOrder(Comparator) Collections.reverseOrder}(comparator())</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * The expression {@code m.descendingMap().descendingMap()} returns a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * view of {@code m} essentially equivalent to {@code m}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * @return a reverse order view of this map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    NavigableMap<K,V> descendingMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * Returns a {@link NavigableSet} view of the keys contained in this map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * The set's iterator returns the keys in ascending order.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * The set is backed by the map, so changes to the map are reflected in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * the set, and vice-versa.  If the map is modified while an iteration
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * over the set is in progress (except through the iterator's own {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * remove} operation), the results of the iteration are undefined.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * set supports element removal, which removes the corresponding mapping
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * from the map, via the {@code Iterator.remove}, {@code Set.remove},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * {@code removeAll}, {@code retainAll}, and {@code clear} operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * It does not support the {@code add} or {@code addAll} operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * @return a navigable set view of the keys in this map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    NavigableSet<K> navigableKeySet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * Returns a reverse order {@link NavigableSet} view of the keys contained in this map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * The set's iterator returns the keys in descending order.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * The set is backed by the map, so changes to the map are reflected in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * the set, and vice-versa.  If the map is modified while an iteration
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * over the set is in progress (except through the iterator's own {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * remove} operation), the results of the iteration are undefined.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * set supports element removal, which removes the corresponding mapping
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * from the map, via the {@code Iterator.remove}, {@code Set.remove},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * {@code removeAll}, {@code retainAll}, and {@code clear} operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * It does not support the {@code add} or {@code addAll} operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * @return a reverse order navigable set view of the keys in this map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    NavigableSet<K> descendingKeySet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * Returns a view of the portion of this map whose keys range from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * {@code fromKey} to {@code toKey}.  If {@code fromKey} and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * {@code toKey} are equal, the returned map is empty unless
4670
fb58a0e847a6 6828204: NavigableSet.subSet() documentation refers to nonexistent parameters
darcy
parents: 2
diff changeset
   301
     * {@code fromInclusive} and {@code toInclusive} are both true.  The
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * returned map is backed by this map, so changes in the returned map are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * reflected in this map, and vice-versa.  The returned map supports all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * optional map operations that this map supports.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * <p>The returned map will throw an {@code IllegalArgumentException}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * on an attempt to insert a key outside of its range, or to construct a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * submap either of whose endpoints lie outside its range.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * @param fromKey low endpoint of the keys in the returned map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * @param fromInclusive {@code true} if the low endpoint
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     *        is to be included in the returned view
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * @param toKey high endpoint of the keys in the returned map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * @param toInclusive {@code true} if the high endpoint
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     *        is to be included in the returned view
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * @return a view of the portion of this map whose keys range from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     *         {@code fromKey} to {@code toKey}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * @throws ClassCastException if {@code fromKey} and {@code toKey}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     *         cannot be compared to one another using this map's comparator
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     *         (or, if the map has no comparator, using natural ordering).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     *         Implementations may, but are not required to, throw this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     *         exception if {@code fromKey} or {@code toKey}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     *         cannot be compared to keys currently in the map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * @throws NullPointerException if {@code fromKey} or {@code toKey}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     *         is null and this map does not permit null keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * @throws IllegalArgumentException if {@code fromKey} is greater than
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     *         {@code toKey}; or if this map itself has a restricted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     *         range, and {@code fromKey} or {@code toKey} lies
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     *         outside the bounds of the range
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    NavigableMap<K,V> subMap(K fromKey, boolean fromInclusive,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                             K toKey,   boolean toInclusive);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * Returns a view of the portion of this map whose keys are less than (or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * equal to, if {@code inclusive} is true) {@code toKey}.  The returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * map is backed by this map, so changes in the returned map are reflected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * in this map, and vice-versa.  The returned map supports all optional
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * map operations that this map supports.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * <p>The returned map will throw an {@code IllegalArgumentException}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * on an attempt to insert a key outside its range.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * @param toKey high endpoint of the keys in the returned map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * @param inclusive {@code true} if the high endpoint
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     *        is to be included in the returned view
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * @return a view of the portion of this map whose keys are less than
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     *         (or equal to, if {@code inclusive} is true) {@code toKey}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * @throws ClassCastException if {@code toKey} is not compatible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     *         with this map's comparator (or, if the map has no comparator,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     *         if {@code toKey} does not implement {@link Comparable}).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     *         Implementations may, but are not required to, throw this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     *         exception if {@code toKey} cannot be compared to keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     *         currently in the map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * @throws NullPointerException if {@code toKey} is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     *         and this map does not permit null keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * @throws IllegalArgumentException if this map itself has a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     *         restricted range, and {@code toKey} lies outside the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     *         bounds of the range
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    NavigableMap<K,V> headMap(K toKey, boolean inclusive);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * Returns a view of the portion of this map whose keys are greater than (or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * equal to, if {@code inclusive} is true) {@code fromKey}.  The returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * map is backed by this map, so changes in the returned map are reflected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * in this map, and vice-versa.  The returned map supports all optional
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * map operations that this map supports.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * <p>The returned map will throw an {@code IllegalArgumentException}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * on an attempt to insert a key outside its range.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * @param fromKey low endpoint of the keys in the returned map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * @param inclusive {@code true} if the low endpoint
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     *        is to be included in the returned view
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * @return a view of the portion of this map whose keys are greater than
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     *         (or equal to, if {@code inclusive} is true) {@code fromKey}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * @throws ClassCastException if {@code fromKey} is not compatible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     *         with this map's comparator (or, if the map has no comparator,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     *         if {@code fromKey} does not implement {@link Comparable}).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     *         Implementations may, but are not required to, throw this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     *         exception if {@code fromKey} cannot be compared to keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     *         currently in the map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * @throws NullPointerException if {@code fromKey} is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     *         and this map does not permit null keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * @throws IllegalArgumentException if this map itself has a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     *         restricted range, and {@code fromKey} lies outside the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     *         bounds of the range
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    NavigableMap<K,V> tailMap(K fromKey, boolean inclusive);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * <p>Equivalent to {@code subMap(fromKey, true, toKey, false)}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * @throws ClassCastException       {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * @throws NullPointerException     {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * @throws IllegalArgumentException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    SortedMap<K,V> subMap(K fromKey, K toKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     * <p>Equivalent to {@code headMap(toKey, false)}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     * @throws ClassCastException       {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * @throws NullPointerException     {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * @throws IllegalArgumentException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    SortedMap<K,V> headMap(K toKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     * <p>Equivalent to {@code tailMap(fromKey, true)}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     * @throws ClassCastException       {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     * @throws NullPointerException     {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     * @throws IllegalArgumentException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    SortedMap<K,V> tailMap(K fromKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
}