comparator.html

来自「j2se5-api-zh,java文档的中文版本」· HTML 代码 · 共 479 行 · 第 1/2 页

HTML
479
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc (build 1.5.0_03) on Wed Nov 02 09:53:03 CST 2005 --><META http-equiv="Content-Type" content="text/html; charset=gb2312"><TITLE>接口 java.util.Comparator 的使用 (Java 2 Platform SE 5.0)</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style"><SCRIPT type="text/javascript">function windowTitle(){    parent.document.title="接口 java.util.Comparator 的使用 (Java 2 Platform SE 5.0)";}</SCRIPT><NOSCRIPT></NOSCRIPT></HEAD><BODY BGCOLOR="white" onload="windowTitle();"><!-- ========= START OF TOP NAVBAR ======= --><A NAME="navbar_top"><!-- --></A><A HREF="#skip-navbar_top" title="跳过导航链接"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">  <TR ALIGN="center" VALIGN="top">  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>概述</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../package-summary.html"><FONT CLASS="NavBarFont1"><B>软件包</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../Comparator.html" title="java.util 中的接口"><FONT CLASS="NavBarFont1"><B>类</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>使用</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../package-tree.html"><FONT CLASS="NavBarFont1"><B>树</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>已过时</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>索引</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>帮助</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>Standard&nbsp;Ed. 5.0</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;上一个&nbsp;&nbsp;下一个</FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">  <A HREF="../../../index.html@java_2Futil_2F_2Fclass-useComparator.html" target="_top"><B>框架</B></A>  &nbsp;&nbsp;<A HREF="Comparator.html" target="_top"><B>无框架</B></A>  &nbsp;&nbsp;<SCRIPT type="text/javascript">  <!--  if(window==top) {    document.writeln('<A HREF="../../../allclasses-noframe.html"><B>所有类</B></A>');  }  //--></SCRIPT><NOSCRIPT>  <A HREF="../../../allclasses-noframe.html"><B>所有类</B></A></NOSCRIPT></FONT></TD></TR></TABLE><A NAME="skip-navbar_top"></A><!-- ========= END OF TOP NAVBAR ========= --><HR><CENTER><H2><B>接口 java.util.Comparator<br>的使用</B></H2></CENTER><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">使用 <A HREF="../Comparator.html" title="java.util 中的接口">Comparator</A> 的软件包</FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><A HREF="#java.lang"><B>java.lang</B></A></TD><TD>提供利用 Java 编程语言进行程序设计的基础类。&nbsp;</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><A HREF="#java.util"><B>java.util</B></A></TD><TD>包含集合框架、遗留的 collection 类、事件模型、日期和时间设施、国际化和各种实用工具类(字符串标记生成器、随机数生成器和位数组)。&nbsp;</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><A HREF="#java.util.concurrent"><B>java.util.concurrent</B></A></TD><TD> 在并发编程中很常用的实用工具类。&nbsp;</TD></TR></TABLE>&nbsp;<P><A NAME="java.lang"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"><A HREF="../../lang/package-summary.html">java.lang</A> 中 <A HREF="../Comparator.html" title="java.util 中的接口">Comparator</A> 的使用</FONT></TH></TR></TABLE>&nbsp;<P><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableSubHeadingColor"><TH ALIGN="left" COLSPAN="2">声明为 <A HREF="../Comparator.html" title="java.util 中的接口">Comparator</A> 的 <A HREF="../../lang/package-summary.html">java.lang</A> 中的字段</FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;<A HREF="../Comparator.html" title="java.util 中的接口">Comparator</A>&lt;<A HREF="../../lang/String.html" title="java.lang 中的类">String</A>&gt;</CODE></FONT></TD><TD><CODE><B>String.</B><B><A HREF="../../lang/String.html#CASE_INSENSITIVE_ORDER">CASE_INSENSITIVE_ORDER</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;一个排序 <code>String</code> 对象的 Comparator,它的作用与 <code>compareToIgnoreCase</code> 相同。</TD></TR></TABLE>&nbsp;<P><A NAME="java.util"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"><A HREF="../package-summary.html">java.util</A> 中 <A HREF="../Comparator.html" title="java.util 中的接口">Comparator</A> 的使用</FONT></TH></TR></TABLE>&nbsp;<P><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableSubHeadingColor"><TH ALIGN="left" COLSPAN="2">返回 <A HREF="../Comparator.html" title="java.util 中的接口">Comparator</A> 的 <A HREF="../package-summary.html">java.util</A> 中的方法</FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../Comparator.html" title="java.util 中的接口">Comparator</A>&lt;? super <A HREF="../SortedSet.html" title="SortedSet 中的类型参数">E</A>&gt;</CODE></FONT></TD><TD><CODE><B>SortedSet.</B><B><A HREF="../SortedSet.html#comparator()">comparator</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回与此有序集合关联的比较器,如果使用元素的自然顺序,则返回 <tt>null</tt>。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../Comparator.html" title="java.util 中的接口">Comparator</A>&lt;? super <A HREF="../TreeSet.html" title="TreeSet 中的类型参数">E</A>&gt;</CODE></FONT></TD><TD><CODE><B>TreeSet.</B><B><A HREF="../TreeSet.html#comparator()">comparator</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回用于确定已排序 set 顺序的比较器,或者,如果此树 set 使用其元素的自然顺序,则返回 <tt>null</tt>。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../Comparator.html" title="java.util 中的接口">Comparator</A>&lt;? super <A HREF="../SortedMap.html" title="SortedMap 中的类型参数">K</A>&gt;</CODE></FONT></TD><TD><CODE><B>SortedMap.</B><B><A HREF="../SortedMap.html#comparator()">comparator</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回与此有序映射关联的比较器,如果使用键的自然顺序,则返回 <tt>null</tt>。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../Comparator.html" title="java.util 中的接口">Comparator</A>&lt;? super <A HREF="../TreeMap.html" title="TreeMap 中的类型参数">K</A>&gt;</CODE></FONT></TD><TD><CODE><B>TreeMap.</B><B><A HREF="../TreeMap.html#comparator()">comparator</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回用于对此映射进行排序的比较器,或者如果此映射使用它的键的自然顺序,则返回 <tt>null</tt>。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../Comparator.html" title="java.util 中的接口">Comparator</A>&lt;? super <A HREF="../PriorityQueue.html" title="PriorityQueue 中的类型参数">E</A>&gt;</CODE></FONT></TD><TD><CODE><B>PriorityQueue.</B><B><A HREF="../PriorityQueue.html#comparator()">comparator</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回用于排序集合的比较器,或者如果此集合根据其元素的自然顺序排序(使用 <tt>Comparable</tt>),则返回 <tt>null</tt>。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""><TR ALIGN="right" VALIGN=""><TD NOWRAP><FONT SIZE="-1"><CODE>&lt;T&gt; <A HREF="../Comparator.html" title="java.util 中的接口">Comparator</A>&lt;T&gt;</CODE></FONT></TD></TR></TABLE></CODE></FONT></TD><TD><CODE><B>Collections.</B><B><A HREF="../Collections.html#reverseOrder()">reverseOrder</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回一个比较器,它强行反转实现 <tt>Comparable</tt> 接口那些对象 collection 上的<i>自然顺序</i>。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""><TR ALIGN="right" VALIGN=""><TD NOWRAP><FONT SIZE="-1"><CODE>&lt;T&gt; <A HREF="../Comparator.html" title="java.util 中的接口">Comparator</A>&lt;T&gt;</CODE></FONT></TD></TR></TABLE></CODE></FONT></TD><TD><CODE><B>Collections.</B><B><A HREF="../Collections.html#reverseOrder(java.util.Comparator)">reverseOrder</A></B>(<A HREF="../Comparator.html" title="java.util 中的接口">Comparator</A>&lt;T&gt;&nbsp;cmp)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回一个比较器,它强行反转指定比较器的顺序。</TD></TR></TABLE>&nbsp;<P><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableSubHeadingColor"><TH ALIGN="left" COLSPAN="2">参数类型为 <A HREF="../Comparator.html" title="java.util 中的接口">Comparator</A> 的 <A HREF="../package-summary.html">java.util</A> 中的方法</FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""><TR ALIGN="right" VALIGN=""><TD NOWRAP><FONT SIZE="-1"><CODE>&lt;T&gt; int</CODE></FONT></TD></TR></TABLE></CODE></FONT></TD><TD><CODE><B>Collections.</B><B><A HREF="../Collections.html#binarySearch(java.util.List, T, java.util.Comparator)">binarySearch</A></B>(<A HREF="../List.html" title="java.util 中的接口">List</A>&lt;? extends T&gt;&nbsp;list,             T&nbsp;key,             <A HREF="../Comparator.html" title="java.util 中的接口">Comparator</A>&lt;? super T&gt;&nbsp;c)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;使用二进制搜索算法来搜索指定列表,以获得指定对象。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static

⌨️ 快捷键说明

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