jdk/src/java.base/share/classes/java/util/SortedMap.java
author mchung
Fri, 22 May 2015 16:43:39 -0700
changeset 30789 9eca83469588
parent 25859 3317bb8137f4
child 44743 f0bbd698c486
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
/*
14342
8435a30053c1 7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents: 8995
diff changeset
     2
 * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.util;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/**
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    29
 * A {@link Map} that further provides a <em>total ordering</em> on its keys.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * The map is ordered according to the {@linkplain Comparable natural
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * ordering} of its keys, or by a {@link Comparator} typically
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * provided at sorted map creation time.  This order is reflected when
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * iterating over the sorted map's collection views (returned by the
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    34
 * {@code entrySet}, {@code keySet} and {@code values} methods).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * Several additional operations are provided to take advantage of the
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    36
 * ordering.  (This interface is the map analogue of {@link SortedSet}.)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    38
 * <p>All keys inserted into a sorted map must implement the {@code Comparable}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * interface (or be accepted by the specified comparator).  Furthermore, all
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    40
 * such keys must be <em>mutually comparable</em>: {@code k1.compareTo(k2)} (or
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    41
 * {@code comparator.compare(k1, k2)}) must not throw a
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    42
 * {@code ClassCastException} for any keys {@code k1} and {@code k2} in
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * the sorted map.  Attempts to violate this restriction will cause the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * offending method or constructor invocation to throw a
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    45
 * {@code ClassCastException}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * <p>Note that the ordering maintained by a sorted map (whether or not an
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    48
 * explicit comparator is provided) must be <em>consistent with equals</em> if
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    49
 * the sorted map is to correctly implement the {@code Map} interface.  (See
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    50
 * the {@code Comparable} interface or {@code Comparator} interface for a
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    51
 * precise definition of <em>consistent with equals</em>.)  This is so because
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    52
 * the {@code Map} interface is defined in terms of the {@code equals}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * operation, but a sorted map performs all key comparisons using its
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    54
 * {@code compareTo} (or {@code compare}) method, so two keys that are
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * deemed equal by this method are, from the standpoint of the sorted map,
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    56
 * equal.  The behavior of a tree map <em>is</em> well-defined even if its
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * ordering is inconsistent with equals; it just fails to obey the general
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    58
 * contract of the {@code Map} interface.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    60
 * <p>All general-purpose sorted map implementation classes should provide four
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    61
 * "standard" constructors. It is not possible to enforce this recommendation
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    62
 * though as required constructors cannot be specified by interfaces. The
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    63
 * expected "standard" constructors for all sorted map implementations are:
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    64
 * <ol>
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    65
 *   <li>A void (no arguments) constructor, which creates an empty sorted map
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    66
 *   sorted according to the natural ordering of its keys.</li>
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    67
 *   <li>A constructor with a single argument of type {@code Comparator}, which
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    68
 *   creates an empty sorted map sorted according to the specified comparator.</li>
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    69
 *   <li>A constructor with a single argument of type {@code Map}, which creates
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    70
 *   a new map with the same key-value mappings as its argument, sorted
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    71
 *   according to the keys' natural ordering.</li>
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    72
 *   <li>A constructor with a single argument of type {@code SortedMap}, which
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    73
 *   creates a new sorted map with the same key-value mappings and the same
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    74
 *   ordering as the input sorted map.</li>
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    75
 * </ol>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 *
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    77
 * <p><strong>Note</strong>: several methods return submaps with restricted key
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    78
 * ranges. Such ranges are <em>half-open</em>, that is, they include their low
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * endpoint but not their high endpoint (where applicable).  If you need a
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    80
 * <em>closed range</em> (which includes both endpoints), and the key type
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * allows for calculation of the successor of a given key, merely request
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    82
 * the subrange from {@code lowEndpoint} to
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    83
 * {@code successor(highEndpoint)}.  For example, suppose that {@code m}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * is a map whose keys are strings.  The following idiom obtains a view
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    85
 * containing all of the key-value mappings in {@code m} whose keys are
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    86
 * between {@code low} and {@code high}, inclusive:<pre>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 *   SortedMap&lt;String, V&gt; sub = m.subMap(low, high+"\0");</pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 *
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    89
 * A similar technique can be used to generate an <em>open range</em>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * (which contains neither endpoint).  The following idiom obtains a
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    91
 * view containing all of the key-value mappings in {@code m} whose keys
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
    92
 * are between {@code low} and {@code high}, exclusive:<pre>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 *   SortedMap&lt;String, V&gt; sub = m.subMap(low+"\0", high);</pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * <p>This interface is a member of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * <a href="{@docRoot}/../technotes/guides/collections/index.html">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * Java Collections Framework</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * @param <K> the type of keys maintained by this map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 * @param <V> the type of mapped values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 * @author  Josh Bloch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 * @see Map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 * @see TreeMap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 * @see SortedSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 * @see Comparator
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 * @see Comparable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * @see Collection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 * @see ClassCastException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
public interface SortedMap<K,V> extends Map<K,V> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * Returns the comparator used to order the keys in this map, or
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   116
     * {@code null} if this map uses the {@linkplain Comparable
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * natural ordering} of its keys.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * @return the comparator used to order the keys in this map,
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   120
     *         or {@code null} if this map uses the natural ordering
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     *         of its keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    Comparator<? super K> comparator();
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 view of the portion of this map whose keys range from
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   127
     * {@code fromKey}, inclusive, to {@code toKey}, exclusive.  (If
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   128
     * {@code fromKey} and {@code toKey} are equal, the returned map
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * is empty.)  The returned map is backed by this map, so changes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * in the returned map are reflected in this map, and vice-versa.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * The returned map supports all optional map operations that this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * map supports.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     *
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   134
     * <p>The returned map will throw an {@code IllegalArgumentException}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * on an attempt to insert a key outside its range.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * @param fromKey low endpoint (inclusive) of the keys in the returned map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * @param toKey high endpoint (exclusive) of the keys in the returned map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * @return a view of the portion of this map whose keys range from
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   140
     *         {@code fromKey}, inclusive, to {@code toKey}, exclusive
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   141
     * @throws ClassCastException if {@code fromKey} and {@code toKey}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     *         cannot be compared to one another using this map's comparator
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     *         (or, if the map has no comparator, using natural ordering).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     *         Implementations may, but are not required to, throw this
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   145
     *         exception if {@code fromKey} or {@code toKey}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     *         cannot be compared to keys currently in the map.
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   147
     * @throws NullPointerException if {@code fromKey} or {@code toKey}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     *         is null and this map does not permit null keys
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   149
     * @throws IllegalArgumentException if {@code fromKey} is greater than
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   150
     *         {@code toKey}; or if this map itself has a restricted
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   151
     *         range, and {@code fromKey} or {@code toKey} lies
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     *         outside the bounds of the range
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    SortedMap<K,V> subMap(K fromKey, K toKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * Returns a view of the portion of this map whose keys are
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   158
     * strictly less than {@code toKey}.  The returned map is backed
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * by this map, so changes in the returned map are reflected in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * this map, and vice-versa.  The returned map supports all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * optional map operations that this map supports.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     *
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   163
     * <p>The returned map will throw an {@code IllegalArgumentException}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * on an attempt to insert a key outside its range.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * @param toKey high endpoint (exclusive) of the keys in the returned map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * @return a view of the portion of this map whose keys are strictly
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   168
     *         less than {@code toKey}
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   169
     * @throws ClassCastException if {@code toKey} is not compatible
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     *         with this map's comparator (or, if the map has no comparator,
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   171
     *         if {@code toKey} does not implement {@link Comparable}).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     *         Implementations may, but are not required to, throw this
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   173
     *         exception if {@code toKey} cannot be compared to keys
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     *         currently in the map.
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   175
     * @throws NullPointerException if {@code toKey} is null and
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     *         this map does not permit null keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * @throws IllegalArgumentException if this map itself has a
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   178
     *         restricted range, and {@code toKey} lies outside the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     *         bounds of the range
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    SortedMap<K,V> headMap(K toKey);
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 view of the portion of this map whose keys are
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   185
     * greater than or equal to {@code fromKey}.  The returned map is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * backed by this map, so changes in the returned map are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * reflected in this map, and vice-versa.  The returned map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * supports all optional map operations that this map supports.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     *
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   190
     * <p>The returned map will throw an {@code IllegalArgumentException}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * on an attempt to insert a key outside its range.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * @param fromKey low endpoint (inclusive) of the keys in the returned map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * @return a view of the portion of this map whose keys are greater
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   195
     *         than or equal to {@code fromKey}
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   196
     * @throws ClassCastException if {@code fromKey} is not compatible
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     *         with this map's comparator (or, if the map has no comparator,
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   198
     *         if {@code fromKey} does not implement {@link Comparable}).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     *         Implementations may, but are not required to, throw this
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   200
     *         exception if {@code fromKey} cannot be compared to keys
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     *         currently in the map.
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   202
     * @throws NullPointerException if {@code fromKey} is null and
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     *         this map does not permit null keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * @throws IllegalArgumentException if this map itself has a
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   205
     *         restricted range, and {@code fromKey} lies outside the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     *         bounds of the range
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    SortedMap<K,V> tailMap(K fromKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * Returns the first (lowest) key currently in this map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * @return the first (lowest) key currently in this map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * @throws NoSuchElementException if this map is empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    K firstKey();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * Returns the last (highest) key currently in this map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * @return the last (highest) key currently in this map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * @throws NoSuchElementException if this map is empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    K lastKey();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * Returns a {@link Set} view of the keys contained in this map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * The set's iterator returns the keys in ascending order.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * The set is backed by the map, so changes to the map are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * reflected in the set, and vice-versa.  If the map is modified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * while an iteration over the set is in progress (except through
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   232
     * the iterator's own {@code remove} operation), the results of
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * the iteration are undefined.  The set supports element removal,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * which removes the corresponding mapping from the map, via the
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   235
     * {@code Iterator.remove}, {@code Set.remove},
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   236
     * {@code removeAll}, {@code retainAll}, and {@code clear}
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   237
     * operations.  It does not support the {@code add} or {@code addAll}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * @return a set view of the keys contained in this map, sorted in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     *         ascending order
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    Set<K> keySet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * Returns a {@link Collection} view of the values contained in this map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * The collection's iterator returns the values in ascending order
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * of the corresponding keys.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * The collection is backed by the map, so changes to the map are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * reflected in the collection, and vice-versa.  If the map is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * modified while an iteration over the collection is in progress
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   252
     * (except through the iterator's own {@code remove} operation),
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * the results of the iteration are undefined.  The collection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * supports element removal, which removes the corresponding
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   255
     * mapping from the map, via the {@code Iterator.remove},
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   256
     * {@code Collection.remove}, {@code removeAll},
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   257
     * {@code retainAll} and {@code clear} operations.  It does not
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   258
     * support the {@code add} or {@code addAll} operations.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * @return a collection view of the values contained in this map,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     *         sorted in ascending key order
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    Collection<V> values();
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 Set} view of the mappings contained in this map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * The set's iterator returns the entries in ascending key order.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * The set is backed by the map, so changes to the map are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * reflected in the set, and vice-versa.  If the map is modified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * while an iteration over the set is in progress (except through
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   271
     * the iterator's own {@code remove} operation, or through the
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   272
     * {@code setValue} operation on a map entry returned by the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * iterator) the results of the iteration are undefined.  The set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * supports element removal, which removes the corresponding
8995
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   275
     * mapping from the map, via the {@code Iterator.remove},
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   276
     * {@code Set.remove}, {@code removeAll}, {@code retainAll} and
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   277
     * {@code clear} operations.  It does not support the
dc0fc82e2d88 7029997: Restyling of SortedMap Javadoc
mduigou
parents: 5506
diff changeset
   278
     * {@code add} or {@code addAll} operations.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * @return a set view of the mappings contained in this map,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     *         sorted in ascending key order
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    Set<Map.Entry<K, V>> entrySet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
}