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

📄 collections.html

📁 API資料大全
💻 HTML
📖 第 1 页 / 共 5 页
字号:
 from the corresponding position in the array.  This avoids the n<sup>2</sup> log(n) performance that would result from attempting to sort a linked list in place.<DD><DL><DT><B>Parameters:</B><DD><CODE>list</CODE> - the list to be sorted.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ClassCastException.html">ClassCastException</A></CODE> - if the list contains elements that are not	       <i>mutually comparable</i> (for example, strings and integers).<DD><CODE><A HREF="../../java/lang/UnsupportedOperationException.html">UnsupportedOperationException</A></CODE> - if the specified list's	       list-iterator does not support the <tt>set</tt> operation.<DT><B>See Also: </B><DD><A HREF="../../java/lang/Comparable.html"><CODE>Comparable</CODE></A></DL></DD></DL><HR><A NAME="sort(java.util.List, java.util.Comparator)"><!-- --></A><H3>sort</H3><PRE>public static void <B>sort</B>(<A HREF="../../java/util/List.html">List</A>&nbsp;list,                        <A HREF="../../java/util/Comparator.html">Comparator</A>&nbsp;c)</PRE><DL><DD>Sorts the specified list according to the order induced by the specified comparator.  All elements in the list must be <i>mutually comparable</i> using 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 list).<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.<p> The specified list must be modifiable, but need not be resizable. This implementation dumps the specified list into an array, sorts the array, and iterates over the list resetting each element from the corresponding position in the array.  This avoids the n<sup>2</sup> log(n) performance that would result from attempting to sort a linked list in place.<DD><DL><DT><B>Parameters:</B><DD><CODE>list</CODE> - the list to be sorted.<DD><CODE>c</CODE> - the comparator to determine the order of the list.  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 list contains elements that are not	       <i>mutually comparable</i> using the specified comparator.<DD><CODE><A HREF="../../java/lang/UnsupportedOperationException.html">UnsupportedOperationException</A></CODE> - if the specified list's	       list-iterator does not support the <tt>set</tt> operation.<DT><B>See Also: </B><DD><A HREF="../../java/util/Comparator.html"><CODE>Comparator</CODE></A></DL></DD></DL><HR><A NAME="binarySearch(java.util.List, java.lang.Object)"><!-- --></A><H3>binarySearch</H3><PRE>public static int <B>binarySearch</B>(<A HREF="../../java/util/List.html">List</A>&nbsp;list,                               <A HREF="../../java/lang/Object.html">Object</A>&nbsp;key)</PRE><DL><DD>Searches the specified list for the specified object using the binary search algorithm.  The list must be sorted into ascending order according to the <i>natural ordering</i> of its elements (as by the <tt>sort(List)</tt> method, above) prior to making this call.  If it is not sorted, the results are undefined.  If the list contains multiple elements equal to the specified object, there is no guarantee which one will be found.<p> This method runs in log(n) time for a "random access" list (which provides near-constant-time positional access).  It may run in n log(n) time if it is called on a "sequential access" list (which provides linear-time positional access).</p> If the specified list implements the <tt>AbstracSequentialList</tt> interface, this method will do a sequential search instead of a binary search; this offers linear performance instead of n log(n) performance if this method is called on a <tt>LinkedList</tt> object.<DD><DL><DT><B>Parameters:</B><DD><CODE>list</CODE> - the list to be searched.<DD><CODE>key</CODE> - the key 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 list 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 list.<DT><B>See Also: </B><DD><A HREF="../../java/lang/Comparable.html"><CODE>Comparable</CODE></A>, <A HREF="../../java/util/Collections.html#sort(java.util.List)"><CODE>sort(List)</CODE></A></DL></DD></DL><HR><A NAME="binarySearch(java.util.List, java.lang.Object, java.util.Comparator)"><!-- --></A><H3>binarySearch</H3><PRE>public static int <B>binarySearch</B>(<A HREF="../../java/util/List.html">List</A>&nbsp;list,                               <A HREF="../../java/lang/Object.html">Object</A>&nbsp;key,                               <A HREF="../../java/util/Comparator.html">Comparator</A>&nbsp;c)</PRE><DL><DD>Searches the specified list for the specified object using the binary search algorithm.  The list must be sorted into ascending order according to the specified comparator (as by the <tt>Sort(List, Comparator)</tt> method, above), prior to making this call.  If it is not sorted, the results are undefined.  If the list contains multiple elements equal to the specified object, there is no guarantee which one will be found.<p> This method runs in log(n) time for a "random access" list (which provides near-constant-time positional access).  It may run in n log(n) time if it is called on a "sequential access" list (which provides linear-time positional access).</p> If the specified list implements the <tt>AbstracSequentialList</tt> interface, this method will do a sequential search instead of a binary search; this offers linear performance instead of n log(n) performance if this method is called on a <tt>LinkedList</tt> object.<DD><DL><DT><B>Parameters:</B><DD><CODE>list</CODE> - the list to be searched.<DD><CODE>key</CODE> - the key to be searched for.<DD><CODE>c</CODE> - the comparator by which the list is ordered.  A        <tt>null</tt> value indicates that the elements' <i>natural        ordering</i> should be used.<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 list contains elements that are not	       <i>mutually comparable</i> using the specified comparator,	       or the search key in not mutually comparable with the	       elements of the list using this comparator.<DT><B>See Also: </B><DD><A HREF="../../java/lang/Comparable.html"><CODE>Comparable</CODE></A>, <A HREF="../../java/util/Collections.html#sort(java.util.List, java.util.Comparator)"><CODE>sort(List, Comparator)</CODE></A></DL></DD></DL><HR><A NAME="reverse(java.util.List)"><!-- --></A><H3>reverse</H3><PRE>public static void <B>reverse</B>(<A HREF="../../java/util/List.html">List</A>&nbsp;l)</PRE><DL><DD>Reverses the order of the elements in the specified list.<p> This method runs in linear time.<DD><DL><DT><B>Parameters:</B><DD><CODE>l</CODE> - the list whose elements are to be reversed.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/UnsupportedOperationException.html">UnsupportedOperationException</A></CODE> - if the specified list's	       list-iterator does not support the <tt>set</tt> operation.</DL></DD></DL><HR><A NAME="shuffle(java.util.List)"><!-- --></A><H3>shuffle</H3><PRE>public static void <B>shuffle</B>(<A HREF="../../java/util/List.html">List</A>&nbsp;list)</PRE><DL><DD>Randomly permutes the specified list using a default source of randomness.  All permutations occur with approximately equal likelihood.<p> The hedge "approximately" is used in the foregoing description because default source of randomenss is only approximately an unbiased source of independently chosen bits. If it were a perfect source of randomly chosen bits, then the algorithm would choose permutations with perfect uniformity.<p> This implementation traverses the list backwards, from the last element up to the second, repeatedly swapping a randomly selected element into the "current position".  Elements are randomly selected from the portion of the list that runs from the first element to the current position, inclusive.<p> This method runs in linear time for a "random access" list (which provides near-constant-time positional access).  It may require quadratic time for a "sequential access" list.<DD><DL><DT><B>Parameters:</B><DD><CODE>list</CODE> - the list to be shuffled.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/UnsupportedOperationException.html">UnsupportedOperationException</A></CODE> - if the specified list's         list-iterator does not support the <tt>set</tt> operation.</DL></DD></DL><HR><A NAME="shuffle(java.util.List, java.util.Random)"><!-- --></A><H3>shuffle</H3><PRE>public static void <B>shuffle</B>(<A HREF="../../java/util/List.html">List</A>&nbsp;list,                           <A HREF="../../java/util/Random.html">Random</A>&nbsp;rnd)</PRE><DL><DD>Randomly permute the specified list using the specified source of randomness.  All permutations occur with equal likelihood assuming that the source of randomness is fair.<p> This implementation traverses the list backwards, from the last element up to the second, repeatedly swapping a randomly selected element into the "current position".  Elements are randomly selected from the portion of the list that runs from the first element to the current position, inclusive.<p> This method runs in linear time for a "random access" list (which provides near-constant-time positional access).  It may require quadratic time for a "sequential access" list.<DD><DL><DT><B>Parameters:</B><DD><CODE>list</CODE> - the list to be shuffled.<DD><CODE>rnd</CODE> - the source of randomness to use to shuffle the list.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/UnsupportedOperationException.html">UnsupportedOperationException</A></CODE> - if the specified list's         list-iterator does not support the <tt>set</tt> operation.</DL></DD></DL><HR><A NAME="fill(java.util.List, java.lang.Object)"><!-- --></A><H3>fill</H3><PRE>public static void <B>fill</B>(<A HREF="../../java/util/List.html">List</A>&nbsp;list,                        <A HREF="../../java/lang/Object.html">Object</A>&nbsp;o)</PRE><DL><DD>Replaces all of the elements of the specified list with the specified element. <p> This method runs in linear time.<DD><DL><DT><B>Parameters:</B><DD><CODE>list</CODE> - the list to be filled with the specified element.<DD><CODE>o</CODE> - The element with which to fill the specified list.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/UnsupportedOperationException.html">UnsupportedOperationException</A></CODE> - if the specified list's	       list-iterator does not support the <tt>set</tt> operation.</DL></DD></DL><HR><A NAME="copy(java.util.List, java.util.List)"><!-- --></A><H3>copy</H3><PRE>public static void <B>copy</B>(<A HREF="../../java/util/List.html">List</A>&nbsp;dest,                        <A HREF="../../java/util/List.html">List</A>&nbsp;src)</PRE><DL><DD>Copies all of the elements from one list into another.  After the operation, the index of each copied element in the destination list will be identical to its index in the source list.  The destination list must be at least as long as the source list.  If it is longer, the remaining elements in the destination list are unaffected. <p> This method runs in linear time.<DD><DL><DT><B>Parameters:</B><DD><CODE>dest</CODE> - The destination list.<DD><CODE>src</CODE> - The source list.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IndexOutOfBoundsException.html">IndexOutOfBoundsException</A></CODE> - if the destination list is too small         to contain the entire source List.<DD><CODE><A HREF="../../java/lang/UnsupportedOperationException.html">UnsupportedOperationException</A></CODE> - if the destination list's         list-iterator does not support the <tt>set</tt> operation.</DL></DD></DL><HR><A NAME="min(java.util.Collection)"><!-- --></A><H3>min</H3><PRE>public static <A HREF="../../java/lang/Object.html">Object</A> <B>min</B>(<A HREF="../../java/util/Collection.html">Collection</A>&nbsp;coll)</PRE><DL><DD>Returns the minimum element of the given collection, according to the <i>natural ordering</i> of its elements.  All elements in the collection must implement the <tt>Comparable</tt> interface. Furthermore, all elements in the collection must be <i>mutually comparable</i> (that is, <tt>e1.compareTo(e2)</tt> must not throw a <tt>ClassCastException</tt> for any elements <tt>e1</tt> and <tt>e2</tt> in the collection).<p> This method iterates over the entire collection, hence it requires time proportional to the size of the collection.<DD><DL><DT><B>Parameters:</B><DD><CODE>coll</CODE> - the collection whose minimum element is to be determined.<DT><B>Returns:</B><DD>the minimum element of the given collection, according         to the <i>natural ordering</i> of its elements.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ClassCastException.html">ClassCastException</A></CODE> - if the collection contains elements that are	       not <i>mutually comparable</i> (for example, strings and	       integers).<DD><CODE><A HREF="../../java/util/NoSuchElementException.html">NoSuchElementException</A></CODE> - if the collection is empty.<DT><B>See Also: </B><DD><A HREF="../../java/lang/Comparable.html"><CODE>Comparable</CODE></A></DL></DD></DL><HR>

⌨️ 快捷键说明

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