0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * This file is available under and governed by the GNU General Public 0N/A * License version 2 only, as published by the Free Software Foundation. 0N/A * However, the following notice accompanied the original version of this 0N/A * Written by Doug Lea and Josh Bloch with assistance from members of JCP 0N/A * JSR-166 Expert Group and released to the public domain, as explained at 0N/A * A {@link SortedMap} extended with navigation methods returning the 0N/A * closest matches for given search targets. Methods 0N/A * {@code lowerEntry}, {@code floorEntry}, {@code ceilingEntry}, 0N/A * and {@code higherEntry} return {@code Map.Entry} objects 0N/A * associated with keys respectively less than, less than or equal, 0N/A * greater than or equal, and greater than a given key, returning 0N/A * {@code null} if there is no such key. Similarly, methods 0N/A * {@code lowerKey}, {@code floorKey}, {@code ceilingKey}, and 0N/A * {@code higherKey} return only the associated keys. All of these 0N/A * methods are designed for locating, not traversing entries. 0N/A * <p>A {@code NavigableMap} may be accessed and traversed in either 0N/A * ascending or descending key order. The {@code descendingMap} 0N/A * method returns a view of the map with the senses of all relational 0N/A * and directional methods inverted. The performance of ascending 0N/A * operations and views is likely to be faster than that of descending 0N/A * ones. Methods {@code subMap}, {@code headMap}, 0N/A * and {@code tailMap} differ from the like-named {@code 0N/A * SortedMap} methods in accepting additional arguments describing 0N/A * whether lower and upper bounds are inclusive versus exclusive. 0N/A * Submaps of any {@code NavigableMap} must implement the {@code 0N/A * NavigableMap} interface. 0N/A * <p>This interface additionally defines methods {@code firstEntry}, 0N/A * {@code pollFirstEntry}, {@code lastEntry}, and 0N/A * {@code pollLastEntry} that return and/or remove the least and 0N/A * greatest mappings, if any exist, else returning {@code null}. 0N/A * <p>Implementations of entry-returning methods are expected to 0N/A * return {@code Map.Entry} pairs representing snapshots of mappings 0N/A * at the time they were produced, and thus generally do <em>not</em> 0N/A * support the optional {@code Entry.setValue} method. Note however 0N/A * that it is possible to change mappings in the associated map using 0N/A * method {@code put}. 0N/A * {@link #subMap(Object, Object) subMap(K, K)}, 0N/A * {@link #headMap(Object) headMap(K)}, and 0N/A * {@link #tailMap(Object) tailMap(K)} 0N/A * are specified to return {@code SortedMap} to allow existing 0N/A * implementations of {@code SortedMap} to be compatibly retrofitted to 0N/A * implement {@code NavigableMap}, but extensions and implementations 0N/A * of this interface are encouraged to override these methods to return 0N/A * {@code NavigableMap}. Similarly, 0N/A * {@link #keySet()} can be overriden to return {@code NavigableSet}. 0N/A * <p>This interface is a member of the 0N/A * Java Collections Framework</a>. 0N/A * @author Josh Bloch 0N/A * @param <K> the type of keys maintained by this map 0N/A * @param <V> the type of mapped values 0N/A * Returns a key-value mapping associated with the greatest key 0N/A * strictly less than the given key, or {@code null} if there is 0N/A * @param key the key 0N/A * @return an entry with the greatest key less than {@code key}, 0N/A * or {@code null} if there is no such key 0N/A * @throws ClassCastException if the specified key cannot be compared 0N/A * with the keys currently in the map 0N/A * @throws NullPointerException if the specified key is null 0N/A * and this map does not permit null keys 0N/A * Returns the greatest key strictly less than the given key, or 0N/A * {@code null} if there is no such key. 0N/A * @param key the key 0N/A * @return the greatest key less than {@code key}, 0N/A * or {@code null} if there is no such key 0N/A * @throws ClassCastException if the specified key cannot be compared 0N/A * with the keys currently in the map 0N/A * @throws NullPointerException if the specified key is null 0N/A * and this map does not permit null keys 0N/A * Returns a key-value mapping associated with the greatest key 0N/A * less than or equal to the given key, or {@code null} if there 0N/A * @param key the key 0N/A * @return an entry with the greatest key less than or equal to 0N/A * {@code key}, or {@code null} if there is no such key 0N/A * @throws ClassCastException if the specified key cannot be compared 0N/A * with the keys currently in the map 0N/A * @throws NullPointerException if the specified key is null 0N/A * and this map does not permit null keys 0N/A * Returns the greatest key less than or equal to the given key, 0N/A * or {@code null} if there is no such key. 0N/A * @param key the key 0N/A * @return the greatest key less than or equal to {@code key}, 0N/A * or {@code null} if there is no such key 0N/A * @throws ClassCastException if the specified key cannot be compared 0N/A * with the keys currently in the map 0N/A * @throws NullPointerException if the specified key is null 0N/A * and this map does not permit null keys 0N/A * Returns a key-value mapping associated with the least key 0N/A * greater than or equal to the given key, or {@code null} if 0N/A * there is no such key. 0N/A * @param key the key 0N/A * @return an entry with the least key greater than or equal to 0N/A * {@code key}, or {@code null} if there is no such key 0N/A * @throws ClassCastException if the specified key cannot be compared 0N/A * with the keys currently in the map 0N/A * @throws NullPointerException if the specified key is null 0N/A * and this map does not permit null keys 0N/A * Returns the least key greater than or equal to the given key, 0N/A * or {@code null} if there is no such key. 0N/A * @param key the key 0N/A * @return the least key greater than or equal to {@code key}, 0N/A * or {@code null} if there is no such key 0N/A * @throws ClassCastException if the specified key cannot be compared 0N/A * with the keys currently in the map 0N/A * @throws NullPointerException if the specified key is null 0N/A * and this map does not permit null keys 0N/A * Returns a key-value mapping associated with the least key 0N/A * strictly greater than the given key, or {@code null} if there 0N/A * @param key the key 0N/A * @return an entry with the least key greater than {@code key}, 0N/A * or {@code null} if there is no such key 0N/A * @throws ClassCastException if the specified key cannot be compared 0N/A * with the keys currently in the map 0N/A * @throws NullPointerException if the specified key is null 0N/A * and this map does not permit null keys 0N/A * Returns the least key strictly greater than the given key, or 0N/A * {@code null} if there is no such key. 0N/A * @param key the key 0N/A * @return the least key greater than {@code key}, 0N/A * or {@code null} if there is no such key 0N/A * @throws ClassCastException if the specified key cannot be compared 0N/A * with the keys currently in the map 0N/A * @throws NullPointerException if the specified key is null 0N/A * and this map does not permit null keys 0N/A * Returns a key-value mapping associated with the least 0N/A * key in this map, or {@code null} if the map is empty. 0N/A * @return an entry with the least key, 0N/A * or {@code null} if this map is empty 0N/A * Returns a key-value mapping associated with the greatest 0N/A * key in this map, or {@code null} if the map is empty. 0N/A * @return an entry with the greatest key, 0N/A * or {@code null} if this map is empty 0N/A * Removes and returns a key-value mapping associated with 0N/A * the least key in this map, or {@code null} if the map is empty. 0N/A * @return the removed first entry of this map, 0N/A * or {@code null} if this map is empty 0N/A * Removes and returns a key-value mapping associated with 0N/A * the greatest key in this map, or {@code null} if the map is empty. 0N/A * @return the removed last entry of this map, 0N/A * or {@code null} if this map is empty 0N/A * Returns a reverse order view of the mappings contained in this map. 0N/A * The descending map is backed by this map, so changes to the map are 0N/A * reflected in the descending map, and vice-versa. If either map is 0N/A * modified while an iteration over a collection view of either map 0N/A * is in progress (except through the iterator's own {@code remove} 0N/A * operation), the results of the iteration are undefined. 0N/A * <p>The returned map has an ordering equivalent to 0N/A * <tt>{@link Collections#reverseOrder(Comparator) Collections.reverseOrder}(comparator())</tt>. 0N/A * The expression {@code m.descendingMap().descendingMap()} returns a 0N/A * view of {@code m} essentially equivalent to {@code m}. 0N/A * @return a reverse order view of this map 0N/A * Returns a {@link NavigableSet} view of the keys contained in this map. 0N/A * The set's iterator returns the keys in ascending order. 0N/A * The set is backed by the map, so changes to the map are reflected in 0N/A * the set, and vice-versa. If the map is modified while an iteration 0N/A * over the set is in progress (except through the iterator's own {@code 0N/A * remove} operation), the results of the iteration are undefined. The 0N/A * set supports element removal, which removes the corresponding mapping 0N/A * from the map, via the {@code Iterator.remove}, {@code Set.remove}, 0N/A * {@code removeAll}, {@code retainAll}, and {@code clear} operations. 0N/A * It does not support the {@code add} or {@code addAll} operations. 0N/A * @return a navigable set view of the keys in this map 0N/A * Returns a reverse order {@link NavigableSet} view of the keys contained in this map. 0N/A * The set's iterator returns the keys in descending order. 0N/A * The set is backed by the map, so changes to the map are reflected in 0N/A * the set, and vice-versa. If the map is modified while an iteration 0N/A * over the set is in progress (except through the iterator's own {@code 0N/A * remove} operation), the results of the iteration are undefined. The 0N/A * set supports element removal, which removes the corresponding mapping 0N/A * from the map, via the {@code Iterator.remove}, {@code Set.remove}, 0N/A * {@code removeAll}, {@code retainAll}, and {@code clear} operations. 0N/A * It does not support the {@code add} or {@code addAll} operations. 0N/A * @return a reverse order navigable set view of the keys in this map 0N/A * Returns a view of the portion of this map whose keys range from 0N/A * {@code fromKey} to {@code toKey}. If {@code fromKey} and 0N/A * {@code toKey} are equal, the returned map is empty unless 2085N/A * {@code fromInclusive} and {@code toInclusive} are both true. The 0N/A * returned map is backed by this map, so changes in the returned map are 0N/A * reflected in this map, and vice-versa. The returned map supports all 0N/A * optional map operations that this map supports. 0N/A * <p>The returned map will throw an {@code IllegalArgumentException} 0N/A * on an attempt to insert a key outside of its range, or to construct a 0N/A * submap either of whose endpoints lie outside its range. 0N/A * @param fromKey low endpoint of the keys in the returned map 0N/A * @param fromInclusive {@code true} if the low endpoint 0N/A * is to be included in the returned view 0N/A * @param toKey high endpoint of the keys in the returned map 0N/A * @param toInclusive {@code true} if the high endpoint 0N/A * is to be included in the returned view 0N/A * @return a view of the portion of this map whose keys range from 0N/A * {@code fromKey} to {@code toKey} 0N/A * @throws ClassCastException if {@code fromKey} and {@code toKey} 0N/A * cannot be compared to one another using this map's comparator 0N/A * (or, if the map has no comparator, using natural ordering). 0N/A * Implementations may, but are not required to, throw this 0N/A * exception if {@code fromKey} or {@code toKey} 0N/A * cannot be compared to keys currently in the map. 0N/A * @throws NullPointerException if {@code fromKey} or {@code toKey} 0N/A * is null and this map does not permit null keys 0N/A * @throws IllegalArgumentException if {@code fromKey} is greater than 0N/A * {@code toKey}; or if this map itself has a restricted 0N/A * range, and {@code fromKey} or {@code toKey} lies 0N/A * outside the bounds of the range 0N/A * Returns a view of the portion of this map whose keys are less than (or 0N/A * equal to, if {@code inclusive} is true) {@code toKey}. The returned 0N/A * map is backed by this map, so changes in the returned map are reflected 0N/A * in this map, and vice-versa. The returned map supports all optional 0N/A * map operations that this map supports. 0N/A * <p>The returned map will throw an {@code IllegalArgumentException} 0N/A * on an attempt to insert a key outside its range. 0N/A * @param toKey high endpoint of the keys in the returned map 0N/A * @param inclusive {@code true} if the high endpoint 0N/A * is to be included in the returned view 0N/A * @return a view of the portion of this map whose keys are less than 0N/A * (or equal to, if {@code inclusive} is true) {@code toKey} 0N/A * @throws ClassCastException if {@code toKey} is not compatible 0N/A * with this map's comparator (or, if the map has no comparator, 0N/A * if {@code toKey} does not implement {@link Comparable}). 0N/A * Implementations may, but are not required to, throw this 0N/A * exception if {@code toKey} cannot be compared to keys 0N/A * currently in the map. 0N/A * @throws NullPointerException if {@code toKey} is null 0N/A * and this map does not permit null keys 0N/A * @throws IllegalArgumentException if this map itself has a 0N/A * restricted range, and {@code toKey} lies outside the 0N/A * bounds of the range 0N/A * Returns a view of the portion of this map whose keys are greater than (or 0N/A * equal to, if {@code inclusive} is true) {@code fromKey}. The returned 0N/A * map is backed by this map, so changes in the returned map are reflected 0N/A * in this map, and vice-versa. The returned map supports all optional 0N/A * map operations that this map supports. 0N/A * <p>The returned map will throw an {@code IllegalArgumentException} 0N/A * on an attempt to insert a key outside its range. 0N/A * @param fromKey low endpoint of the keys in the returned map 0N/A * @param inclusive {@code true} if the low endpoint 0N/A * is to be included in the returned view 0N/A * @return a view of the portion of this map whose keys are greater than 0N/A * (or equal to, if {@code inclusive} is true) {@code fromKey} 0N/A * @throws ClassCastException if {@code fromKey} is not compatible 0N/A * with this map's comparator (or, if the map has no comparator, 0N/A * if {@code fromKey} does not implement {@link Comparable}). 0N/A * Implementations may, but are not required to, throw this 0N/A * exception if {@code fromKey} cannot be compared to keys 0N/A * currently in the map. 0N/A * @throws NullPointerException if {@code fromKey} is null 0N/A * and this map does not permit null keys 0N/A * @throws IllegalArgumentException if this map itself has a 0N/A * restricted range, and {@code fromKey} lies outside the 0N/A * bounds of the range 0N/A * <p>Equivalent to {@code subMap(fromKey, true, toKey, false)}. 0N/A * @throws ClassCastException {@inheritDoc} 0N/A * @throws NullPointerException {@inheritDoc} 0N/A * @throws IllegalArgumentException {@inheritDoc} 0N/A * <p>Equivalent to {@code headMap(toKey, false)}. 0N/A * @throws ClassCastException {@inheritDoc} 0N/A * @throws NullPointerException {@inheritDoc} 0N/A * @throws IllegalArgumentException {@inheritDoc} 0N/A * <p>Equivalent to {@code tailMap(fromKey, true)}. 0N/A * @throws ClassCastException {@inheritDoc} 0N/A * @throws NullPointerException {@inheritDoc} 0N/A * @throws IllegalArgumentException {@inheritDoc}