📄 collections.html
字号:
<TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Collections.html#shuffle(java.util.List)">shuffle</A></B>(<A HREF="../../java/util/List.html">List</A> list)</CODE><BR> Randomly permutes the specified list using a default source of randomness.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Collections.html#shuffle(java.util.List, java.util.Random)">shuffle</A></B>(<A HREF="../../java/util/List.html">List</A> list, <A HREF="../../java/util/Random.html">Random</A> rnd)</CODE><BR> Randomly permute the specified list using the specified source of randomness.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/util/Set.html">Set</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Collections.html#singleton(java.lang.Object)">singleton</A></B>(<A HREF="../../java/lang/Object.html">Object</A> o)</CODE><BR> Returns an immutable set containing only the specified object.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/util/List.html">List</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Collections.html#singletonList(java.lang.Object)">singletonList</A></B>(<A HREF="../../java/lang/Object.html">Object</A> o)</CODE><BR> Returns an immutable list containing only the specified object.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/util/Map.html">Map</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Collections.html#singletonMap(java.lang.Object, java.lang.Object)">singletonMap</A></B>(<A HREF="../../java/lang/Object.html">Object</A> key, <A HREF="../../java/lang/Object.html">Object</A> value)</CODE><BR> Returns an immutable map, mapping only the specified key to the specified value.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Collections.html#sort(java.util.List)">sort</A></B>(<A HREF="../../java/util/List.html">List</A> list)</CODE><BR> Sorts the specified list into ascending order, according to the <i>natural ordering</i> of its elements.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Collections.html#sort(java.util.List, java.util.Comparator)">sort</A></B>(<A HREF="../../java/util/List.html">List</A> list, <A HREF="../../java/util/Comparator.html">Comparator</A> c)</CODE><BR> Sorts the specified list according to the order induced by the specified comparator.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/util/Collection.html">Collection</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Collections.html#synchronizedCollection(java.util.Collection)">synchronizedCollection</A></B>(<A HREF="../../java/util/Collection.html">Collection</A> c)</CODE><BR> Returns a synchronized (thread-safe) collection backed by the specified collection.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/util/List.html">List</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Collections.html#synchronizedList(java.util.List)">synchronizedList</A></B>(<A HREF="../../java/util/List.html">List</A> list)</CODE><BR> Returns a synchronized (thread-safe) list backed by the specified list.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/util/Map.html">Map</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Collections.html#synchronizedMap(java.util.Map)">synchronizedMap</A></B>(<A HREF="../../java/util/Map.html">Map</A> m)</CODE><BR> Returns a synchronized (thread-safe) map backed by the specified map.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/util/Set.html">Set</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Collections.html#synchronizedSet(java.util.Set)">synchronizedSet</A></B>(<A HREF="../../java/util/Set.html">Set</A> s)</CODE><BR> Returns a synchronized (thread-safe) set backed by the specified set.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/util/SortedMap.html">SortedMap</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Collections.html#synchronizedSortedMap(java.util.SortedMap)">synchronizedSortedMap</A></B>(<A HREF="../../java/util/SortedMap.html">SortedMap</A> m)</CODE><BR> Returns a synchronized (thread-safe) sorted map backed by the specified sorted map.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/util/SortedSet.html">SortedSet</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Collections.html#synchronizedSortedSet(java.util.SortedSet)">synchronizedSortedSet</A></B>(<A HREF="../../java/util/SortedSet.html">SortedSet</A> s)</CODE><BR> Returns a synchronized (thread-safe) sorted set backed by the specified sorted set.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/util/Collection.html">Collection</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Collections.html#unmodifiableCollection(java.util.Collection)">unmodifiableCollection</A></B>(<A HREF="../../java/util/Collection.html">Collection</A> c)</CODE><BR> Returns an unmodifiable view of the specified collection.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/util/List.html">List</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Collections.html#unmodifiableList(java.util.List)">unmodifiableList</A></B>(<A HREF="../../java/util/List.html">List</A> list)</CODE><BR> Returns an unmodifiable view of the specified list.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/util/Map.html">Map</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Collections.html#unmodifiableMap(java.util.Map)">unmodifiableMap</A></B>(<A HREF="../../java/util/Map.html">Map</A> m)</CODE><BR> Returns an unmodifiable view of the specified map.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/util/Set.html">Set</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Collections.html#unmodifiableSet(java.util.Set)">unmodifiableSet</A></B>(<A HREF="../../java/util/Set.html">Set</A> s)</CODE><BR> Returns an unmodifiable view of the specified set.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/util/SortedMap.html">SortedMap</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Collections.html#unmodifiableSortedMap(java.util.SortedMap)">unmodifiableSortedMap</A></B>(<A HREF="../../java/util/SortedMap.html">SortedMap</A> m)</CODE><BR> Returns an unmodifiable view of the specified sorted map.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/util/SortedSet.html">SortedSet</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Collections.html#unmodifiableSortedSet(java.util.SortedSet)">unmodifiableSortedSet</A></B>(<A HREF="../../java/util/SortedSet.html">SortedSet</A> s)</CODE><BR> Returns an unmodifiable view of the specified sorted set.</TD></TR></TABLE> <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Methods inherited from class java.lang.<A HREF="../../java/lang/Object.html">Object</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../java/lang/Object.html#clone()">clone</A>, <A HREF="../../java/lang/Object.html#equals(java.lang.Object)">equals</A>, <A HREF="../../java/lang/Object.html#finalize()">finalize</A>, <A HREF="../../java/lang/Object.html#getClass()">getClass</A>, <A HREF="../../java/lang/Object.html#hashCode()">hashCode</A>, <A HREF="../../java/lang/Object.html#notify()">notify</A>, <A HREF="../../java/lang/Object.html#notifyAll()">notifyAll</A>, <A HREF="../../java/lang/Object.html#toString()">toString</A>, <A HREF="../../java/lang/Object.html#wait()">wait</A>, <A HREF="../../java/lang/Object.html#wait(long)">wait</A>, <A HREF="../../java/lang/Object.html#wait(long, int)">wait</A></CODE></TD></TR></TABLE> <P><!-- ============ FIELD DETAIL =========== --><A NAME="field_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Field Detail</B></FONT></TD></TR></TABLE><A NAME="EMPTY_SET"><!-- --></A><H3>EMPTY_SET</H3><PRE>public static final <A HREF="../../java/util/Set.html">Set</A> <B>EMPTY_SET</B></PRE><DL><DD>The empty set (immutable). This set is serializable.</DL><HR><A NAME="EMPTY_LIST"><!-- --></A><H3>EMPTY_LIST</H3><PRE>public static final <A HREF="../../java/util/List.html">List</A> <B>EMPTY_LIST</B></PRE><DL><DD>The empty list (immutable). This list is serializable.</DL><HR><A NAME="EMPTY_MAP"><!-- --></A><H3>EMPTY_MAP</H3><PRE>public static final <A HREF="../../java/util/Map.html">Map</A> <B>EMPTY_MAP</B></PRE><DL><DD>The empty map (immutable). This map is serializable.<DD><DL><DT><B>Since: </B><DD>1.3</DD></DL></DD></DL><!-- ========= CONSTRUCTOR DETAIL ======== --><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Method Detail</B></FONT></TD></TR></TABLE><A NAME="sort(java.util.List)"><!-- --></A><H3>sort</H3><PRE>public static void <B>sort</B>(<A HREF="../../java/util/List.html">List</A> list)</PRE><DL><DD>Sorts the specified list into ascending order, according to the <i>natural ordering</i> of its elements. All elements in the list must implement the <tt>Comparable</tt> interface. Furthermore, all elements in the list 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 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 specified list must be modifiable, but need not be resizable.<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> This implementation dumps the specified list into an array, sorts the array, and iterates over the list resetting each element
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -