<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--NewPage--> <HTML> <HEAD> <!-- Generated by javadoc (build 1.6.0-google-internal) on Mon Jan 04 20:47:59 PST 2010 --> <TITLE> Lists (Guava Libraries 2010.01.04) </TITLE> <META NAME="date" CONTENT="2010-01-04"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style"> <SCRIPT type="text/javascript"> function windowTitle() { if (location.href.indexOf('is-external=true') == -1) { parent.document.title="Lists (Guava Libraries 2010.01.04)"; } } </SCRIPT> <NOSCRIPT> </NOSCRIPT> </HEAD> <BODY BGCOLOR="white" onload="windowTitle();"> <HR> <!-- ========= START OF TOP NAVBAR ======= --> <A NAME="navbar_top"><!-- --></A> <A HREF="#skip-navbar_top" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_top_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Lists.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../com/google/common/collect/ListMultimap.html" title="interface in com.google.common.collect"><B>PREV CLASS</B></A> <A HREF="../../../../com/google/common/collect/MapDifference.html" title="interface in com.google.common.collect"><B>NEXT CLASS</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../index.html?com/google/common/collect/Lists.html" target="_top"><B>FRAMES</B></A> <A HREF="Lists.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> <TR> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_top"></A> <!-- ========= END OF TOP NAVBAR ========= --> <HR> <!-- ======== START OF CLASS DATA ======== --> <H2> <FONT SIZE="-1"> com.google.common.collect</FONT> <BR> Class Lists</H2> <PRE> <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</A> <IMG SRC="../../../../resources/inherit.gif" ALT="extended by "><B>com.google.common.collect.Lists</B> </PRE> <HR> <DL> <DT><PRE>public final class <B>Lists</B><DT>extends <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></DL> </PRE> <P> Static utility methods pertaining to <A HREF="http://java.sun.com/javase/6/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util"><CODE>List</CODE></A> instances. Also see this class's counterparts <A HREF="../../../../com/google/common/collect/Sets.html" title="class in com.google.common.collect"><CODE>Sets</CODE></A> and <A HREF="../../../../com/google/common/collect/Maps.html" title="class in com.google.common.collect"><CODE>Maps</CODE></A>. <P> <P> <DL> <DT><B>Since:</B></DT> <DD>2010.01.04 <b>stable</b> (imported from Google Collections Library)</DD> <DT><B>Author:</B></DT> <DD>Kevin Bourrillion, Mike Bostock</DD> </DL> <HR> <P> <!-- ========== METHOD SUMMARY =========== --> <A NAME="method_summary"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> <B>Method Summary</B></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> <TR ALIGN="right" VALIGN=""> <TD NOWRAP><FONT SIZE="-1"> <CODE><E> <A HREF="http://java.sun.com/javase/6/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</A><E></CODE></FONT></TD> </TR> </TABLE> </CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../com/google/common/collect/Lists.html#asList(E, E[])">asList</A></B>(E first, E[] rest)</CODE> <BR> Returns an unmodifiable list containing the specified first element and backed by the specified array of additional elements.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> <TR ALIGN="right" VALIGN=""> <TD NOWRAP><FONT SIZE="-1"> <CODE><E> <A HREF="http://java.sun.com/javase/6/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</A><E></CODE></FONT></TD> </TR> </TABLE> </CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../com/google/common/collect/Lists.html#asList(E, E, E[])">asList</A></B>(E first, E second, E[] rest)</CODE> <BR> Returns an unmodifiable list containing the specified first and second element, and backed by the specified array of additional elements.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> <TR ALIGN="right" VALIGN=""> <TD NOWRAP><FONT SIZE="-1"> <CODE><E> <A HREF="http://java.sun.com/javase/6/docs/api/java/util/ArrayList.html?is-external=true" title="class or interface in java.util">ArrayList</A><E></CODE></FONT></TD> </TR> </TABLE> </CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../com/google/common/collect/Lists.html#newArrayList()">newArrayList</A></B>()</CODE> <BR> Creates a <i>mutable</i>, empty <code>ArrayList</code> instance.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> <TR ALIGN="right" VALIGN=""> <TD NOWRAP><FONT SIZE="-1"> <CODE><E> <A HREF="http://java.sun.com/javase/6/docs/api/java/util/ArrayList.html?is-external=true" title="class or interface in java.util">ArrayList</A><E></CODE></FONT></TD> </TR> </TABLE> </CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../com/google/common/collect/Lists.html#newArrayList(E...)">newArrayList</A></B>(E... elements)</CODE> <BR> Creates a <i>mutable</i> <code>ArrayList</code> instance containing the given elements.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> <TR ALIGN="right" VALIGN=""> <TD NOWRAP><FONT SIZE="-1"> <CODE><E> <A HREF="http://java.sun.com/javase/6/docs/api/java/util/ArrayList.html?is-external=true" title="class or interface in java.util">ArrayList</A><E></CODE></FONT></TD> </TR> </TABLE> </CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../com/google/common/collect/Lists.html#newArrayList(java.lang.Iterable)">newArrayList</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Iterable.html?is-external=true" title="class or interface in java.lang">Iterable</A><? extends E> elements)</CODE> <BR> Creates a <i>mutable</i> <code>ArrayList</code> instance containing the given elements.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> <TR ALIGN="right" VALIGN=""> <TD NOWRAP><FONT SIZE="-1"> <CODE><E> <A HREF="http://java.sun.com/javase/6/docs/api/java/util/ArrayList.html?is-external=true" title="class or interface in java.util">ArrayList</A><E></CODE></FONT></TD> </TR> </TABLE> </CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../com/google/common/collect/Lists.html#newArrayList(java.util.Iterator)">newArrayList</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/util/Iterator.html?is-external=true" title="class or interface in java.util">Iterator</A><? extends E> elements)</CODE> <BR> Creates a <i>mutable</i> <code>ArrayList</code> instance containing the given elements.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> <TR ALIGN="right" VALIGN=""> <TD NOWRAP><FONT SIZE="-1"> <CODE><E> <A HREF="http://java.sun.com/javase/6/docs/api/java/util/ArrayList.html?is-external=true" title="class or interface in java.util">ArrayList</A><E></CODE></FONT></TD> </TR> </TABLE> </CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../com/google/common/collect/Lists.html#newArrayListWithCapacity(int)">newArrayListWithCapacity</A></B>(int initialArraySize)</CODE> <BR> Creates an <code>ArrayList</code> instance backed by an array of the <i>exact</i> size specified; equivalent to <A HREF="http://java.sun.com/javase/6/docs/api/java/util/ArrayList.html?is-external=true#ArrayList(int)" title="class or interface in java.util"><CODE>ArrayList.ArrayList(int)</CODE></A>.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> <TR ALIGN="right" VALIGN=""> <TD NOWRAP><FONT SIZE="-1"> <CODE><E> <A HREF="http://java.sun.com/javase/6/docs/api/java/util/ArrayList.html?is-external=true" title="class or interface in java.util">ArrayList</A><E></CODE></FONT></TD> </TR> </TABLE> </CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../com/google/common/collect/Lists.html#newArrayListWithExpectedSize(int)">newArrayListWithExpectedSize</A></B>(int estimatedSize)</CODE> <BR> Creates an <code>ArrayList</code> instance sized appropriately to hold an <i>estimated</i> number of elements without resizing.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> <TR ALIGN="right" VALIGN=""> <TD NOWRAP><FONT SIZE="-1"> <CODE><E> <A HREF="http://java.sun.com/javase/6/docs/api/java/util/LinkedList.html?is-external=true" title="class or interface in java.util">LinkedList</A><E></CODE></FONT></TD> </TR> </TABLE> </CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../com/google/common/collect/Lists.html#newLinkedList()">newLinkedList</A></B>()</CODE> <BR> Creates an empty <code>LinkedList</code> instance.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> <TR ALIGN="right" VALIGN=""> <TD NOWRAP><FONT SIZE="-1"> <CODE><E> <A HREF="http://java.sun.com/javase/6/docs/api/java/util/LinkedList.html?is-external=true" title="class or interface in java.util">LinkedList</A><E></CODE></FONT></TD> </TR> </TABLE> </CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../com/google/common/collect/Lists.html#newLinkedList(java.lang.Iterable)">newLinkedList</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Iterable.html?is-external=true" title="class or interface in java.lang">Iterable</A><? extends E> elements)</CODE> <BR> Creates a <code>LinkedList</code> instance containing the given elements.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> <TR ALIGN="right" VALIGN=""> <TD NOWRAP><FONT SIZE="-1"> <CODE><T> <A HREF="http://java.sun.com/javase/6/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</A><<A HREF="http://java.sun.com/javase/6/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</A><T>></CODE></FONT></TD> </TR> </TABLE> </CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../com/google/common/collect/Lists.html#partition(java.util.List, int)">partition</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</A><T> list, int size)</CODE> <BR> Returns consecutive <A HREF="http://java.sun.com/javase/6/docs/api/java/util/List.html?is-external=true#subList(int, int)" title="class or interface in java.util">sublists</A> of a list, each of the same size (the final list may be smaller).</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> <TR ALIGN="right" VALIGN=""> <TD NOWRAP><FONT SIZE="-1"> <CODE><F,T> <A HREF="http://java.sun.com/javase/6/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</A><T></CODE></FONT></TD> </TR> </TABLE> </CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../com/google/common/collect/Lists.html#transform(java.util.List, com.google.common.base.Function)">transform</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</A><F> fromList, <A HREF="../../../../com/google/common/base/Function.html" title="interface in com.google.common.base">Function</A><? super F,? extends T> function)</CODE> <BR> Returns a list that applies <code>function</code> to each element of <code>fromList</code>.</TD> </TR> </TABLE> <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"> <TH ALIGN="left"><B>Methods inherited from class java.lang.<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></B></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang">clone</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang">equals</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang">finalize</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long, int)" title="class or interface in java.lang">wait</A></CODE></TD> </TR> </TABLE> <P> <!-- ============ METHOD DETAIL ========== --> <A NAME="method_detail"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> <B>Method Detail</B></FONT></TH> </TR> </TABLE> <A NAME="newArrayList()"><!-- --></A><H3> newArrayList</H3> <PRE> public static <E> <A HREF="http://java.sun.com/javase/6/docs/api/java/util/ArrayList.html?is-external=true" title="class or interface in java.util">ArrayList</A><E> <B>newArrayList</B>()</PRE> <DL> <DD>Creates a <i>mutable</i>, empty <code>ArrayList</code> instance. <p><b>Note:</b> if mutability is not required, use <A HREF="../../../../com/google/common/collect/ImmutableList.html#of()"><CODE>ImmutableList.of()</CODE></A> instead. <P> <DD><DL> <DT><B>Returns:</B><DD>a new, empty <code>ArrayList</code></DL> </DD> </DL> <HR> <A NAME="newArrayList(java.lang.Object[])"><!-- --></A><A NAME="newArrayList(E...)"><!-- --></A><H3> newArrayList</H3> <PRE> public static <E> <A HREF="http://java.sun.com/javase/6/docs/api/java/util/ArrayList.html?is-external=true" title="class or interface in java.util">ArrayList</A><E> <B>newArrayList</B>(E... elements)</PRE> <DL> <DD>Creates a <i>mutable</i> <code>ArrayList</code> instance containing the given elements. <p><b>Note:</b> if mutability is not required and the elements are non-null, use <A HREF="../../../../com/google/common/collect/ImmutableList.html#of(E...)"><CODE>ImmutableList.of(Object[])</CODE></A> instead. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>elements</CODE> - the elements that the list should contain, in order <DT><B>Returns:</B><DD>a new <code>ArrayList</code> containing those elements</DL> </DD> </DL> <HR> <A NAME="newArrayList(java.lang.Iterable)"><!-- --></A><H3> newArrayList</H3> <PRE> public static <E> <A HREF="http://java.sun.com/javase/6/docs/api/java/util/ArrayList.html?is-external=true" title="class or interface in java.util">ArrayList</A><E> <B>newArrayList</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Iterable.html?is-external=true" title="class or interface in java.lang">Iterable</A><? extends E> elements)</PRE> <DL> <DD>Creates a <i>mutable</i> <code>ArrayList</code> instance containing the given elements. <p><b>Note:</b> if mutability is not required and the elements are non-null, use <A HREF="../../../../com/google/common/collect/ImmutableList.html#copyOf(java.util.Iterator)"><CODE>ImmutableList.copyOf(Iterator)</CODE></A> instead. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>elements</CODE> - the elements that the list should contain, in order <DT><B>Returns:</B><DD>a new <code>ArrayList</code> containing those elements</DL> </DD> </DL> <HR> <A NAME="newArrayList(java.util.Iterator)"><!-- --></A><H3> newArrayList</H3> <PRE> public static <E> <A HREF="http://java.sun.com/javase/6/docs/api/java/util/ArrayList.html?is-external=true" title="class or interface in java.util">ArrayList</A><E> <B>newArrayList</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/util/Iterator.html?is-external=true" title="class or interface in java.util">Iterator</A><? extends E> elements)</PRE> <DL> <DD>Creates a <i>mutable</i> <code>ArrayList</code> instance containing the given elements. <p><b>Note:</b> if mutability is not required and the elements are non-null, use <A HREF="../../../../com/google/common/collect/ImmutableList.html#copyOf(java.util.Iterator)"><CODE>ImmutableList.copyOf(Iterator)</CODE></A> instead. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>elements</CODE> - the elements that the list should contain, in order <DT><B>Returns:</B><DD>a new <code>ArrayList</code> containing those elements</DL> </DD> </DL> <HR> <A NAME="newArrayListWithCapacity(int)"><!-- --></A><H3> newArrayListWithCapacity</H3> <PRE> public static <E> <A HREF="http://java.sun.com/javase/6/docs/api/java/util/ArrayList.html?is-external=true" title="class or interface in java.util">ArrayList</A><E> <B>newArrayListWithCapacity</B>(int initialArraySize)</PRE> <DL> <DD>Creates an <code>ArrayList</code> instance backed by an array of the <i>exact</i> size specified; equivalent to <A HREF="http://java.sun.com/javase/6/docs/api/java/util/ArrayList.html?is-external=true#ArrayList(int)" title="class or interface in java.util"><CODE>ArrayList.ArrayList(int)</CODE></A>. <p><b>Note:</b> if you know the exact size your list will be, consider using a fixed-size list (<A HREF="http://java.sun.com/javase/6/docs/api/java/util/Arrays.html?is-external=true#asList(T...)" title="class or interface in java.util"><CODE>Arrays.asList(Object[])</CODE></A>) or an <A HREF="../../../../com/google/common/collect/ImmutableList.html" title="class in com.google.common.collect"><CODE>ImmutableList</CODE></A> instead of a growable <A HREF="http://java.sun.com/javase/6/docs/api/java/util/ArrayList.html?is-external=true" title="class or interface in java.util"><CODE>ArrayList</CODE></A>. <p><b>Note:</b> If you have only an <i>estimate</i> of the eventual size of the list, consider padding this estimate by a suitable amount, or simply use <A HREF="../../../../com/google/common/collect/Lists.html#newArrayListWithExpectedSize(int)"><CODE>newArrayListWithExpectedSize(int)</CODE></A> instead. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>initialArraySize</CODE> - the exact size of the initial backing array for the returned array list (<code>ArrayList</code> documentation calls this value the "capacity") <DT><B>Returns:</B><DD>a new, empty <code>ArrayList</code> which is guaranteed not to resize itself unless its size reaches <code>initialArraySize + 1</code> <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if <code>initialArraySize</code> is negative</DL> </DD> </DL> <HR> <A NAME="newArrayListWithExpectedSize(int)"><!-- --></A><H3> newArrayListWithExpectedSize</H3> <PRE> public static <E> <A HREF="http://java.sun.com/javase/6/docs/api/java/util/ArrayList.html?is-external=true" title="class or interface in java.util">ArrayList</A><E> <B>newArrayListWithExpectedSize</B>(int estimatedSize)</PRE> <DL> <DD>Creates an <code>ArrayList</code> instance sized appropriately to hold an <i>estimated</i> number of elements without resizing. A small amount of padding is added in case the estimate is low. <p><b>Note:</b> If you know the <i>exact</i> number of elements the list will hold, or prefer to calculate your own amount of padding, refer to <A HREF="../../../../com/google/common/collect/Lists.html#newArrayListWithCapacity(int)"><CODE>newArrayListWithCapacity(int)</CODE></A>. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>estimatedSize</CODE> - an estimate of the eventual <A HREF="http://java.sun.com/javase/6/docs/api/java/util/List.html?is-external=true#size()" title="class or interface in java.util"><CODE>List.size()</CODE></A> of the new list <DT><B>Returns:</B><DD>a new, empty <code>ArrayList</code>, sized appropriately to hold the estimated number of elements <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if <code>estimatedSize</code> is negative</DL> </DD> </DL> <HR> <A NAME="newLinkedList()"><!-- --></A><H3> newLinkedList</H3> <PRE> public static <E> <A HREF="http://java.sun.com/javase/6/docs/api/java/util/LinkedList.html?is-external=true" title="class or interface in java.util">LinkedList</A><E> <B>newLinkedList</B>()</PRE> <DL> <DD>Creates an empty <code>LinkedList</code> instance. <p><b>Note:</b> if you need an immutable empty <A HREF="http://java.sun.com/javase/6/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util"><CODE>List</CODE></A>, use <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collections.html?is-external=true#emptyList()" title="class or interface in java.util"><CODE>Collections.emptyList()</CODE></A> instead. <P> <DD><DL> <DT><B>Returns:</B><DD>a new, empty <code>LinkedList</code></DL> </DD> </DL> <HR> <A NAME="newLinkedList(java.lang.Iterable)"><!-- --></A><H3> newLinkedList</H3> <PRE> public static <E> <A HREF="http://java.sun.com/javase/6/docs/api/java/util/LinkedList.html?is-external=true" title="class or interface in java.util">LinkedList</A><E> <B>newLinkedList</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Iterable.html?is-external=true" title="class or interface in java.lang">Iterable</A><? extends E> elements)</PRE> <DL> <DD>Creates a <code>LinkedList</code> instance containing the given elements. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>elements</CODE> - the elements that the list should contain, in order <DT><B>Returns:</B><DD>a new <code>LinkedList</code> containing those elements</DL> </DD> </DL> <HR> <A NAME="asList(java.lang.Object,java.lang.Object[])"><!-- --></A><A NAME="asList(E, E[])"><!-- --></A><H3> asList</H3> <PRE> public static <E> <A HREF="http://java.sun.com/javase/6/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</A><E> <B>asList</B>(<FONT SIZE="-1"><A HREF="http://jsr-305.googlecode.com/svn/trunk/javadoc/javax/annotation/Nullable.html?is-external=true" title="class or interface in javax.annotation">@Nullable</A></FONT> E first, E[] rest)</PRE> <DL> <DD>Returns an unmodifiable list containing the specified first element and backed by the specified array of additional elements. Changes to the <code>rest</code> array will be reflected in the returned list. Unlike <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Arrays.html?is-external=true#asList(T...)" title="class or interface in java.util"><CODE>Arrays.asList(T...)</CODE></A>, the returned list is unmodifiable. <p>This is useful when a varargs method needs to use a signature such as <code>(Foo firstFoo, Foo... moreFoos)</code>, in order to avoid overload ambiguity or to enforce a minimum argument count. <p>The returned list is serializable and implements <A HREF="http://java.sun.com/javase/6/docs/api/java/util/RandomAccess.html?is-external=true" title="class or interface in java.util"><CODE>RandomAccess</CODE></A>. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>first</CODE> - the first element<DD><CODE>rest</CODE> - an array of additional elements, possibly empty <DT><B>Returns:</B><DD>an unmodifiable list containing the specified elements</DL> </DD> </DL> <HR> <A NAME="asList(java.lang.Object,java.lang.Object,java.lang.Object[])"><!-- --></A><A NAME="asList(E, E, E[])"><!-- --></A><H3> asList</H3> <PRE> public static <E> <A HREF="http://java.sun.com/javase/6/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</A><E> <B>asList</B>(<FONT SIZE="-1"><A HREF="http://jsr-305.googlecode.com/svn/trunk/javadoc/javax/annotation/Nullable.html?is-external=true" title="class or interface in javax.annotation">@Nullable</A></FONT> E first, <FONT SIZE="-1"><A HREF="http://jsr-305.googlecode.com/svn/trunk/javadoc/javax/annotation/Nullable.html?is-external=true" title="class or interface in javax.annotation">@Nullable</A></FONT> E second, E[] rest)</PRE> <DL> <DD>Returns an unmodifiable list containing the specified first and second element, and backed by the specified array of additional elements. Changes to the <code>rest</code> array will be reflected in the returned list. Unlike <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Arrays.html?is-external=true#asList(T...)" title="class or interface in java.util"><CODE>Arrays.asList(T...)</CODE></A>, the returned list is unmodifiable. <p>This is useful when a varargs method needs to use a signature such as <code>(Foo firstFoo, Foo secondFoo, Foo... moreFoos)</code>, in order to avoid overload ambiguity or to enforce a minimum argument count. <p>The returned list is serializable and implements <A HREF="http://java.sun.com/javase/6/docs/api/java/util/RandomAccess.html?is-external=true" title="class or interface in java.util"><CODE>RandomAccess</CODE></A>. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>first</CODE> - the first element<DD><CODE>second</CODE> - the second element<DD><CODE>rest</CODE> - an array of additional elements, possibly empty <DT><B>Returns:</B><DD>an unmodifiable list containing the specified elements</DL> </DD> </DL> <HR> <A NAME="transform(java.util.List, com.google.common.base.Function)"><!-- --></A><H3> transform</H3> <PRE> public static <F,T> <A HREF="http://java.sun.com/javase/6/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</A><T> <B>transform</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</A><F> fromList, <A HREF="../../../../com/google/common/base/Function.html" title="interface in com.google.common.base">Function</A><? super F,? extends T> function)</PRE> <DL> <DD>Returns a list that applies <code>function</code> to each element of <code>fromList</code>. The returned list is a transformed view of <code>fromList</code>; changes to <code>fromList</code> will be reflected in the returned list and vice versa. <p>Since functions are not reversible, the transform is one-way and new items cannot be stored in the returned list. The <code>add</code>, <code>addAll</code> and <code>set</code> methods are unsupported in the returned list. <p>The function is applied lazily, invoked when needed. This is necessary for the returned list to be a view, but it means that the function will be applied many times for bulk operations like <A HREF="http://java.sun.com/javase/6/docs/api/java/util/List.html?is-external=true#contains(java.lang.Object)" title="class or interface in java.util"><CODE>List.contains(java.lang.Object)</CODE></A> and <A HREF="http://java.sun.com/javase/6/docs/api/java/util/List.html?is-external=true#hashCode()" title="class or interface in java.util"><CODE>List.hashCode()</CODE></A>. For this to perform well, <code>function</code> should be fast. To avoid lazy evaluation when the returned list doesn't need to be a view, copy the returned list into a new list of your choosing. <p>If <code>fromList</code> implements <A HREF="http://java.sun.com/javase/6/docs/api/java/util/RandomAccess.html?is-external=true" title="class or interface in java.util"><CODE>RandomAccess</CODE></A>, so will the returned list. The returned list always implements <A HREF="http://java.sun.com/javase/6/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io"><CODE>Serializable</CODE></A>, but serialization will succeed only when <code>fromList</code> and <code>function</code> are serializable. The returned list is threadsafe if the supplied list and function are. <P> <DD><DL> </DL> </DD> </DL> <HR> <A NAME="partition(java.util.List, int)"><!-- --></A><H3> partition</H3> <PRE> public static <T> <A HREF="http://java.sun.com/javase/6/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</A><<A HREF="http://java.sun.com/javase/6/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</A><T>> <B>partition</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</A><T> list, int size)</PRE> <DL> <DD>Returns consecutive <A HREF="http://java.sun.com/javase/6/docs/api/java/util/List.html?is-external=true#subList(int, int)" title="class or interface in java.util">sublists</A> of a list, each of the same size (the final list may be smaller). For example, partitioning a list containing <code>[a, b, c, d, e]</code> with a partition size of 3 yields <code>[[a, b, c], [d, e]]</code> -- an outer list containing two inner lists of three and two elements, all in the original order. <p>The outer list is unmodifiable, but reflects the latest state of the source list. The inner lists are sublist views of the original list, produced on demand using <A HREF="http://java.sun.com/javase/6/docs/api/java/util/List.html?is-external=true#subList(int, int)" title="class or interface in java.util"><CODE>List.subList(int, int)</CODE></A>, and are subject to all the usual caveats about modification as explained in that API. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>list</CODE> - the list to return consecutive sublists of<DD><CODE>size</CODE> - the desired size of each sublist (the last may be smaller) <DT><B>Returns:</B><DD>a list of consecutive sublists <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if <code>partitionSize</code> is nonpositive</DL> </DD> </DL> <!-- ========= END OF CLASS DATA ========= --> <HR> <!-- ======= START OF BOTTOM NAVBAR ====== --> <A NAME="navbar_bottom"><!-- --></A> <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_bottom_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Lists.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../com/google/common/collect/ListMultimap.html" title="interface in com.google.common.collect"><B>PREV CLASS</B></A> <A HREF="../../../../com/google/common/collect/MapDifference.html" title="interface in com.google.common.collect"><B>NEXT CLASS</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../index.html?com/google/common/collect/Lists.html" target="_top"><B>FRAMES</B></A> <A HREF="Lists.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> <TR> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_bottom"></A> <!-- ======== END OF BOTTOM NAVBAR ======= --> <HR> </BODY> </HTML>