src/java.base/share/classes/java/util/doc-files/coll-reference.html
changeset 49522 3930c4d4f805
parent 47216 71c04702a3d5
child 52808 064e5795fa59
equal deleted inserted replaced
49521:755e1b55a4df 49522:3930c4d4f805
     1 <!DOCTYPE html>
     1 <!DOCTYPE html>
     2 <!--
     2 <!--
     3  Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
     3  Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
     4  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5 
     5 
     6  This code is free software; you can redistribute it and/or modify it
     6  This code is free software; you can redistribute it and/or modify it
     7  under the terms of the GNU General Public License version 2 only, as
     7  under the terms of the GNU General Public License version 2 only, as
     8  published by the Free Software Foundation.  Oracle designates this
     8  published by the Free Software Foundation.  Oracle designates this
   175 "../LinkedHashMap.html">LinkedHashMap</a></strong>
   175 "../LinkedHashMap.html">LinkedHashMap</a></strong>
   176 - Hash table and linked list implementation of the <code>Map</code>
   176 - Hash table and linked list implementation of the <code>Map</code>
   177 interface. An insertion-ordered <code>Map</code> implementation that
   177 interface. An insertion-ordered <code>Map</code> implementation that
   178 runs nearly as fast as <code>HashMap</code>. Also useful for building
   178 runs nearly as fast as <code>HashMap</code>. Also useful for building
   179 caches (see <a href=
   179 caches (see <a href=
   180 "../LinkedHashMap.html#removeEldestEntry-java.util.Map.Entry-">
   180 "../LinkedHashMap.html#removeEldestEntry(java.util.Map.Entry)">
   181 removeEldestEntry(Map.Entry)</a> ).</li>
   181 removeEldestEntry(Map.Entry)</a> ).</li>
   182 </ul>
   182 </ul>
   183 </li>
   183 </li>
   184 <li><strong>Wrapper implementations</strong> -
   184 <li><strong>Wrapper implementations</strong> -
   185 Functionality-enhancing implementations for use with other
   185 Functionality-enhancing implementations for use with other
   186 implementations. Accessed solely through static factory methods.
   186 implementations. Accessed solely through static factory methods.
   187 <ul>
   187 <ul>
   188 <li><a href=
   188 <li><a href=
   189 "../Collections.html#unmodifiableCollection-java.util.Collection-">
   189 "../Collections.html#unmodifiableCollection(java.util.Collection)">
   190 <strong>Collections.unmodifiable<i>Interface</i></strong></a> -
   190 <strong>Collections.unmodifiable<i>Interface</i></strong></a> -
   191 Returns an unmodifiable view of a specified collection that throws
   191 Returns an unmodifiable view of a specified collection that throws
   192 an <code>UnsupportedOperationException</code> if the user attempts to
   192 an <code>UnsupportedOperationException</code> if the user attempts to
   193 modify it.</li>
   193 modify it.</li>
   194 <li><a href=
   194 <li><a href=
   195 "../Collections.html#synchronizedCollection-java.util.Collection-"
   195 "../Collections.html#synchronizedCollection(java.util.Collection)"
   196 id=
   196 id=
   197 "synchWrappers"><strong>Collections.synchronized<i>Interface</i></strong></a>
   197 "synchWrappers"><strong>Collections.synchronized<i>Interface</i></strong></a>
   198 - Returns a synchronized collection that is backed by the specified
   198 - Returns a synchronized collection that is backed by the specified
   199 (typically unsynchronized) collection. As long as all accesses to
   199 (typically unsynchronized) collection. As long as all accesses to
   200 the backing collection are through the returned collection, thread
   200 the backing collection are through the returned collection, thread
   201 safety is guaranteed.</li>
   201 safety is guaranteed.</li>
   202 <li><a href=
   202 <li><a href=
   203 "../Collections.html#checkedCollection-java.util.Collection-java.lang.Class-">
   203 "../Collections.html#checkedCollection(java.util.Collection,java.lang.Class)">
   204 <strong>Collections.checked<i>Interface</i></strong></a> - Returns
   204 <strong>Collections.checked<i>Interface</i></strong></a> - Returns
   205 a dynamically type-safe view of the specified collection, which
   205 a dynamically type-safe view of the specified collection, which
   206 throws a <code>ClassCastException</code> if a client attempts to add an
   206 throws a <code>ClassCastException</code> if a client attempts to add an
   207 element of the wrong type. The generics mechanism in the language
   207 element of the wrong type. The generics mechanism in the language
   208 provides compile-time (static) type checking, but it is possible to
   208 provides compile-time (static) type checking, but it is possible to
   212 </li>
   212 </li>
   213 <li><strong>Adapter implementations</strong> - Implementations that
   213 <li><strong>Adapter implementations</strong> - Implementations that
   214 adapt one collections interface to another:
   214 adapt one collections interface to another:
   215 <ul>
   215 <ul>
   216 <li><strong><a href=
   216 <li><strong><a href=
   217 "../Collections.html#newSetFromMap-java.util.Map-">
   217 "../Collections.html#newSetFromMap(java.util.Map)">
   218 newSetFromMap(Map)</a></strong> - Creates a general-purpose
   218 newSetFromMap(Map)</a></strong> - Creates a general-purpose
   219 <code>Set</code> implementation from a general-purpose <code>Map</code>
   219 <code>Set</code> implementation from a general-purpose <code>Map</code>
   220 implementation.</li>
   220 implementation.</li>
   221 <li><strong><a href=
   221 <li><strong><a href=
   222 "../Collections.html#asLifoQueue-java.util.Deque-">
   222 "../Collections.html#asLifoQueue(java.util.Deque)">
   223 asLifoQueue(Deque)</a></strong> - Returns a view of a
   223 asLifoQueue(Deque)</a></strong> - Returns a view of a
   224 <code>Deque</code> as a Last In First Out (LIFO) <code>Queue</code>.</li>
   224 <code>Deque</code> as a Last In First Out (LIFO) <code>Queue</code>.</li>
   225 </ul>
   225 </ul>
   226 </li>
   226 </li>
   227 <li><strong>Convenience implementations</strong> - High-performance
   227 <li><strong>Convenience implementations</strong> - High-performance
   228 "mini-implementations" of the collection interfaces.
   228 "mini-implementations" of the collection interfaces.
   229 <ul>
   229 <ul>
   230 <li><a href=
   230 <li><a href=
   231 "../Arrays.html#asList-T...-"><strong>Arrays.asList</strong></a>
   231 "../Arrays.html#asList(T...)"><strong>Arrays.asList</strong></a>
   232 - Enables an array to be viewed as a list.</li>
   232 - Enables an array to be viewed as a list.</li>
   233 <li><strong><a href=
   233 <li><strong><a href=
   234 "../Collections.html#emptySet--">emptySet</a>,
   234 "../Collections.html#emptySet()">emptySet</a>,
   235 <a href=
   235 <a href=
   236 "../Collections.html#emptyList--">emptyList</a>
   236 "../Collections.html#emptyList()">emptyList</a>
   237 and <a href=
   237 and <a href=
   238 "../Collections.html#emptyMap--">emptyMap</a></strong>
   238 "../Collections.html#emptyMap()">emptyMap</a></strong>
   239 - Return an immutable empty set, list, or map.</li>
   239 - Return an immutable empty set, list, or map.</li>
   240 <li><strong><a href=
   240 <li><strong><a href=
   241 "../Collections.html#singleton-java.lang.Object-">
   241 "../Collections.html#singleton(java.lang.Object)">
   242 singleton</a>, <a href=
   242 singleton</a>, <a href=
   243 "../Collections.html#singletonList-java.lang.Object-">
   243 "../Collections.html#singletonList(java.lang.Object)">
   244 singletonList</a>, and <a href=
   244 singletonList</a>, and <a href=
   245 "../Collections.html#singletonMap-K-V-">singletonMap</a></strong>
   245 "../Collections.html#singletonMap(K,V)">singletonMap</a></strong>
   246 - Return an immutable singleton set, list, or map, containing only
   246 - Return an immutable singleton set, list, or map, containing only
   247 the specified object (or key-value mapping).</li>
   247 the specified object (or key-value mapping).</li>
   248 <li><a href=
   248 <li><a href=
   249 "../Collections.html#nCopies-int-T-"><strong>
   249 "../Collections.html#nCopies(int,T)"><strong>
   250 nCopies</strong></a> - Returns an immutable list consisting of n
   250 nCopies</strong></a> - Returns an immutable list consisting of n
   251 copies of a specified object.</li>
   251 copies of a specified object.</li>
   252 </ul>
   252 </ul>
   253 </li>
   253 </li>
   254 <li><strong>Legacy implementations</strong> - Older collection
   254 <li><strong>Legacy implementations</strong> - Older collection
   408 <li><strong>Algorithms</strong> - The <a href=
   408 <li><strong>Algorithms</strong> - The <a href=
   409 "../Collections.html"><strong>Collections</strong></a>
   409 "../Collections.html"><strong>Collections</strong></a>
   410 class contains these useful static methods.
   410 class contains these useful static methods.
   411 <ul>
   411 <ul>
   412 <li><strong><a href=
   412 <li><strong><a href=
   413 "../Collections.html#sort-java.util.List-">sort(List)</a></strong>
   413 "../Collections.html#sort(java.util.List)">sort(List)</a></strong>
   414 - Sorts a list using a merge sort algorithm, which provides average
   414 - Sorts a list using a merge sort algorithm, which provides average
   415 case performance comparable to a high quality quicksort, guaranteed
   415 case performance comparable to a high quality quicksort, guaranteed
   416 O(n*log n) performance (unlike quicksort), and <em>stability</em>
   416 O(n*log n) performance (unlike quicksort), and <em>stability</em>
   417 (unlike quicksort). A stable sort is one that does not reorder
   417 (unlike quicksort). A stable sort is one that does not reorder
   418 equal elements.</li>
   418 equal elements.</li>
   419 <li><strong><a href=
   419 <li><strong><a href=
   420 "../Collections.html#binarySearch-java.util.List-T-">
   420 "../Collections.html#binarySearch(java.util.List,T)">
   421 binarySearch(List, Object)</a></strong> - Searches for an element
   421 binarySearch(List, Object)</a></strong> - Searches for an element
   422 in an ordered list using the binary search algorithm.</li>
   422 in an ordered list using the binary search algorithm.</li>
   423 <li><strong><a href=
   423 <li><strong><a href=
   424 "../Collections.html#reverse-java.util.List-">reverse(List)</a></strong>
   424 "../Collections.html#reverse(java.util.List)">reverse(List)</a></strong>
   425 - Reverses the order of the elements in a list.</li>
   425 - Reverses the order of the elements in a list.</li>
   426 <li><strong><a href=
   426 <li><strong><a href=
   427 "../Collections.html#shuffle-java.util.List-">shuffle(List)</a></strong>
   427 "../Collections.html#shuffle(java.util.List)">shuffle(List)</a></strong>
   428 - Randomly changes the order of the elements in a list.</li>
   428 - Randomly changes the order of the elements in a list.</li>
   429 <li><strong><a href=
   429 <li><strong><a href=
   430 "../Collections.html#fill-java.util.List-T-">
   430 "../Collections.html#fill(java.util.List,T)">
   431 fill(List, Object)</a></strong> - Overwrites every element in a
   431 fill(List, Object)</a></strong> - Overwrites every element in a
   432 list with the specified value.</li>
   432 list with the specified value.</li>
   433 <li><strong><a href=
   433 <li><strong><a href=
   434 "../Collections.html#copy-java.util.List-java.util.List-">
   434 "../Collections.html#copy-java.util.List(java.util.List)">
   435 copy(List dest, List src)</a></strong> - Copies the source list
   435 copy(List dest, List src)</a></strong> - Copies the source list
   436 into the destination list.</li>
   436 into the destination list.</li>
   437 <li><strong><a href=
   437 <li><strong><a href=
   438 "../Collections.html#min-java.util.Collection-">
   438 "../Collections.html#min(java.util.Collection)">
   439 min(Collection)</a></strong> - Returns the minimum element in a
   439 min(Collection)</a></strong> - Returns the minimum element in a
   440 collection.</li>
   440 collection.</li>
   441 <li><strong><a href=
   441 <li><strong><a href=
   442 "../Collections.html#max-java.util.Collection-">
   442 "../Collections.html#max(java.util.Collection)">
   443 max(Collection)</a></strong> - Returns the maximum element in a
   443 max(Collection)</a></strong> - Returns the maximum element in a
   444 collection.</li>
   444 collection.</li>
   445 <li><strong><a href=
   445 <li><strong><a href=
   446 "../Collections.html#rotate-java.util.List-int-">
   446 "../Collections.html#rotate(java.util.List,int)">
   447 rotate(List list, int distance)</a></strong> - Rotates all of the
   447 rotate(List list, int distance)</a></strong> - Rotates all of the
   448 elements in the list by the specified distance.</li>
   448 elements in the list by the specified distance.</li>
   449 <li><strong><a href=
   449 <li><strong><a href=
   450 "../Collections.html#replaceAll-java.util.List-T-T-">
   450 "../Collections.html#replaceAll(java.util.List,T,T)">
   451 replaceAll(List list, Object oldVal, Object newVal)</a></strong> -
   451 replaceAll(List list, Object oldVal, Object newVal)</a></strong> -
   452 Replaces all occurrences of one specified value with another.</li>
   452 Replaces all occurrences of one specified value with another.</li>
   453 <li><strong><a href=
   453 <li><strong><a href=
   454 "../Collections.html#indexOfSubList-java.util.List-java.util.List-">
   454 "../Collections.html#indexOfSubList(java.util.List,java.util.List)">
   455 indexOfSubList(List source, List target)</a></strong> - Returns the
   455 indexOfSubList(List source, List target)</a></strong> - Returns the
   456 index of the first sublist of source that is equal to target.</li>
   456 index of the first sublist of source that is equal to target.</li>
   457 <li><strong><a href=
   457 <li><strong><a href=
   458 "../Collections.html#lastIndexOfSubList-java.util.List-java.util.List-">
   458 "../Collections.html#lastIndexOfSubList(java.util.List,java.util.List)">
   459 lastIndexOfSubList(List source, List target)</a></strong> - Returns
   459 lastIndexOfSubList(List source, List target)</a></strong> - Returns
   460 the index of the last sublist of source that is equal to
   460 the index of the last sublist of source that is equal to
   461 target.</li>
   461 target.</li>
   462 <li><strong><a href=
   462 <li><strong><a href=
   463 "../Collections.html#swap-java.util.List-int-int-">
   463 "../Collections.html#swap(java.util.List,int,int)">
   464 swap(List, int, int)</a></strong> - Swaps the elements at the
   464 swap(List, int, int)</a></strong> - Swaps the elements at the
   465 specified positions in the specified list.</li>
   465 specified positions in the specified list.</li>
   466 <li><strong><a href=
   466 <li><strong><a href=
   467 "../Collections.html#frequency-java.util.Collection-java.lang.Object-">
   467 "../Collections.html#frequency(java.util.Collection,java.lang.Object)">
   468 frequency(Collection, Object)</a></strong> - Counts the number of
   468 frequency(Collection, Object)</a></strong> - Counts the number of
   469 times the specified element occurs in the specified
   469 times the specified element occurs in the specified
   470 collection.</li>
   470 collection.</li>
   471 <li><strong><a href=
   471 <li><strong><a href=
   472 "../Collections.html#disjoint-java.util.Collection-java.util.Collection-">
   472 "../Collections.html#disjoint(java.util.Collection,java.util.Collection)">
   473 disjoint(Collection, Collection)</a></strong> - Determines whether
   473 disjoint(Collection, Collection)</a></strong> - Determines whether
   474 two collections are disjoint, in other words, whether they contain
   474 two collections are disjoint, in other words, whether they contain
   475 no elements in common.</li>
   475 no elements in common.</li>
   476 <li><strong><a href=
   476 <li><strong><a href=
   477 "../Collections.html#addAll-java.util.Collection-T...-">
   477 "../Collections.html#addAll(java.util.Collection,T...)">
   478 addAll(Collection&lt;? super T&gt;, T...)</a></strong> - Adds all
   478 addAll(Collection&lt;? super T&gt;, T...)</a></strong> - Adds all
   479 of the elements in the specified array to the specified
   479 of the elements in the specified array to the specified
   480 collection.</li>
   480 collection.</li>
   481 </ul>
   481 </ul>
   482 </li>
   482 </li>