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

📄 arrays.html

📁 API資料大全
💻 HTML
📖 第 1 页 / 共 5 页
字号:
</DL><HR><A NAME="sort(java.lang.Object[], java.util.Comparator)"><!-- --></A><H3>sort</H3><PRE>public static void <B>sort</B>(<A HREF="../../java/lang/Object.html">Object</A>[]&nbsp;a,                        <A HREF="../../java/util/Comparator.html">Comparator</A>&nbsp;c)</PRE><DL><DD>Sorts the specified array of objects according to the order induced by the specified comparator.  All elements in the array must be <i>mutually comparable</i> by the specified comparator (that is, <tt>c.compare(e1, e2)</tt> must not throw a <tt>ClassCastException</tt> for any elements <tt>e1</tt> and <tt>e2</tt> in the array).<p> This sort is guaranteed to be <i>stable</i>:  equal elements will not be reordered as a result of the sort.<p> The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist).  This algorithm offers guaranteed n*log(n) performance, and can approach linear performance on nearly sorted lists.<DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - the array to be sorted.<DD><CODE>c</CODE> - the comparator to determine the order of the array.  A        <tt>null</tt> value indicates that the elements' <i>natural        ordering</i> should be used.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ClassCastException.html">ClassCastException</A></CODE> - if the array contains elements that are		not <i>mutually comparable</i> using the specified comparator.<DT><B>See Also: </B><DD><A HREF="../../java/util/Comparator.html"><CODE>Comparator</CODE></A></DL></DD></DL><HR><A NAME="sort(java.lang.Object[], int, int, java.util.Comparator)"><!-- --></A><H3>sort</H3><PRE>public static void <B>sort</B>(<A HREF="../../java/lang/Object.html">Object</A>[]&nbsp;a,                        int&nbsp;fromIndex,                        int&nbsp;toIndex,                        <A HREF="../../java/util/Comparator.html">Comparator</A>&nbsp;c)</PRE><DL><DD>Sorts the specified range of the specified array of objects according to the order induced by the specified comparator.  The range to be sorted extends from index <tt>fromIndex</tt>, inclusive, to index <tt>toIndex</tt>, exclusive.  (If <tt>fromIndex==toIndex</tt>, the range to be sorted is empty.)  All elements in the range must be <i>mutually comparable</i> by the specified comparator (that is, <tt>c.compare(e1, e2)</tt> must not throw a <tt>ClassCastException</tt> for any elements <tt>e1</tt> and <tt>e2</tt> in the range).<p> This sort is guaranteed to be <i>stable</i>:  equal elements will not be reordered as a result of the sort.<p> The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist).  This algorithm offers guaranteed n*log(n) performance, and can approach linear performance on nearly sorted lists.<DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - the array to be sorted.<DD><CODE>fromIndex</CODE> - the index of the first element (inclusive) to be        sorted.<DD><CODE>toIndex</CODE> - the index of the last element (exclusive) to be sorted.<DD><CODE>c</CODE> - the comparator to determine the order of the array.  A        <tt>null</tt> value indicates that the elements' <i>natural        ordering</i> should be used.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ClassCastException.html">ClassCastException</A></CODE> - if the array contains elements that are not	       <i>mutually comparable</i> using the specified comparator.<DD><CODE><A HREF="../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if <tt>fromIndex &gt; toIndex</tt><DD><CODE><A HREF="../../java/lang/ArrayIndexOutOfBoundsException.html">ArrayIndexOutOfBoundsException</A></CODE> - if <tt>fromIndex &lt; 0</tt> or	       <tt>toIndex &gt; a.length</tt><DT><B>See Also: </B><DD><A HREF="../../java/util/Comparator.html"><CODE>Comparator</CODE></A></DL></DD></DL><HR><A NAME="binarySearch(long[], long)"><!-- --></A><H3>binarySearch</H3><PRE>public static int <B>binarySearch</B>(long[]&nbsp;a,                               long&nbsp;key)</PRE><DL><DD>Searches the specified array of longs for the specified value using the binary search algorithm.  The array <strong>must</strong> be sorted (as by the <tt>sort</tt> method, above) prior to making this call.  If it is not sorted, the results are undefined.  If the array contains multiple elements with the specified value, there is no guarantee which one will be found.<DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - the array to be searched.<DD><CODE>key</CODE> - the value to be searched for.<DT><B>Returns:</B><DD>index of the search key, if it is contained in the list;	       otherwise, <tt>(-(<i>insertion point</i>) - 1)</tt>.  The	       <i>insertion point</i> is defined as the point at which the	       key would be inserted into the list: the index of the first	       element greater than the key, or <tt>list.size()</tt>, if all	       elements in the list are less than the specified key.  Note	       that this guarantees that the return value will be &gt;= 0 if	       and only if the key is found.<DT><B>See Also: </B><DD><A HREF="../../java/util/Arrays.html#sort(long[])"><CODE>sort(long[])</CODE></A></DL></DD></DL><HR><A NAME="binarySearch(int[], int)"><!-- --></A><H3>binarySearch</H3><PRE>public static int <B>binarySearch</B>(int[]&nbsp;a,                               int&nbsp;key)</PRE><DL><DD>Searches the specified array of ints for the specified value using the binary search algorithm.  The array <strong>must</strong> be sorted (as by the <tt>sort</tt> method, above) prior to making this call.  If it is not sorted, the results are undefined.  If the array contains multiple elements with the specified value, there is no guarantee which one will be found.<DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - the array to be searched.<DD><CODE>key</CODE> - the value to be searched for.<DT><B>Returns:</B><DD>index of the search key, if it is contained in the list;	       otherwise, <tt>(-(<i>insertion point</i>) - 1)</tt>.  The	       <i>insertion point</i> is defined as the point at which the	       key would be inserted into the list: the index of the first	       element greater than the key, or <tt>list.size()</tt>, if all	       elements in the list are less than the specified key.  Note	       that this guarantees that the return value will be &gt;= 0 if	       and only if the key is found.<DT><B>See Also: </B><DD><A HREF="../../java/util/Arrays.html#sort(int[])"><CODE>sort(int[])</CODE></A></DL></DD></DL><HR><A NAME="binarySearch(short[], short)"><!-- --></A><H3>binarySearch</H3><PRE>public static int <B>binarySearch</B>(short[]&nbsp;a,                               short&nbsp;key)</PRE><DL><DD>Searches the specified array of shorts for the specified value using the binary search algorithm.  The array <strong>must</strong> be sorted (as by the <tt>sort</tt> method, above) prior to making this call.  If it is not sorted, the results are undefined.  If the array contains multiple elements with the specified value, there is no guarantee which one will be found.<DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - the array to be searched.<DD><CODE>key</CODE> - the value to be searched for.<DT><B>Returns:</B><DD>index of the search key, if it is contained in the list;	       otherwise, <tt>(-(<i>insertion point</i>) - 1)</tt>.  The	       <i>insertion point</i> is defined as the point at which the	       key would be inserted into the list: the index of the first	       element greater than the key, or <tt>list.size()</tt>, if all	       elements in the list are less than the specified key.  Note	       that this guarantees that the return value will be &gt;= 0 if	       and only if the key is found.<DT><B>See Also: </B><DD><A HREF="../../java/util/Arrays.html#sort(short[])"><CODE>sort(short[])</CODE></A></DL></DD></DL><HR><A NAME="binarySearch(char[], char)"><!-- --></A><H3>binarySearch</H3><PRE>public static int <B>binarySearch</B>(char[]&nbsp;a,                               char&nbsp;key)</PRE><DL><DD>Searches the specified array of chars for the specified value using the binary search algorithm.  The array <strong>must</strong> be sorted (as by the <tt>sort</tt> method, above) prior to making this call.  If it is not sorted, the results are undefined.  If the array contains multiple elements with the specified value, there is no guarantee which one will be found.<DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - the array to be searched.<DD><CODE>key</CODE> - the value to be searched for.<DT><B>Returns:</B><DD>index of the search key, if it is contained in the list;	       otherwise, <tt>(-(<i>insertion point</i>) - 1)</tt>.  The	       <i>insertion point</i> is defined as the point at which the	       key would be inserted into the list: the index of the first	       element greater than the key, or <tt>list.size()</tt>, if all	       elements in the list are less than the specified key.  Note	       that this guarantees that the return value will be &gt;= 0 if	       and only if the key is found.<DT><B>See Also: </B><DD><A HREF="../../java/util/Arrays.html#sort(char[])"><CODE>sort(char[])</CODE></A></DL></DD></DL><HR><A NAME="binarySearch(byte[], byte)"><!-- --></A><H3>binarySearch</H3><PRE>public static int <B>binarySearch</B>(byte[]&nbsp;a,                               byte&nbsp;key)</PRE><DL><DD>Searches the specified array of bytes for the specified value using the binary search algorithm.  The array <strong>must</strong> be sorted (as by the <tt>sort</tt> method, above) prior to making this call.  If it is not sorted, the results are undefined.  If the array contains multiple elements with the specified value, there is no guarantee which one will be found.<DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - the array to be searched.<DD><CODE>key</CODE> - the value to be searched for.<DT><B>Returns:</B><DD>index of the search key, if it is contained in the list;	       otherwise, <tt>(-(<i>insertion point</i>) - 1)</tt>.  The	       <i>insertion point</i> is defined as the point at which the	       key would be inserted into the list: the index of the first	       element greater than the key, or <tt>list.size()</tt>, if all	       elements in the list are less than the specified key.  Note	       that this guarantees that the return value will be &gt;= 0 if	       and only if the key is found.<DT><B>See Also: </B><DD><A HREF="../../java/util/Arrays.html#sort(byte[])"><CODE>sort(byte[])</CODE></A></DL></DD></DL><HR><A NAME="binarySearch(double[], double)"><!-- --></A><H3>binarySearch</H3><PRE>public static int <B>binarySearch</B>(double[]&nbsp;a,                               double&nbsp;key)</PRE><DL><DD>Searches the specified array of doubles for the specified value using the binary search algorithm.  The array <strong>must</strong> be sorted (as by the <tt>sort</tt> method, above) prior to making this call.  If it is not sorted, the results are undefined.  If the array contains multiple elements with the specified value, there is no guarantee which one will be found.<DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - the array to be searched.<DD><CODE>key</CODE> - the value to be searched for.<DT><B>Returns:</B><DD>index of the search key, if it is contained in the list;	       otherwise, <tt>(-(<i>insertion point</i>) - 1)</tt>.  The	       <i>insertion point</i> is defined as the point at which the	       key would be inserted into the list: the index of the first	       element greater than the key, or <tt>list.size()</tt>, if all	       elements in the list are less than the specified key.  Note	       that this guarantees that the return value will be &gt;= 0 if	       and only if the key is found.<DT><B>See Also: </B><DD><A HREF="../../java/util/Arrays.html#sort(double[])"><CODE>sort(double[])</CODE></A></DL></DD></DL><HR><A NAME="binarySearch(float[], float)"><!-- --></A><H3>binarySearch</H3><PRE>public static int <B>binarySearch</B>(float[]&nbsp;a,                               float&nbsp;key)</PRE><DL><DD>Searches the specified array of floats for the specified value using the binary search algorithm.  The array <strong>must</strong> be sorted (as by the <tt>sort</tt> method, above) prior to making this call.  If it is not sorted, the results are undefined.  If the array contains multiple elements with the specified value, there is no guarantee which one will be found.<DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - the array to be searched.<DD><CODE>key</CODE> - the value to be searched for.<DT><B>Returns:</B><DD>index of the search key, if it is contained in the list;	       otherwise, <tt>(-(<i>insertion point</i>) - 1)</tt>.  The	       <i>insertion point</i> is defined as the point at which the	       key would be inserted into the list: the index of the first	       element greater than the key, or <tt>list.size()</tt>, if all	       elements in the list are less than the specified key.  Note	       that this guarantees that the return value will be &gt;= 0 if	       and only if the key is found.<DT><B>See Also: </B><DD><A HREF="../../java/util/Arrays.html#sort(float[])"><CODE>sort(float[])</CODE></A></DL></DD></DL><HR><A NAME="binarySearch(java.lang.Object[], java.lang.Object)"><!-- --></A><H3>binarySearch</H3><PRE>public static int <B>binarySearch</B>(<A HREF="../../java/lang/Object.html">Object</A>[]&nbsp;a,                               <A HREF="../../java/lang/Object.html">Object</A>&nbsp;key)</PRE><DL><DD>Searches the specified array for the specified object using the binary search algorithm.  The array must be sorted into ascending order according to the <i>natural ordering</i> of its elements (as by <tt>Sort(Object[]</tt>), above) prior to making this call.  If it is not sorted, the results are undefined.  If the array contains multiple elements equal to the specified object, there is no guarantee which one will be found.<DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - the array to be searched.<DD><CODE>key</CODE> - the value to be searched for.<DT><B>Returns:</B><DD>index of the search key, if it is contained in the list;	       otherwise, <tt>(-(<i>insertion point</i>) - 1)</tt>.  The	       <i>insertion point</i> is defined as the point at which the	       key would be inserted into the list: the index of the first	       element greater than the key, or <tt>list.size()</tt>, if all	       elements in the list are less than the specified key.  Note	       that this guarantees that the return value will be &gt;= 0 if	       and only if the key is found.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ClassCastException.html">ClassCastException</A></CODE> - if the array contains elements that are not	       <i>mutually comparable</i> (for example, strings and integers),         or the search key in not mutually comparable with the elements         of the array.<DT><B>See Also: </B><DD><A HREF="../../java/lang/Comparabl

⌨️ 快捷键说明

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