⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sortedmap.html

📁 API資料大全
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Thu Apr 27 23:36:45 PDT 2000 --><TITLE>Java 2 Platform SE v1.3: Interface  SortedMap</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style"></HEAD><BODY BGCOLOR="white"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">  <TR ALIGN="center" VALIGN="top">  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/SortedMap.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>  </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup>&nbsp;2&nbsp;Platform<br>Std.&nbsp;Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;<A HREF="../../java/util/Set.html"><B>PREV CLASS</B></A>&nbsp;&nbsp;<A HREF="../../java/util/SortedSet.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">  <A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A>  &nbsp;&nbsp;<A HREF="SortedMap.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">  SUMMARY: &nbsp;INNER&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: &nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">java.util</FONT><BR>Interface  SortedMap</H2><DL><DT><B>All Superinterfaces:</B> <DD><A HREF="../../java/util/Map.html">Map</A></DD></DL><DL><DT><B>All Known Implementing Classes:</B> <DD><A HREF="../../java/util/TreeMap.html">TreeMap</A></DD></DL><HR><DL><DT>public interface <B>SortedMap</B><DT>extends <A HREF="../../java/util/Map.html">Map</A></DL><P>A map that further guarantees that it will be in ascending key order, sorted according to the <i>natural ordering</i> of its keys (see the <tt>Comparable</tt> interface), or by a comparator provided at sorted map creation time.  This order is reflected when iterating over the sorted map's collection views (returned by the <tt>entrySet</tt>, <tt>keySet</tt> and <tt>values</tt> methods).  Several additional operations are provided to take advantage of the ordering.  (This interface is the map analogue of the <tt>SortedSet</tt> interface.)<p> All keys inserted into a sorted map must implement the <tt>Comparable</tt> interface (or be accepted by the specified comparator).  Furthermore, all such keys must be <i>mutually comparable</i>: <tt>k1.compareTo(k2)</tt> (or <tt>comparator.compare(k1, k2)</tt>) must not throw a <tt>ClassCastException</tt> for any elements <tt>k1</tt> and <tt>k2</tt> in the sorted map.  Attempts to violate this restriction will cause the offending method or constructor invocation to throw a <tt>ClassCastException</tt>.<p> Note that the ordering maintained by a sorted map (whether or not an explicit comparator is provided) must be <i>consistent with equals</i> if the sorted map is to correctly implement the <tt>Map</tt> interface.  (See the <tt>Comparable</tt> interface or <tt>Comparator</tt> interface for a precise definition of <i>consistent with equals</i>.)  This is so because the <tt>Map</tt> interface is defined in terms of the <tt>equals</tt> operation, but a sorted map performs all key comparisons using its <tt>compareTo</tt> (or <tt>compare</tt>) method, so two keys that are deemed equal by this method are, from the standpoint of the sorted map, equal.  The behavior of a tree map <i>is</i> well-defined even if its ordering is inconsistent with equals; it just fails to obey the general contract of the <tt>Map</tt> interface.<p> All general-purpose sorted map implementation classes should provide four "standard" constructors: 1) A void (no arguments) constructor, which creates an empty sorted map sorted according to the <i>natural order</i> of its keys.  2) A constructor with a single argument of type <tt>Comparator</tt>, which creates an empty sorted map sorted according to the specified comparator.  3) A constructor with a single argument of type <tt>Map</tt>, which creates a new map with the same key-value mappings as its argument, sorted according to the keys' natural ordering.  4) A constructor with a single argument of type sorted map, which creates a new sorted map with the same key-value mappings and the same ordering as the input sorted map.  There is no way to enforce this recommendation (as interfaces cannot contain constructors) but the SDK implementation (TreeMap) complies.<P><DL><DT><B>Since: </B><DD>1.2</DD><DT><B>See Also: </B><DD><A HREF="../../java/util/Map.html"><CODE>Map</CODE></A>, <A HREF="../../java/util/TreeMap.html"><CODE>TreeMap</CODE></A>, <A HREF="../../java/util/SortedSet.html"><CODE>SortedSet</CODE></A>, <A HREF="../../java/util/Comparator.html"><CODE>Comparator</CODE></A>, <A HREF="../../java/lang/Comparable.html"><CODE>Comparable</CODE></A>, <A HREF="../../java/util/Collection.html"><CODE>Collection</CODE></A>, <A HREF="../../java/lang/ClassCastException.html"><CODE>ClassCastException</CODE></A></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><A NAME="inner_classes_inherited_from_class_java.util.Map"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Inner classes inherited from class java.util.<A HREF="../../java/util/Map.html">Map</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../java/util/Map.Entry.html">Map.Entry</A></CODE></TD></TR></TABLE>&nbsp;<!-- =========== FIELD SUMMARY =========== --><!-- ======== CONSTRUCTOR SUMMARY ======== --><!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../../java/util/Comparator.html">Comparator</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/SortedMap.html#comparator()">comparator</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the comparator associated with this sorted map, or <tt>null</tt> if it uses its keys' natural ordering.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../../java/lang/Object.html">Object</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/SortedMap.html#firstKey()">firstKey</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the first (lowest) key currently in this sorted map.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../../java/util/SortedMap.html">SortedMap</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/SortedMap.html#headMap(java.lang.Object)">headMap</A></B>(<A HREF="../../java/lang/Object.html">Object</A>&nbsp;toKey)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a view of the portion of this sorted map whose keys are strictly less than toKey.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../../java/lang/Object.html">Object</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/SortedMap.html#lastKey()">lastKey</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the last (highest) key currently in this sorted map.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../../java/util/SortedMap.html">SortedMap</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/SortedMap.html#subMap(java.lang.Object, java.lang.Object)">subMap</A></B>(<A HREF="../../java/lang/Object.html">Object</A>&nbsp;fromKey,       <A HREF="../../java/lang/Object.html">Object</A>&nbsp;toKey)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a view of the portion of this sorted map whose keys range from <tt>fromKey</tt>, inclusive, to <tt>toKey</tt>, exclusive.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../../java/util/SortedMap.html">SortedMap</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/SortedMap.html#tailMap(java.lang.Object)">tailMap</A></B>(<A HREF="../../java/lang/Object.html">Object</A>&nbsp;fromKey)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a view of the portion of this sorted map whose keys are greater than or equal to <tt>fromKey</tt>.</TD></TR></TABLE>&nbsp;<A NAME="methods_inherited_from_class_java.util.Map"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Methods inherited from interface java.util.<A HREF="../../java/util/Map.html">Map</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../java/util/Map.html#clear()">clear</A>, <A HREF="../../java/util/Map.html#containsKey(java.lang.Object)">containsKey</A>, <A HREF="../../java/util/Map.html#containsValue(java.lang.Object)">containsValue</A>, <A HREF="../../java/util/Map.html#entrySet()">entrySet</A>, <A HREF="../../java/util/Map.html#equals(java.lang.Object)">equals</A>, <A HREF="../../java/util/Map.html#get(java.lang.Object)">get</A>, <A HREF="../../java/util/Map.html#hashCode()">hashCode</A>, <A HREF="../../java/util/Map.html#isEmpty()">isEmpty</A>, <A HREF="../../java/util/Map.html#keySet()">keySet</A>, <A HREF="../../java/util/Map.html#put(java.lang.Object, java.lang.Object)">put</A>, <A HREF="../../java/util/Map.html#putAll(java.util.Map)">putAll</A>, <A HREF="../../java/util/Map.html#remove(java.lang.Object)">remove</A>, <A HREF="../../java/util/Map.html#size()">size</A>, <A HREF="../../java/util/Map.html#values()">values</A></CODE></TD></TR></TABLE>&nbsp;<P><!-- ============ FIELD DETAIL =========== --><!-- ========= CONSTRUCTOR DETAIL ======== --><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -