1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2 <!--NewPage--> 3 <HTML> 4 <HEAD> 5 <!-- Generated by javadoc (build 1.6.0-google-internal) on Mon Jan 04 20:47:59 PST 2010 --> 6 <TITLE> 7 Lists (Guava Libraries 2010.01.04) 8 </TITLE> 9 10 <META NAME="date" CONTENT="2010-01-04"> 11 12 <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style"> 13 14 <SCRIPT type="text/javascript"> 15 function windowTitle() 16 { 17 if (location.href.indexOf('is-external=true') == -1) { 18 parent.document.title="Lists (Guava Libraries 2010.01.04)"; 19 } 20 } 21 </SCRIPT> 22 <NOSCRIPT> 23 </NOSCRIPT> 24 25 </HEAD> 26 27 <BODY BGCOLOR="white" onload="windowTitle();"> 28 <HR> 29 30 31 <!-- ========= START OF TOP NAVBAR ======= --> 32 <A NAME="navbar_top"><!-- --></A> 33 <A HREF="#skip-navbar_top" title="Skip navigation links"></A> 34 <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> 35 <TR> 36 <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> 37 <A NAME="navbar_top_firstrow"><!-- --></A> 38 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> 39 <TR ALIGN="center" VALIGN="top"> 40 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> 41 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> 42 <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> 43 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Lists.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> 44 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> 45 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> 46 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> 47 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> 48 </TR> 49 </TABLE> 50 </TD> 51 <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> 52 </EM> 53 </TD> 54 </TR> 55 56 <TR> 57 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 58 <A HREF="../../../../com/google/common/collect/ListMultimap.html" title="interface in com.google.common.collect"><B>PREV CLASS</B></A> 59 <A HREF="../../../../com/google/common/collect/MapDifference.html" title="interface in com.google.common.collect"><B>NEXT CLASS</B></A></FONT></TD> 60 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 61 <A HREF="../../../../index.html?com/google/common/collect/Lists.html" target="_top"><B>FRAMES</B></A> 62 <A HREF="Lists.html" target="_top"><B>NO FRAMES</B></A> 63 <SCRIPT type="text/javascript"> 64 <!-- 65 if(window==top) { 66 document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>'); 67 } 68 //--> 69 </SCRIPT> 70 <NOSCRIPT> 71 <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A> 72 </NOSCRIPT> 73 74 75 </FONT></TD> 76 </TR> 77 <TR> 78 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 79 SUMMARY: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> 80 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 81 DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD> 82 </TR> 83 </TABLE> 84 <A NAME="skip-navbar_top"></A> 85 <!-- ========= END OF TOP NAVBAR ========= --> 86 87 <HR> 88 <!-- ======== START OF CLASS DATA ======== --> 89 <H2> 90 <FONT SIZE="-1"> 91 com.google.common.collect</FONT> 92 <BR> 93 Class Lists</H2> 94 <PRE> 95 <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> 96 <IMG SRC="../../../../resources/inherit.gif" ALT="extended by "><B>com.google.common.collect.Lists</B> 97 </PRE> 98 <HR> 99 <DL> 100 <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> 101 </PRE> 102 103 <P> 104 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 105 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>. 106 <P> 107 108 <P> 109 <DL> 110 <DT><B>Since:</B></DT> 111 <DD>2010.01.04 <b>stable</b> (imported from Google Collections Library)</DD> 112 <DT><B>Author:</B></DT> 113 <DD>Kevin Bourrillion, Mike Bostock</DD> 114 </DL> 115 <HR> 116 117 <P> 118 119 <!-- ========== METHOD SUMMARY =========== --> 120 121 <A NAME="method_summary"><!-- --></A> 122 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 123 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 124 <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> 125 <B>Method Summary</B></FONT></TH> 126 </TR> 127 <TR BGCOLOR="white" CLASS="TableRowColor"> 128 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 129 <CODE>static 130 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> 131 <TR ALIGN="right" VALIGN=""> 132 <TD NOWRAP><FONT SIZE="-1"> 133 <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> 134 </TR> 135 </TABLE> 136 </CODE></FONT></TD> 137 <TD><CODE><B><A HREF="../../../../com/google/common/collect/Lists.html#asList(E, E[])">asList</A></B>(E first, 138 E[] rest)</CODE> 139 140 <BR> 141 Returns an unmodifiable list containing the specified first element and 142 backed by the specified array of additional elements.</TD> 143 </TR> 144 <TR BGCOLOR="white" CLASS="TableRowColor"> 145 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 146 <CODE>static 147 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> 148 <TR ALIGN="right" VALIGN=""> 149 <TD NOWRAP><FONT SIZE="-1"> 150 <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> 151 </TR> 152 </TABLE> 153 </CODE></FONT></TD> 154 <TD><CODE><B><A HREF="../../../../com/google/common/collect/Lists.html#asList(E, E, E[])">asList</A></B>(E first, 155 E second, 156 E[] rest)</CODE> 157 158 <BR> 159 Returns an unmodifiable list containing the specified first and second 160 element, and backed by the specified array of additional elements.</TD> 161 </TR> 162 <TR BGCOLOR="white" CLASS="TableRowColor"> 163 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 164 <CODE>static 165 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> 166 <TR ALIGN="right" VALIGN=""> 167 <TD NOWRAP><FONT SIZE="-1"> 168 <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> 169 </TR> 170 </TABLE> 171 </CODE></FONT></TD> 172 <TD><CODE><B><A HREF="../../../../com/google/common/collect/Lists.html#newArrayList()">newArrayList</A></B>()</CODE> 173 174 <BR> 175 Creates a <i>mutable</i>, empty <code>ArrayList</code> instance.</TD> 176 </TR> 177 <TR BGCOLOR="white" CLASS="TableRowColor"> 178 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 179 <CODE>static 180 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> 181 <TR ALIGN="right" VALIGN=""> 182 <TD NOWRAP><FONT SIZE="-1"> 183 <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> 184 </TR> 185 </TABLE> 186 </CODE></FONT></TD> 187 <TD><CODE><B><A HREF="../../../../com/google/common/collect/Lists.html#newArrayList(E...)">newArrayList</A></B>(E... elements)</CODE> 188 189 <BR> 190 Creates a <i>mutable</i> <code>ArrayList</code> instance containing the given 191 elements.</TD> 192 </TR> 193 <TR BGCOLOR="white" CLASS="TableRowColor"> 194 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 195 <CODE>static 196 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> 197 <TR ALIGN="right" VALIGN=""> 198 <TD NOWRAP><FONT SIZE="-1"> 199 <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> 200 </TR> 201 </TABLE> 202 </CODE></FONT></TD> 203 <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> 204 205 <BR> 206 Creates a <i>mutable</i> <code>ArrayList</code> instance containing the given 207 elements.</TD> 208 </TR> 209 <TR BGCOLOR="white" CLASS="TableRowColor"> 210 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 211 <CODE>static 212 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> 213 <TR ALIGN="right" VALIGN=""> 214 <TD NOWRAP><FONT SIZE="-1"> 215 <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> 216 </TR> 217 </TABLE> 218 </CODE></FONT></TD> 219 <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> 220 221 <BR> 222 Creates a <i>mutable</i> <code>ArrayList</code> instance containing the given 223 elements.</TD> 224 </TR> 225 <TR BGCOLOR="white" CLASS="TableRowColor"> 226 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 227 <CODE>static 228 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> 229 <TR ALIGN="right" VALIGN=""> 230 <TD NOWRAP><FONT SIZE="-1"> 231 <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> 232 </TR> 233 </TABLE> 234 </CODE></FONT></TD> 235 <TD><CODE><B><A HREF="../../../../com/google/common/collect/Lists.html#newArrayListWithCapacity(int)">newArrayListWithCapacity</A></B>(int initialArraySize)</CODE> 236 237 <BR> 238 Creates an <code>ArrayList</code> instance backed by an array of the 239 <i>exact</i> size specified; equivalent to 240 <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> 241 </TR> 242 <TR BGCOLOR="white" CLASS="TableRowColor"> 243 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 244 <CODE>static 245 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> 246 <TR ALIGN="right" VALIGN=""> 247 <TD NOWRAP><FONT SIZE="-1"> 248 <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> 249 </TR> 250 </TABLE> 251 </CODE></FONT></TD> 252 <TD><CODE><B><A HREF="../../../../com/google/common/collect/Lists.html#newArrayListWithExpectedSize(int)">newArrayListWithExpectedSize</A></B>(int estimatedSize)</CODE> 253 254 <BR> 255 Creates an <code>ArrayList</code> instance sized appropriately to hold an 256 <i>estimated</i> number of elements without resizing.</TD> 257 </TR> 258 <TR BGCOLOR="white" CLASS="TableRowColor"> 259 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 260 <CODE>static 261 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> 262 <TR ALIGN="right" VALIGN=""> 263 <TD NOWRAP><FONT SIZE="-1"> 264 <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> 265 </TR> 266 </TABLE> 267 </CODE></FONT></TD> 268 <TD><CODE><B><A HREF="../../../../com/google/common/collect/Lists.html#newLinkedList()">newLinkedList</A></B>()</CODE> 269 270 <BR> 271 Creates an empty <code>LinkedList</code> instance.</TD> 272 </TR> 273 <TR BGCOLOR="white" CLASS="TableRowColor"> 274 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 275 <CODE>static 276 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> 277 <TR ALIGN="right" VALIGN=""> 278 <TD NOWRAP><FONT SIZE="-1"> 279 <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> 280 </TR> 281 </TABLE> 282 </CODE></FONT></TD> 283 <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> 284 285 <BR> 286 Creates a <code>LinkedList</code> instance containing the given elements.</TD> 287 </TR> 288 <TR BGCOLOR="white" CLASS="TableRowColor"> 289 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 290 <CODE>static 291 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> 292 <TR ALIGN="right" VALIGN=""> 293 <TD NOWRAP><FONT SIZE="-1"> 294 <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> 295 </TR> 296 </TABLE> 297 </CODE></FONT></TD> 298 <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, 299 int size)</CODE> 300 301 <BR> 302 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, 303 each of the same size (the final list may be smaller).</TD> 304 </TR> 305 <TR BGCOLOR="white" CLASS="TableRowColor"> 306 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 307 <CODE>static 308 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> 309 <TR ALIGN="right" VALIGN=""> 310 <TD NOWRAP><FONT SIZE="-1"> 311 <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> 312 </TR> 313 </TABLE> 314 </CODE></FONT></TD> 315 <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, 316 <A HREF="../../../../com/google/common/base/Function.html" title="interface in com.google.common.base">Function</A><? super F,? extends T> function)</CODE> 317 318 <BR> 319 Returns a list that applies <code>function</code> to each element of <code>fromList</code>.</TD> 320 </TR> 321 </TABLE> 322 <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A> 323 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 324 <TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"> 325 <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> 326 </TR> 327 <TR BGCOLOR="white" CLASS="TableRowColor"> 328 <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> 329 </TR> 330 </TABLE> 331 332 <P> 333 334 <!-- ============ METHOD DETAIL ========== --> 335 336 <A NAME="method_detail"><!-- --></A> 337 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 338 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 339 <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> 340 <B>Method Detail</B></FONT></TH> 341 </TR> 342 </TABLE> 343 344 <A NAME="newArrayList()"><!-- --></A><H3> 345 newArrayList</H3> 346 <PRE> 347 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> 348 <DL> 349 <DD>Creates a <i>mutable</i>, empty <code>ArrayList</code> instance. 350 351 <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. 352 <P> 353 <DD><DL> 354 355 <DT><B>Returns:</B><DD>a new, empty <code>ArrayList</code></DL> 356 </DD> 357 </DL> 358 <HR> 359 360 <A NAME="newArrayList(java.lang.Object[])"><!-- --></A><A NAME="newArrayList(E...)"><!-- --></A><H3> 361 newArrayList</H3> 362 <PRE> 363 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> 364 <DL> 365 <DD>Creates a <i>mutable</i> <code>ArrayList</code> instance containing the given 366 elements. 367 368 <p><b>Note:</b> if mutability is not required and the elements are 369 non-null, use <A HREF="../../../../com/google/common/collect/ImmutableList.html#of(E...)"><CODE>ImmutableList.of(Object[])</CODE></A> instead. 370 <P> 371 <DD><DL> 372 <DT><B>Parameters:</B><DD><CODE>elements</CODE> - the elements that the list should contain, in order 373 <DT><B>Returns:</B><DD>a new <code>ArrayList</code> containing those elements</DL> 374 </DD> 375 </DL> 376 <HR> 377 378 <A NAME="newArrayList(java.lang.Iterable)"><!-- --></A><H3> 379 newArrayList</H3> 380 <PRE> 381 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> 382 <DL> 383 <DD>Creates a <i>mutable</i> <code>ArrayList</code> instance containing the given 384 elements. 385 386 <p><b>Note:</b> if mutability is not required and the elements are 387 non-null, use <A HREF="../../../../com/google/common/collect/ImmutableList.html#copyOf(java.util.Iterator)"><CODE>ImmutableList.copyOf(Iterator)</CODE></A> instead. 388 <P> 389 <DD><DL> 390 <DT><B>Parameters:</B><DD><CODE>elements</CODE> - the elements that the list should contain, in order 391 <DT><B>Returns:</B><DD>a new <code>ArrayList</code> containing those elements</DL> 392 </DD> 393 </DL> 394 <HR> 395 396 <A NAME="newArrayList(java.util.Iterator)"><!-- --></A><H3> 397 newArrayList</H3> 398 <PRE> 399 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> 400 <DL> 401 <DD>Creates a <i>mutable</i> <code>ArrayList</code> instance containing the given 402 elements. 403 404 <p><b>Note:</b> if mutability is not required and the elements are 405 non-null, use <A HREF="../../../../com/google/common/collect/ImmutableList.html#copyOf(java.util.Iterator)"><CODE>ImmutableList.copyOf(Iterator)</CODE></A> instead. 406 <P> 407 <DD><DL> 408 <DT><B>Parameters:</B><DD><CODE>elements</CODE> - the elements that the list should contain, in order 409 <DT><B>Returns:</B><DD>a new <code>ArrayList</code> containing those elements</DL> 410 </DD> 411 </DL> 412 <HR> 413 414 <A NAME="newArrayListWithCapacity(int)"><!-- --></A><H3> 415 newArrayListWithCapacity</H3> 416 <PRE> 417 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> 418 <DL> 419 <DD>Creates an <code>ArrayList</code> instance backed by an array of the 420 <i>exact</i> size specified; equivalent to 421 <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>. 422 423 <p><b>Note:</b> if you know the exact size your list will be, consider 424 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>. 425 426 <p><b>Note:</b> If you have only an <i>estimate</i> of the eventual size of 427 the list, consider padding this estimate by a suitable amount, or simply 428 use <A HREF="../../../../com/google/common/collect/Lists.html#newArrayListWithExpectedSize(int)"><CODE>newArrayListWithExpectedSize(int)</CODE></A> instead. 429 <P> 430 <DD><DL> 431 <DT><B>Parameters:</B><DD><CODE>initialArraySize</CODE> - the exact size of the initial backing array for 432 the returned array list (<code>ArrayList</code> documentation calls this 433 value the "capacity") 434 <DT><B>Returns:</B><DD>a new, empty <code>ArrayList</code> which is guaranteed not to resize 435 itself unless its size reaches <code>initialArraySize + 1</code> 436 <DT><B>Throws:</B> 437 <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> 438 </DD> 439 </DL> 440 <HR> 441 442 <A NAME="newArrayListWithExpectedSize(int)"><!-- --></A><H3> 443 newArrayListWithExpectedSize</H3> 444 <PRE> 445 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> 446 <DL> 447 <DD>Creates an <code>ArrayList</code> instance sized appropriately to hold an 448 <i>estimated</i> number of elements without resizing. A small amount of 449 padding is added in case the estimate is low. 450 451 <p><b>Note:</b> If you know the <i>exact</i> number of elements the list 452 will hold, or prefer to calculate your own amount of padding, refer to 453 <A HREF="../../../../com/google/common/collect/Lists.html#newArrayListWithCapacity(int)"><CODE>newArrayListWithCapacity(int)</CODE></A>. 454 <P> 455 <DD><DL> 456 <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 457 the new list 458 <DT><B>Returns:</B><DD>a new, empty <code>ArrayList</code>, sized appropriately to hold the 459 estimated number of elements 460 <DT><B>Throws:</B> 461 <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> 462 </DD> 463 </DL> 464 <HR> 465 466 <A NAME="newLinkedList()"><!-- --></A><H3> 467 newLinkedList</H3> 468 <PRE> 469 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> 470 <DL> 471 <DD>Creates an empty <code>LinkedList</code> instance. 472 473 <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 474 <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. 475 <P> 476 <DD><DL> 477 478 <DT><B>Returns:</B><DD>a new, empty <code>LinkedList</code></DL> 479 </DD> 480 </DL> 481 <HR> 482 483 <A NAME="newLinkedList(java.lang.Iterable)"><!-- --></A><H3> 484 newLinkedList</H3> 485 <PRE> 486 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> 487 <DL> 488 <DD>Creates a <code>LinkedList</code> instance containing the given elements. 489 <P> 490 <DD><DL> 491 <DT><B>Parameters:</B><DD><CODE>elements</CODE> - the elements that the list should contain, in order 492 <DT><B>Returns:</B><DD>a new <code>LinkedList</code> containing those elements</DL> 493 </DD> 494 </DL> 495 <HR> 496 497 <A NAME="asList(java.lang.Object,java.lang.Object[])"><!-- --></A><A NAME="asList(E, E[])"><!-- --></A><H3> 498 asList</H3> 499 <PRE> 500 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> 501 E first, 502 E[] rest)</PRE> 503 <DL> 504 <DD>Returns an unmodifiable list containing the specified first element and 505 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. 506 507 <p>This is useful when a varargs method needs to use a signature such as 508 <code>(Foo firstFoo, Foo... moreFoos)</code>, in order to avoid overload 509 ambiguity or to enforce a minimum argument count. 510 511 <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>. 512 <P> 513 <DD><DL> 514 <DT><B>Parameters:</B><DD><CODE>first</CODE> - the first element<DD><CODE>rest</CODE> - an array of additional elements, possibly empty 515 <DT><B>Returns:</B><DD>an unmodifiable list containing the specified elements</DL> 516 </DD> 517 </DL> 518 <HR> 519 520 <A NAME="asList(java.lang.Object,java.lang.Object,java.lang.Object[])"><!-- --></A><A NAME="asList(E, E, E[])"><!-- --></A><H3> 521 asList</H3> 522 <PRE> 523 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> 524 E first, 525 <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> 526 E second, 527 E[] rest)</PRE> 528 <DL> 529 <DD>Returns an unmodifiable list containing the specified first and second 530 element, and backed by the specified array of additional elements. Changes 531 to the <code>rest</code> array will be reflected in the returned list. Unlike 532 <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. 533 534 <p>This is useful when a varargs method needs to use a signature such as 535 <code>(Foo firstFoo, Foo secondFoo, Foo... moreFoos)</code>, in order to avoid 536 overload ambiguity or to enforce a minimum argument count. 537 538 <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>. 539 <P> 540 <DD><DL> 541 <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 542 <DT><B>Returns:</B><DD>an unmodifiable list containing the specified elements</DL> 543 </DD> 544 </DL> 545 <HR> 546 547 <A NAME="transform(java.util.List, com.google.common.base.Function)"><!-- --></A><H3> 548 transform</H3> 549 <PRE> 550 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, 551 <A HREF="../../../../com/google/common/base/Function.html" title="interface in com.google.common.base">Function</A><? super F,? extends T> function)</PRE> 552 <DL> 553 <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>; 554 changes to <code>fromList</code> will be reflected in the returned list and vice 555 versa. 556 557 <p>Since functions are not reversible, the transform is one-way and new 558 items cannot be stored in the returned list. The <code>add</code>, 559 <code>addAll</code> and <code>set</code> methods are unsupported in the returned 560 list. 561 562 <p>The function is applied lazily, invoked when needed. This is necessary 563 for the returned list to be a view, but it means that the function will be 564 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 565 <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 566 fast. To avoid lazy evaluation when the returned list doesn't need to be a 567 view, copy the returned list into a new list of your choosing. 568 569 <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 570 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>, 571 but serialization will succeed only when <code>fromList</code> and 572 <code>function</code> are serializable. The returned list is threadsafe if the 573 supplied list and function are. 574 <P> 575 <DD><DL> 576 </DL> 577 </DD> 578 </DL> 579 <HR> 580 581 <A NAME="partition(java.util.List, int)"><!-- --></A><H3> 582 partition</H3> 583 <PRE> 584 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, 585 int size)</PRE> 586 <DL> 587 <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, 588 each of the same size (the final list may be smaller). For example, 589 partitioning a list containing <code>[a, b, c, d, e]</code> with a partition 590 size of 3 yields <code>[[a, b, c], [d, e]]</code> -- an outer list containing 591 two inner lists of three and two elements, all in the original order. 592 593 <p>The outer list is unmodifiable, but reflects the latest state of the 594 source list. The inner lists are sublist views of the original list, 595 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 596 to all the usual caveats about modification as explained in that API. 597 <P> 598 <DD><DL> 599 <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 600 smaller) 601 <DT><B>Returns:</B><DD>a list of consecutive sublists 602 <DT><B>Throws:</B> 603 <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> 604 </DD> 605 </DL> 606 <!-- ========= END OF CLASS DATA ========= --> 607 <HR> 608 609 610 <!-- ======= START OF BOTTOM NAVBAR ====== --> 611 <A NAME="navbar_bottom"><!-- --></A> 612 <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> 613 <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> 614 <TR> 615 <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> 616 <A NAME="navbar_bottom_firstrow"><!-- --></A> 617 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> 618 <TR ALIGN="center" VALIGN="top"> 619 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> 620 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> 621 <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> 622 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Lists.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> 623 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> 624 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> 625 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> 626 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> 627 </TR> 628 </TABLE> 629 </TD> 630 <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> 631 </EM> 632 </TD> 633 </TR> 634 635 <TR> 636 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 637 <A HREF="../../../../com/google/common/collect/ListMultimap.html" title="interface in com.google.common.collect"><B>PREV CLASS</B></A> 638 <A HREF="../../../../com/google/common/collect/MapDifference.html" title="interface in com.google.common.collect"><B>NEXT CLASS</B></A></FONT></TD> 639 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 640 <A HREF="../../../../index.html?com/google/common/collect/Lists.html" target="_top"><B>FRAMES</B></A> 641 <A HREF="Lists.html" target="_top"><B>NO FRAMES</B></A> 642 <SCRIPT type="text/javascript"> 643 <!-- 644 if(window==top) { 645 document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>'); 646 } 647 //--> 648 </SCRIPT> 649 <NOSCRIPT> 650 <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A> 651 </NOSCRIPT> 652 653 654 </FONT></TD> 655 </TR> 656 <TR> 657 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 658 SUMMARY: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> 659 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 660 DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD> 661 </TR> 662 </TABLE> 663 <A NAME="skip-navbar_bottom"></A> 664 <!-- ======== END OF BOTTOM NAVBAR ======= --> 665 666 <HR> 667 668 </BODY> 669 </HTML> 670