emul/compact/src/main/java/java/util/NavigableMap.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Sat, 07 Sep 2013 13:51:24 +0200
branchjdk7-b147
changeset 1258 724f3e1ea53e
permissions -rw-r--r--
Additional set of classes to make porting of lookup library more easier
jaroslav@1258
     1
/*
jaroslav@1258
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jaroslav@1258
     3
 *
jaroslav@1258
     4
 * This code is free software; you can redistribute it and/or modify it
jaroslav@1258
     5
 * under the terms of the GNU General Public License version 2 only, as
jaroslav@1258
     6
 * published by the Free Software Foundation.  Oracle designates this
jaroslav@1258
     7
 * particular file as subject to the "Classpath" exception as provided
jaroslav@1258
     8
 * by Oracle in the LICENSE file that accompanied this code.
jaroslav@1258
     9
 *
jaroslav@1258
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
jaroslav@1258
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jaroslav@1258
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
jaroslav@1258
    13
 * version 2 for more details (a copy is included in the LICENSE file that
jaroslav@1258
    14
 * accompanied this code).
jaroslav@1258
    15
 *
jaroslav@1258
    16
 * You should have received a copy of the GNU General Public License version
jaroslav@1258
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
jaroslav@1258
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jaroslav@1258
    19
 *
jaroslav@1258
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
jaroslav@1258
    21
 * or visit www.oracle.com if you need additional information or have any
jaroslav@1258
    22
 * questions.
jaroslav@1258
    23
 */
jaroslav@1258
    24
jaroslav@1258
    25
/*
jaroslav@1258
    26
 * This file is available under and governed by the GNU General Public
jaroslav@1258
    27
 * License version 2 only, as published by the Free Software Foundation.
jaroslav@1258
    28
 * However, the following notice accompanied the original version of this
jaroslav@1258
    29
 * file:
jaroslav@1258
    30
 *
jaroslav@1258
    31
 * Written by Doug Lea and Josh Bloch with assistance from members of JCP
jaroslav@1258
    32
 * JSR-166 Expert Group and released to the public domain, as explained at
jaroslav@1258
    33
 * http://creativecommons.org/publicdomain/zero/1.0/
jaroslav@1258
    34
 */
jaroslav@1258
    35
jaroslav@1258
    36
package java.util;
jaroslav@1258
    37
jaroslav@1258
    38
/**
jaroslav@1258
    39
 * A {@link SortedMap} extended with navigation methods returning the
jaroslav@1258
    40
 * closest matches for given search targets. Methods
jaroslav@1258
    41
 * {@code lowerEntry}, {@code floorEntry}, {@code ceilingEntry},
jaroslav@1258
    42
 * and {@code higherEntry} return {@code Map.Entry} objects
jaroslav@1258
    43
 * associated with keys respectively less than, less than or equal,
jaroslav@1258
    44
 * greater than or equal, and greater than a given key, returning
jaroslav@1258
    45
 * {@code null} if there is no such key.  Similarly, methods
jaroslav@1258
    46
 * {@code lowerKey}, {@code floorKey}, {@code ceilingKey}, and
jaroslav@1258
    47
 * {@code higherKey} return only the associated keys. All of these
jaroslav@1258
    48
 * methods are designed for locating, not traversing entries.
jaroslav@1258
    49
 *
jaroslav@1258
    50
 * <p>A {@code NavigableMap} may be accessed and traversed in either
jaroslav@1258
    51
 * ascending or descending key order.  The {@code descendingMap}
jaroslav@1258
    52
 * method returns a view of the map with the senses of all relational
jaroslav@1258
    53
 * and directional methods inverted. The performance of ascending
jaroslav@1258
    54
 * operations and views is likely to be faster than that of descending
jaroslav@1258
    55
 * ones.  Methods {@code subMap}, {@code headMap},
jaroslav@1258
    56
 * and {@code tailMap} differ from the like-named {@code
jaroslav@1258
    57
 * SortedMap} methods in accepting additional arguments describing
jaroslav@1258
    58
 * whether lower and upper bounds are inclusive versus exclusive.
jaroslav@1258
    59
 * Submaps of any {@code NavigableMap} must implement the {@code
jaroslav@1258
    60
 * NavigableMap} interface.
jaroslav@1258
    61
 *
jaroslav@1258
    62
 * <p>This interface additionally defines methods {@code firstEntry},
jaroslav@1258
    63
 * {@code pollFirstEntry}, {@code lastEntry}, and
jaroslav@1258
    64
 * {@code pollLastEntry} that return and/or remove the least and
jaroslav@1258
    65
 * greatest mappings, if any exist, else returning {@code null}.
jaroslav@1258
    66
 *
jaroslav@1258
    67
 * <p>Implementations of entry-returning methods are expected to
jaroslav@1258
    68
 * return {@code Map.Entry} pairs representing snapshots of mappings
jaroslav@1258
    69
 * at the time they were produced, and thus generally do <em>not</em>
jaroslav@1258
    70
 * support the optional {@code Entry.setValue} method. Note however
jaroslav@1258
    71
 * that it is possible to change mappings in the associated map using
jaroslav@1258
    72
 * method {@code put}.
jaroslav@1258
    73
 *
jaroslav@1258
    74
 * <p>Methods
jaroslav@1258
    75
 * {@link #subMap(Object, Object) subMap(K, K)},
jaroslav@1258
    76
 * {@link #headMap(Object) headMap(K)}, and
jaroslav@1258
    77
 * {@link #tailMap(Object) tailMap(K)}
jaroslav@1258
    78
 * are specified to return {@code SortedMap} to allow existing
jaroslav@1258
    79
 * implementations of {@code SortedMap} to be compatibly retrofitted to
jaroslav@1258
    80
 * implement {@code NavigableMap}, but extensions and implementations
jaroslav@1258
    81
 * of this interface are encouraged to override these methods to return
jaroslav@1258
    82
 * {@code NavigableMap}.  Similarly,
jaroslav@1258
    83
 * {@link #keySet()} can be overriden to return {@code NavigableSet}.
jaroslav@1258
    84
 *
jaroslav@1258
    85
 * <p>This interface is a member of the
jaroslav@1258
    86
 * <a href="{@docRoot}/../technotes/guides/collections/index.html">
jaroslav@1258
    87
 * Java Collections Framework</a>.
jaroslav@1258
    88
 *
jaroslav@1258
    89
 * @author Doug Lea
jaroslav@1258
    90
 * @author Josh Bloch
jaroslav@1258
    91
 * @param <K> the type of keys maintained by this map
jaroslav@1258
    92
 * @param <V> the type of mapped values
jaroslav@1258
    93
 * @since 1.6
jaroslav@1258
    94
 */
jaroslav@1258
    95
public interface NavigableMap<K,V> extends SortedMap<K,V> {
jaroslav@1258
    96
    /**
jaroslav@1258
    97
     * Returns a key-value mapping associated with the greatest key
jaroslav@1258
    98
     * strictly less than the given key, or {@code null} if there is
jaroslav@1258
    99
     * no such key.
jaroslav@1258
   100
     *
jaroslav@1258
   101
     * @param key the key
jaroslav@1258
   102
     * @return an entry with the greatest key less than {@code key},
jaroslav@1258
   103
     *         or {@code null} if there is no such key
jaroslav@1258
   104
     * @throws ClassCastException if the specified key cannot be compared
jaroslav@1258
   105
     *         with the keys currently in the map
jaroslav@1258
   106
     * @throws NullPointerException if the specified key is null
jaroslav@1258
   107
     *         and this map does not permit null keys
jaroslav@1258
   108
     */
jaroslav@1258
   109
    Map.Entry<K,V> lowerEntry(K key);
jaroslav@1258
   110
jaroslav@1258
   111
    /**
jaroslav@1258
   112
     * Returns the greatest key strictly less than the given key, or
jaroslav@1258
   113
     * {@code null} if there is no such key.
jaroslav@1258
   114
     *
jaroslav@1258
   115
     * @param key the key
jaroslav@1258
   116
     * @return the greatest key less than {@code key},
jaroslav@1258
   117
     *         or {@code null} if there is no such key
jaroslav@1258
   118
     * @throws ClassCastException if the specified key cannot be compared
jaroslav@1258
   119
     *         with the keys currently in the map
jaroslav@1258
   120
     * @throws NullPointerException if the specified key is null
jaroslav@1258
   121
     *         and this map does not permit null keys
jaroslav@1258
   122
     */
jaroslav@1258
   123
    K lowerKey(K key);
jaroslav@1258
   124
jaroslav@1258
   125
    /**
jaroslav@1258
   126
     * Returns a key-value mapping associated with the greatest key
jaroslav@1258
   127
     * less than or equal to the given key, or {@code null} if there
jaroslav@1258
   128
     * is no such key.
jaroslav@1258
   129
     *
jaroslav@1258
   130
     * @param key the key
jaroslav@1258
   131
     * @return an entry with the greatest key less than or equal to
jaroslav@1258
   132
     *         {@code key}, or {@code null} if there is no such key
jaroslav@1258
   133
     * @throws ClassCastException if the specified key cannot be compared
jaroslav@1258
   134
     *         with the keys currently in the map
jaroslav@1258
   135
     * @throws NullPointerException if the specified key is null
jaroslav@1258
   136
     *         and this map does not permit null keys
jaroslav@1258
   137
     */
jaroslav@1258
   138
    Map.Entry<K,V> floorEntry(K key);
jaroslav@1258
   139
jaroslav@1258
   140
    /**
jaroslav@1258
   141
     * Returns the greatest key less than or equal to the given key,
jaroslav@1258
   142
     * or {@code null} if there is no such key.
jaroslav@1258
   143
     *
jaroslav@1258
   144
     * @param key the key
jaroslav@1258
   145
     * @return the greatest key less than or equal to {@code key},
jaroslav@1258
   146
     *         or {@code null} if there is no such key
jaroslav@1258
   147
     * @throws ClassCastException if the specified key cannot be compared
jaroslav@1258
   148
     *         with the keys currently in the map
jaroslav@1258
   149
     * @throws NullPointerException if the specified key is null
jaroslav@1258
   150
     *         and this map does not permit null keys
jaroslav@1258
   151
     */
jaroslav@1258
   152
    K floorKey(K key);
jaroslav@1258
   153
jaroslav@1258
   154
    /**
jaroslav@1258
   155
     * Returns a key-value mapping associated with the least key
jaroslav@1258
   156
     * greater than or equal to the given key, or {@code null} if
jaroslav@1258
   157
     * there is no such key.
jaroslav@1258
   158
     *
jaroslav@1258
   159
     * @param key the key
jaroslav@1258
   160
     * @return an entry with the least key greater than or equal to
jaroslav@1258
   161
     *         {@code key}, or {@code null} if there is no such key
jaroslav@1258
   162
     * @throws ClassCastException if the specified key cannot be compared
jaroslav@1258
   163
     *         with the keys currently in the map
jaroslav@1258
   164
     * @throws NullPointerException if the specified key is null
jaroslav@1258
   165
     *         and this map does not permit null keys
jaroslav@1258
   166
     */
jaroslav@1258
   167
    Map.Entry<K,V> ceilingEntry(K key);
jaroslav@1258
   168
jaroslav@1258
   169
    /**
jaroslav@1258
   170
     * Returns the least key greater than or equal to the given key,
jaroslav@1258
   171
     * or {@code null} if there is no such key.
jaroslav@1258
   172
     *
jaroslav@1258
   173
     * @param key the key
jaroslav@1258
   174
     * @return the least key greater than or equal to {@code key},
jaroslav@1258
   175
     *         or {@code null} if there is no such key
jaroslav@1258
   176
     * @throws ClassCastException if the specified key cannot be compared
jaroslav@1258
   177
     *         with the keys currently in the map
jaroslav@1258
   178
     * @throws NullPointerException if the specified key is null
jaroslav@1258
   179
     *         and this map does not permit null keys
jaroslav@1258
   180
     */
jaroslav@1258
   181
    K ceilingKey(K key);
jaroslav@1258
   182
jaroslav@1258
   183
    /**
jaroslav@1258
   184
     * Returns a key-value mapping associated with the least key
jaroslav@1258
   185
     * strictly greater than the given key, or {@code null} if there
jaroslav@1258
   186
     * is no such key.
jaroslav@1258
   187
     *
jaroslav@1258
   188
     * @param key the key
jaroslav@1258
   189
     * @return an entry with the least key greater than {@code key},
jaroslav@1258
   190
     *         or {@code null} if there is no such key
jaroslav@1258
   191
     * @throws ClassCastException if the specified key cannot be compared
jaroslav@1258
   192
     *         with the keys currently in the map
jaroslav@1258
   193
     * @throws NullPointerException if the specified key is null
jaroslav@1258
   194
     *         and this map does not permit null keys
jaroslav@1258
   195
     */
jaroslav@1258
   196
    Map.Entry<K,V> higherEntry(K key);
jaroslav@1258
   197
jaroslav@1258
   198
    /**
jaroslav@1258
   199
     * Returns the least key strictly greater than the given key, or
jaroslav@1258
   200
     * {@code null} if there is no such key.
jaroslav@1258
   201
     *
jaroslav@1258
   202
     * @param key the key
jaroslav@1258
   203
     * @return the least key greater than {@code key},
jaroslav@1258
   204
     *         or {@code null} if there is no such key
jaroslav@1258
   205
     * @throws ClassCastException if the specified key cannot be compared
jaroslav@1258
   206
     *         with the keys currently in the map
jaroslav@1258
   207
     * @throws NullPointerException if the specified key is null
jaroslav@1258
   208
     *         and this map does not permit null keys
jaroslav@1258
   209
     */
jaroslav@1258
   210
    K higherKey(K key);
jaroslav@1258
   211
jaroslav@1258
   212
    /**
jaroslav@1258
   213
     * Returns a key-value mapping associated with the least
jaroslav@1258
   214
     * key in this map, or {@code null} if the map is empty.
jaroslav@1258
   215
     *
jaroslav@1258
   216
     * @return an entry with the least key,
jaroslav@1258
   217
     *         or {@code null} if this map is empty
jaroslav@1258
   218
     */
jaroslav@1258
   219
    Map.Entry<K,V> firstEntry();
jaroslav@1258
   220
jaroslav@1258
   221
    /**
jaroslav@1258
   222
     * Returns a key-value mapping associated with the greatest
jaroslav@1258
   223
     * key in this map, or {@code null} if the map is empty.
jaroslav@1258
   224
     *
jaroslav@1258
   225
     * @return an entry with the greatest key,
jaroslav@1258
   226
     *         or {@code null} if this map is empty
jaroslav@1258
   227
     */
jaroslav@1258
   228
    Map.Entry<K,V> lastEntry();
jaroslav@1258
   229
jaroslav@1258
   230
    /**
jaroslav@1258
   231
     * Removes and returns a key-value mapping associated with
jaroslav@1258
   232
     * the least key in this map, or {@code null} if the map is empty.
jaroslav@1258
   233
     *
jaroslav@1258
   234
     * @return the removed first entry of this map,
jaroslav@1258
   235
     *         or {@code null} if this map is empty
jaroslav@1258
   236
     */
jaroslav@1258
   237
    Map.Entry<K,V> pollFirstEntry();
jaroslav@1258
   238
jaroslav@1258
   239
    /**
jaroslav@1258
   240
     * Removes and returns a key-value mapping associated with
jaroslav@1258
   241
     * the greatest key in this map, or {@code null} if the map is empty.
jaroslav@1258
   242
     *
jaroslav@1258
   243
     * @return the removed last entry of this map,
jaroslav@1258
   244
     *         or {@code null} if this map is empty
jaroslav@1258
   245
     */
jaroslav@1258
   246
    Map.Entry<K,V> pollLastEntry();
jaroslav@1258
   247
jaroslav@1258
   248
    /**
jaroslav@1258
   249
     * Returns a reverse order view of the mappings contained in this map.
jaroslav@1258
   250
     * The descending map is backed by this map, so changes to the map are
jaroslav@1258
   251
     * reflected in the descending map, and vice-versa.  If either map is
jaroslav@1258
   252
     * modified while an iteration over a collection view of either map
jaroslav@1258
   253
     * is in progress (except through the iterator's own {@code remove}
jaroslav@1258
   254
     * operation), the results of the iteration are undefined.
jaroslav@1258
   255
     *
jaroslav@1258
   256
     * <p>The returned map has an ordering equivalent to
jaroslav@1258
   257
     * <tt>{@link Collections#reverseOrder(Comparator) Collections.reverseOrder}(comparator())</tt>.
jaroslav@1258
   258
     * The expression {@code m.descendingMap().descendingMap()} returns a
jaroslav@1258
   259
     * view of {@code m} essentially equivalent to {@code m}.
jaroslav@1258
   260
     *
jaroslav@1258
   261
     * @return a reverse order view of this map
jaroslav@1258
   262
     */
jaroslav@1258
   263
    NavigableMap<K,V> descendingMap();
jaroslav@1258
   264
jaroslav@1258
   265
    /**
jaroslav@1258
   266
     * Returns a {@link NavigableSet} view of the keys contained in this map.
jaroslav@1258
   267
     * The set's iterator returns the keys in ascending order.
jaroslav@1258
   268
     * The set is backed by the map, so changes to the map are reflected in
jaroslav@1258
   269
     * the set, and vice-versa.  If the map is modified while an iteration
jaroslav@1258
   270
     * over the set is in progress (except through the iterator's own {@code
jaroslav@1258
   271
     * remove} operation), the results of the iteration are undefined.  The
jaroslav@1258
   272
     * set supports element removal, which removes the corresponding mapping
jaroslav@1258
   273
     * from the map, via the {@code Iterator.remove}, {@code Set.remove},
jaroslav@1258
   274
     * {@code removeAll}, {@code retainAll}, and {@code clear} operations.
jaroslav@1258
   275
     * It does not support the {@code add} or {@code addAll} operations.
jaroslav@1258
   276
     *
jaroslav@1258
   277
     * @return a navigable set view of the keys in this map
jaroslav@1258
   278
     */
jaroslav@1258
   279
    NavigableSet<K> navigableKeySet();
jaroslav@1258
   280
jaroslav@1258
   281
    /**
jaroslav@1258
   282
     * Returns a reverse order {@link NavigableSet} view of the keys contained in this map.
jaroslav@1258
   283
     * The set's iterator returns the keys in descending order.
jaroslav@1258
   284
     * The set is backed by the map, so changes to the map are reflected in
jaroslav@1258
   285
     * the set, and vice-versa.  If the map is modified while an iteration
jaroslav@1258
   286
     * over the set is in progress (except through the iterator's own {@code
jaroslav@1258
   287
     * remove} operation), the results of the iteration are undefined.  The
jaroslav@1258
   288
     * set supports element removal, which removes the corresponding mapping
jaroslav@1258
   289
     * from the map, via the {@code Iterator.remove}, {@code Set.remove},
jaroslav@1258
   290
     * {@code removeAll}, {@code retainAll}, and {@code clear} operations.
jaroslav@1258
   291
     * It does not support the {@code add} or {@code addAll} operations.
jaroslav@1258
   292
     *
jaroslav@1258
   293
     * @return a reverse order navigable set view of the keys in this map
jaroslav@1258
   294
     */
jaroslav@1258
   295
    NavigableSet<K> descendingKeySet();
jaroslav@1258
   296
jaroslav@1258
   297
    /**
jaroslav@1258
   298
     * Returns a view of the portion of this map whose keys range from
jaroslav@1258
   299
     * {@code fromKey} to {@code toKey}.  If {@code fromKey} and
jaroslav@1258
   300
     * {@code toKey} are equal, the returned map is empty unless
jaroslav@1258
   301
     * {@code fromInclusive} and {@code toInclusive} are both true.  The
jaroslav@1258
   302
     * returned map is backed by this map, so changes in the returned map are
jaroslav@1258
   303
     * reflected in this map, and vice-versa.  The returned map supports all
jaroslav@1258
   304
     * optional map operations that this map supports.
jaroslav@1258
   305
     *
jaroslav@1258
   306
     * <p>The returned map will throw an {@code IllegalArgumentException}
jaroslav@1258
   307
     * on an attempt to insert a key outside of its range, or to construct a
jaroslav@1258
   308
     * submap either of whose endpoints lie outside its range.
jaroslav@1258
   309
     *
jaroslav@1258
   310
     * @param fromKey low endpoint of the keys in the returned map
jaroslav@1258
   311
     * @param fromInclusive {@code true} if the low endpoint
jaroslav@1258
   312
     *        is to be included in the returned view
jaroslav@1258
   313
     * @param toKey high endpoint of the keys in the returned map
jaroslav@1258
   314
     * @param toInclusive {@code true} if the high endpoint
jaroslav@1258
   315
     *        is to be included in the returned view
jaroslav@1258
   316
     * @return a view of the portion of this map whose keys range from
jaroslav@1258
   317
     *         {@code fromKey} to {@code toKey}
jaroslav@1258
   318
     * @throws ClassCastException if {@code fromKey} and {@code toKey}
jaroslav@1258
   319
     *         cannot be compared to one another using this map's comparator
jaroslav@1258
   320
     *         (or, if the map has no comparator, using natural ordering).
jaroslav@1258
   321
     *         Implementations may, but are not required to, throw this
jaroslav@1258
   322
     *         exception if {@code fromKey} or {@code toKey}
jaroslav@1258
   323
     *         cannot be compared to keys currently in the map.
jaroslav@1258
   324
     * @throws NullPointerException if {@code fromKey} or {@code toKey}
jaroslav@1258
   325
     *         is null and this map does not permit null keys
jaroslav@1258
   326
     * @throws IllegalArgumentException if {@code fromKey} is greater than
jaroslav@1258
   327
     *         {@code toKey}; or if this map itself has a restricted
jaroslav@1258
   328
     *         range, and {@code fromKey} or {@code toKey} lies
jaroslav@1258
   329
     *         outside the bounds of the range
jaroslav@1258
   330
     */
jaroslav@1258
   331
    NavigableMap<K,V> subMap(K fromKey, boolean fromInclusive,
jaroslav@1258
   332
                             K toKey,   boolean toInclusive);
jaroslav@1258
   333
jaroslav@1258
   334
    /**
jaroslav@1258
   335
     * Returns a view of the portion of this map whose keys are less than (or
jaroslav@1258
   336
     * equal to, if {@code inclusive} is true) {@code toKey}.  The returned
jaroslav@1258
   337
     * map is backed by this map, so changes in the returned map are reflected
jaroslav@1258
   338
     * in this map, and vice-versa.  The returned map supports all optional
jaroslav@1258
   339
     * map operations that this map supports.
jaroslav@1258
   340
     *
jaroslav@1258
   341
     * <p>The returned map will throw an {@code IllegalArgumentException}
jaroslav@1258
   342
     * on an attempt to insert a key outside its range.
jaroslav@1258
   343
     *
jaroslav@1258
   344
     * @param toKey high endpoint of the keys in the returned map
jaroslav@1258
   345
     * @param inclusive {@code true} if the high endpoint
jaroslav@1258
   346
     *        is to be included in the returned view
jaroslav@1258
   347
     * @return a view of the portion of this map whose keys are less than
jaroslav@1258
   348
     *         (or equal to, if {@code inclusive} is true) {@code toKey}
jaroslav@1258
   349
     * @throws ClassCastException if {@code toKey} is not compatible
jaroslav@1258
   350
     *         with this map's comparator (or, if the map has no comparator,
jaroslav@1258
   351
     *         if {@code toKey} does not implement {@link Comparable}).
jaroslav@1258
   352
     *         Implementations may, but are not required to, throw this
jaroslav@1258
   353
     *         exception if {@code toKey} cannot be compared to keys
jaroslav@1258
   354
     *         currently in the map.
jaroslav@1258
   355
     * @throws NullPointerException if {@code toKey} is null
jaroslav@1258
   356
     *         and this map does not permit null keys
jaroslav@1258
   357
     * @throws IllegalArgumentException if this map itself has a
jaroslav@1258
   358
     *         restricted range, and {@code toKey} lies outside the
jaroslav@1258
   359
     *         bounds of the range
jaroslav@1258
   360
     */
jaroslav@1258
   361
    NavigableMap<K,V> headMap(K toKey, boolean inclusive);
jaroslav@1258
   362
jaroslav@1258
   363
    /**
jaroslav@1258
   364
     * Returns a view of the portion of this map whose keys are greater than (or
jaroslav@1258
   365
     * equal to, if {@code inclusive} is true) {@code fromKey}.  The returned
jaroslav@1258
   366
     * map is backed by this map, so changes in the returned map are reflected
jaroslav@1258
   367
     * in this map, and vice-versa.  The returned map supports all optional
jaroslav@1258
   368
     * map operations that this map supports.
jaroslav@1258
   369
     *
jaroslav@1258
   370
     * <p>The returned map will throw an {@code IllegalArgumentException}
jaroslav@1258
   371
     * on an attempt to insert a key outside its range.
jaroslav@1258
   372
     *
jaroslav@1258
   373
     * @param fromKey low endpoint of the keys in the returned map
jaroslav@1258
   374
     * @param inclusive {@code true} if the low endpoint
jaroslav@1258
   375
     *        is to be included in the returned view
jaroslav@1258
   376
     * @return a view of the portion of this map whose keys are greater than
jaroslav@1258
   377
     *         (or equal to, if {@code inclusive} is true) {@code fromKey}
jaroslav@1258
   378
     * @throws ClassCastException if {@code fromKey} is not compatible
jaroslav@1258
   379
     *         with this map's comparator (or, if the map has no comparator,
jaroslav@1258
   380
     *         if {@code fromKey} does not implement {@link Comparable}).
jaroslav@1258
   381
     *         Implementations may, but are not required to, throw this
jaroslav@1258
   382
     *         exception if {@code fromKey} cannot be compared to keys
jaroslav@1258
   383
     *         currently in the map.
jaroslav@1258
   384
     * @throws NullPointerException if {@code fromKey} is null
jaroslav@1258
   385
     *         and this map does not permit null keys
jaroslav@1258
   386
     * @throws IllegalArgumentException if this map itself has a
jaroslav@1258
   387
     *         restricted range, and {@code fromKey} lies outside the
jaroslav@1258
   388
     *         bounds of the range
jaroslav@1258
   389
     */
jaroslav@1258
   390
    NavigableMap<K,V> tailMap(K fromKey, boolean inclusive);
jaroslav@1258
   391
jaroslav@1258
   392
    /**
jaroslav@1258
   393
     * {@inheritDoc}
jaroslav@1258
   394
     *
jaroslav@1258
   395
     * <p>Equivalent to {@code subMap(fromKey, true, toKey, false)}.
jaroslav@1258
   396
     *
jaroslav@1258
   397
     * @throws ClassCastException       {@inheritDoc}
jaroslav@1258
   398
     * @throws NullPointerException     {@inheritDoc}
jaroslav@1258
   399
     * @throws IllegalArgumentException {@inheritDoc}
jaroslav@1258
   400
     */
jaroslav@1258
   401
    SortedMap<K,V> subMap(K fromKey, K toKey);
jaroslav@1258
   402
jaroslav@1258
   403
    /**
jaroslav@1258
   404
     * {@inheritDoc}
jaroslav@1258
   405
     *
jaroslav@1258
   406
     * <p>Equivalent to {@code headMap(toKey, false)}.
jaroslav@1258
   407
     *
jaroslav@1258
   408
     * @throws ClassCastException       {@inheritDoc}
jaroslav@1258
   409
     * @throws NullPointerException     {@inheritDoc}
jaroslav@1258
   410
     * @throws IllegalArgumentException {@inheritDoc}
jaroslav@1258
   411
     */
jaroslav@1258
   412
    SortedMap<K,V> headMap(K toKey);
jaroslav@1258
   413
jaroslav@1258
   414
    /**
jaroslav@1258
   415
     * {@inheritDoc}
jaroslav@1258
   416
     *
jaroslav@1258
   417
     * <p>Equivalent to {@code tailMap(fromKey, true)}.
jaroslav@1258
   418
     *
jaroslav@1258
   419
     * @throws ClassCastException       {@inheritDoc}
jaroslav@1258
   420
     * @throws NullPointerException     {@inheritDoc}
jaroslav@1258
   421
     * @throws IllegalArgumentException {@inheritDoc}
jaroslav@1258
   422
     */
jaroslav@1258
   423
    SortedMap<K,V> tailMap(K fromKey);
jaroslav@1258
   424
}