< prev index next >

src/java.base/share/classes/java/util/SortedMap.java

Print this page




  76  *
  77  * <p><strong>Note</strong>: several methods return submaps with restricted key
  78  * ranges. Such ranges are <em>half-open</em>, that is, they include their low
  79  * endpoint but not their high endpoint (where applicable).  If you need a
  80  * <em>closed range</em> (which includes both endpoints), and the key type
  81  * allows for calculation of the successor of a given key, merely request
  82  * the subrange from {@code lowEndpoint} to
  83  * {@code successor(highEndpoint)}.  For example, suppose that {@code m}
  84  * is a map whose keys are strings.  The following idiom obtains a view
  85  * containing all of the key-value mappings in {@code m} whose keys are
  86  * between {@code low} and {@code high}, inclusive:<pre>
  87  *   SortedMap&lt;String, V&gt; sub = m.subMap(low, high+"\0");</pre>
  88  *
  89  * A similar technique can be used to generate an <em>open range</em>
  90  * (which contains neither endpoint).  The following idiom obtains a
  91  * view containing all of the key-value mappings in {@code m} whose keys
  92  * are between {@code low} and {@code high}, exclusive:<pre>
  93  *   SortedMap&lt;String, V&gt; sub = m.subMap(low+"\0", high);</pre>
  94  *
  95  * <p>This interface is a member of the
  96  * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  97  * Java Collections Framework</a>.
  98  *
  99  * @param <K> the type of keys maintained by this map
 100  * @param <V> the type of mapped values
 101  *
 102  * @author  Josh Bloch
 103  * @see Map
 104  * @see TreeMap
 105  * @see SortedSet
 106  * @see Comparator
 107  * @see Comparable
 108  * @see Collection
 109  * @see ClassCastException
 110  * @since 1.2
 111  */
 112 
 113 public interface SortedMap<K,V> extends Map<K,V> {
 114     /**
 115      * Returns the comparator used to order the keys in this map, or
 116      * {@code null} if this map uses the {@linkplain Comparable




  76  *
  77  * <p><strong>Note</strong>: several methods return submaps with restricted key
  78  * ranges. Such ranges are <em>half-open</em>, that is, they include their low
  79  * endpoint but not their high endpoint (where applicable).  If you need a
  80  * <em>closed range</em> (which includes both endpoints), and the key type
  81  * allows for calculation of the successor of a given key, merely request
  82  * the subrange from {@code lowEndpoint} to
  83  * {@code successor(highEndpoint)}.  For example, suppose that {@code m}
  84  * is a map whose keys are strings.  The following idiom obtains a view
  85  * containing all of the key-value mappings in {@code m} whose keys are
  86  * between {@code low} and {@code high}, inclusive:<pre>
  87  *   SortedMap&lt;String, V&gt; sub = m.subMap(low, high+"\0");</pre>
  88  *
  89  * A similar technique can be used to generate an <em>open range</em>
  90  * (which contains neither endpoint).  The following idiom obtains a
  91  * view containing all of the key-value mappings in {@code m} whose keys
  92  * are between {@code low} and {@code high}, exclusive:<pre>
  93  *   SortedMap&lt;String, V&gt; sub = m.subMap(low+"\0", high);</pre>
  94  *
  95  * <p>This interface is a member of the
  96  * <a href="{@docRoot}/java.base/java/util/package-summary.html#CollectionsFramework">
  97  * Java Collections Framework</a>.
  98  *
  99  * @param <K> the type of keys maintained by this map
 100  * @param <V> the type of mapped values
 101  *
 102  * @author  Josh Bloch
 103  * @see Map
 104  * @see TreeMap
 105  * @see SortedSet
 106  * @see Comparator
 107  * @see Comparable
 108  * @see Collection
 109  * @see ClassCastException
 110  * @since 1.2
 111  */
 112 
 113 public interface SortedMap<K,V> extends Map<K,V> {
 114     /**
 115      * Returns the comparator used to order the keys in this map, or
 116      * {@code null} if this map uses the {@linkplain Comparable


< prev index next >