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

📄 collections.html

📁 API資料大全
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<A NAME="min(java.util.Collection, java.util.Comparator)"><!-- --></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,                         <A HREF="../../java/util/Comparator.html">Comparator</A>&nbsp;comp)</PRE><DL><DD>Returns the minimum element of the given collection, according to the order induced by the specified comparator.  All elements in the collection must be <i>mutually comparable</i> by the specified comparator (that is, <tt>comp.compare(e1, 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.<DD><CODE>comp</CODE> - the comparator with which to determine the minimum element.         A <tt>null</tt> value indicates that the elements' <i>natural         ordering</i> should be used.<DT><B>Returns:</B><DD>the minimum element of the given collection, according         to the specified comparator.<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> using the specified comparator.<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><A NAME="max(java.util.Collection)"><!-- --></A><H3>max</H3><PRE>public static <A HREF="../../java/lang/Object.html">Object</A> <B>max</B>(<A HREF="../../java/util/Collection.html">Collection</A>&nbsp;coll)</PRE><DL><DD>Returns the maximum 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 maximum element is to be determined.<DT><B>Returns:</B><DD>the maximum 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><A NAME="max(java.util.Collection, java.util.Comparator)"><!-- --></A><H3>max</H3><PRE>public static <A HREF="../../java/lang/Object.html">Object</A> <B>max</B>(<A HREF="../../java/util/Collection.html">Collection</A>&nbsp;coll,                         <A HREF="../../java/util/Comparator.html">Comparator</A>&nbsp;comp)</PRE><DL><DD>Returns the maximum element of the given collection, according to the order induced by the specified comparator.  All elements in the collection must be <i>mutually comparable</i> by the specified comparator (that is, <tt>comp.compare(e1, 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 maximum element is to be determined.<DD><CODE>comp</CODE> - the comparator with which to determine the maximum element.         A <tt>null</tt> value indicates that the elements' <i>natural        ordering</i> should be used.<DT><B>Returns:</B><DD>the maximum element of the given collection, according         to the specified comparator.<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> using the specified comparator.<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><A NAME="unmodifiableCollection(java.util.Collection)"><!-- --></A><H3>unmodifiableCollection</H3><PRE>public static <A HREF="../../java/util/Collection.html">Collection</A> <B>unmodifiableCollection</B>(<A HREF="../../java/util/Collection.html">Collection</A>&nbsp;c)</PRE><DL><DD>Returns an unmodifiable view of the specified collection.  This method allows modules to provide users with "read-only" access to internal collections.  Query operations on the returned collection "read through" to the specified collection, and attempts to modify the returned collection, whether direct or via its iterator, result in an <tt>UnsupportedOperationException</tt>.<p> The returned collection does <i>not</i> pass the hashCode and equals operations through to the backing collection, but relies on <tt>Object</tt>'s <tt>equals</tt> and <tt>hashCode</tt> methods.  This is necessary to preserve the contracts of these operations in the case that the backing collection is a set or a list.<p> The returned collection will be serializable if the specified collection is serializable.<DD><DL><DT><B>Parameters:</B><DD><CODE>c</CODE> - the collection for which an unmodifiable view is to be	       returned.<DT><B>Returns:</B><DD>an unmodifiable view of the specified collection.</DL></DD></DL><HR><A NAME="unmodifiableSet(java.util.Set)"><!-- --></A><H3>unmodifiableSet</H3><PRE>public static <A HREF="../../java/util/Set.html">Set</A> <B>unmodifiableSet</B>(<A HREF="../../java/util/Set.html">Set</A>&nbsp;s)</PRE><DL><DD>Returns an unmodifiable view of the specified set.  This method allows modules to provide users with "read-only" access to internal sets. Query operations on the returned set "read through" to the specified set, and attempts to modify the returned set, whether direct or via its iterator, result in an <tt>UnsupportedOperationException</tt>.<p> The returned set will be serializable if the specified set is serializable.<DD><DL><DT><B>Parameters:</B><DD><CODE>s</CODE> - the set for which an unmodifiable view is to be returned.<DT><B>Returns:</B><DD>an unmodifiable view of the specified set.</DL></DD></DL><HR><A NAME="unmodifiableSortedSet(java.util.SortedSet)"><!-- --></A><H3>unmodifiableSortedSet</H3><PRE>public static <A HREF="../../java/util/SortedSet.html">SortedSet</A> <B>unmodifiableSortedSet</B>(<A HREF="../../java/util/SortedSet.html">SortedSet</A>&nbsp;s)</PRE><DL><DD>Returns an unmodifiable view of the specified sorted set.  This method allows modules to provide users with "read-only" access to internal sorted sets.  Query operations on the returned sorted set "read through" to the specified sorted set.  Attempts to modify the returned sorted set, whether direct, via its iterator, or via its <tt>subSet</tt>, <tt>headSet</tt>, or <tt>tailSet</tt> views, result in an <tt>UnsupportedOperationException</tt>.<p> The returned sorted set will be serializable if the specified sorted set is serializable.<DD><DL><DT><B>Parameters:</B><DD><CODE>s</CODE> - the sorted set for which an unmodifiable view is to be        returned.<DT><B>Returns:</B><DD>an unmodifiable view of the specified sorted set.</DL></DD></DL><HR><A NAME="unmodifiableList(java.util.List)"><!-- --></A><H3>unmodifiableList</H3><PRE>public static <A HREF="../../java/util/List.html">List</A> <B>unmodifiableList</B>(<A HREF="../../java/util/List.html">List</A>&nbsp;list)</PRE><DL><DD>Returns an unmodifiable view of the specified list.  This method allows modules to provide users with "read-only" access to internal lists.  Query operations on the returned list "read through" to the specified list, and attempts to modify the returned list, whether direct or via its iterator, result in an <tt>UnsupportedOperationException</tt>.<p> The returned list will be serializable if the specified list is serializable.<DD><DL><DT><B>Parameters:</B><DD><CODE>list</CODE> - the list for which an unmodifiable view is to be returned.<DT><B>Returns:</B><DD>an unmodifiable view of the specified list.</DL></DD></DL><HR><A NAME="unmodifiableMap(java.util.Map)"><!-- --></A><H3>unmodifiableMap</H3><PRE>public static <A HREF="../../java/util/Map.html">Map</A> <B>unmodifiableMap</B>(<A HREF="../../java/util/Map.html">Map</A>&nbsp;m)</PRE><DL><DD>Returns an unmodifiable view of the specified map.  This method allows modules to provide users with "read-only" access to internal maps.  Query operations on the returned map "read through" to the specified map, and attempts to modify the returned map, whether direct or via its collection views, result in an <tt>UnsupportedOperationException</tt>.<p> The returned map will be serializable if the specified map is serializable.<DD><DL><DT><B>Parameters:</B><DD><CODE>m</CODE> - the map for which an unmodifiable view is to be returned.<DT><B>Returns:</B><DD>an unmodifiable view of the specified map.</DL></DD></DL><HR><A NAME="unmodifiableSortedMap(java.util.SortedMap)"><!-- --></A><H3>unmodifiableSortedMap</H3><PRE>public static <A HREF="../../java/util/SortedMap.html">SortedMap</A> <B>unmodifiableSortedMap</B>(<A HREF="../../java/util/SortedMap.html">SortedMap</A>&nbsp;m)</PRE><DL><DD>Returns an unmodifiable view of the specified sorted map.  This method allows modules to provide users with "read-only" access to internal sorted maps.  Query operations on the returned sorted map "read through" to the specified sorted map.  Attempts to modify the returned sorted map, whether direct, via its collection views, or via its <tt>subMap</tt>, <tt>headMap</tt>, or <tt>tailMap</tt> views, result in an <tt>UnsupportedOperationException</tt>.<p> The returned sorted map will be serializable if the specified sorted map is serializable.<DD><DL><DT><B>Parameters:</B><DD><CODE>m</CODE> - the sorted map for which an unmodifiable view is to be        returned.<DT><B>Returns:</B><DD>an unmodifiable view of the specified sorted map.</DL></DD></DL><HR><A NAME="synchronizedCollection(java.util.Collection)"><!-- --></A><H3>synchronizedCollection</H3><PRE>public static <A HREF="../../java/util/Collection.html">Collection</A> <B>synchronizedCollection</B>(<A HREF="../../java/util/Collection.html">Collection</A>&nbsp;c)</PRE><DL><DD>Returns a synchronized (thread-safe) collection backed by the specified collection.  In order to guarantee serial access, it is critical that <strong>all</strong> access to the backing collection is accomplished through the returned collection.<p> It is imperative that the user manually synchronize on the returned collection when iterating over it: <pre>  Collection c = Collections.synchronizedCollection(myCollection);     ...  synchronized(c) {      Iterator i = c.iterator(); // Must be in the synchronized block      while (i.hasNext())         foo(i.next());  } </pre> Failure to follow this advice may result in non-deterministic behavior. <p>The returned collection does <i>not</i> pass the <tt>hashCode</tt> and <tt>equals</tt> operations through to the backing collection, but relies on <tt>Object</tt>'s equals and hashCode methods.  This is necessary to preserve the contracts of these operations in the case that the backing collection is a set or a list.<p> The returned collection will be serializable if the specified collection is serializable.<DD><DL><DT><B>Parameters:</B><DD><CODE>c</CODE> - the collection to be "wrapped" in a synchronized collection.<DT><B>Returns:</B><DD>a synchronized view of the specified collection.</DL></DD></DL><HR><A NAME="synchronizedSet(java.util.Set)"><!-- --></A><H3>synchronizedSet</H3><PRE>public static <A HREF="../../java/util/Set.html">Set</A> <B>synchronizedSet</B>(<A HREF="../../java/util/Set.html">Set</A>&nbsp;s)</PRE><DL><DD>Returns a synchronized (thread-safe) set backed by the specified set.  In order to guarantee serial access, it is critical that <strong>all</strong> access to the backing set is accomplished through the returned set.<p> It is imperative that the user manually synchronize on the returned set when iterating over it: <pre>  Set s = Collections.synchronizedSet(new HashSet());      ...  synchronized(s) {      Iterator i = s.iterator(); // Must be in the synchronized block      while (i.hasNext())          foo(i.next());  } </pre> Failure to follow this advice may result in non-deterministic behavior.

⌨️ 快捷键说明

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