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:48:00 PST 2010 --> 6<TITLE> 7Ints (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"> 15function windowTitle() 16{ 17 if (location.href.indexOf('is-external=true') == -1) { 18 parent.document.title="Ints (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/Ints.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/primitives/Floats.html" title="class in com.google.common.primitives"><B>PREV CLASS</B></A> 59 <A HREF="../../../../com/google/common/primitives/Longs.html" title="class in com.google.common.primitives"><B>NEXT CLASS</B></A></FONT></TD> 60<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 61 <A HREF="../../../../index.html?com/google/common/primitives/Ints.html" target="_top"><B>FRAMES</B></A> 62 <A HREF="Ints.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 | <A HREF="#field_summary">FIELD</A> | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> 80<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 81DETAIL: <A HREF="#field_detail">FIELD</A> | 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"> 91com.google.common.primitives</FONT> 92<BR> 93Class Ints</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.primitives.Ints</B> 97</PRE> 98<HR> 99<DL> 100<DT><PRE>public final class <B>Ints</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> 104Static utility methods pertaining to <code>int</code> primitives, that are not 105 already found in either <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Integer.html?is-external=true" title="class or interface in java.lang"><CODE>Integer</CODE></A> or <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Arrays.html?is-external=true" title="class or interface in java.util"><CODE>Arrays</CODE></A>. 106<P> 107 108<P> 109<DL> 110<DT><B>Since:</B></DT> 111 <DD>2009.09.15 <b>tentative</b></DD> 112<DT><B>Author:</B></DT> 113 <DD>Kevin Bourrillion</DD> 114</DL> 115<HR> 116 117<P> 118<!-- =========== FIELD SUMMARY =========== --> 119 120<A NAME="field_summary"><!-- --></A> 121<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 122<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 123<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> 124<B>Field Summary</B></FONT></TH> 125</TR> 126<TR BGCOLOR="white" CLASS="TableRowColor"> 127<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 128<CODE>static int</CODE></FONT></TD> 129<TD><CODE><B><A HREF="../../../../com/google/common/primitives/Ints.html#BYTES">BYTES</A></B></CODE> 130 131<BR> 132 The number of bytes required to represent a primitive <code>int</code> 133 value.</TD> 134</TR> 135</TABLE> 136 137<!-- ========== METHOD SUMMARY =========== --> 138 139<A NAME="method_summary"><!-- --></A> 140<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 141<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 142<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> 143<B>Method Summary</B></FONT></TH> 144</TR> 145<TR BGCOLOR="white" CLASS="TableRowColor"> 146<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 147<CODE>static <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/lang/Integer.html?is-external=true" title="class or interface in java.lang">Integer</A>></CODE></FONT></TD> 148<TD><CODE><B><A HREF="../../../../com/google/common/primitives/Ints.html#asList(int...)">asList</A></B>(int... backingArray)</CODE> 149 150<BR> 151 Returns a fixed-size list backed by the specified array, similar to <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>.</TD> 152</TR> 153<TR BGCOLOR="white" CLASS="TableRowColor"> 154<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 155<CODE>static int</CODE></FONT></TD> 156<TD><CODE><B><A HREF="../../../../com/google/common/primitives/Ints.html#checkedCast(long)">checkedCast</A></B>(long value)</CODE> 157 158<BR> 159 Returns the <code>int</code> value that is equal to <code>value</code>, if possible.</TD> 160</TR> 161<TR BGCOLOR="white" CLASS="TableRowColor"> 162<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 163<CODE>static int</CODE></FONT></TD> 164<TD><CODE><B><A HREF="../../../../com/google/common/primitives/Ints.html#compare(int, int)">compare</A></B>(int a, 165 int b)</CODE> 166 167<BR> 168 Compares the two specified <code>int</code> values.</TD> 169</TR> 170<TR BGCOLOR="white" CLASS="TableRowColor"> 171<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 172<CODE>static int[]</CODE></FONT></TD> 173<TD><CODE><B><A HREF="../../../../com/google/common/primitives/Ints.html#concat(int[]...)">concat</A></B>(int[]... arrays)</CODE> 174 175<BR> 176 Returns the values from each provided array combined into a single array.</TD> 177</TR> 178<TR BGCOLOR="white" CLASS="TableRowColor"> 179<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 180<CODE>static boolean</CODE></FONT></TD> 181<TD><CODE><B><A HREF="../../../../com/google/common/primitives/Ints.html#contains(int[], int)">contains</A></B>(int[] array, 182 int target)</CODE> 183 184<BR> 185 Returns <code>true</code> if <code>target</code> is present as an element anywhere in 186 <code>array</code>.</TD> 187</TR> 188<TR BGCOLOR="white" CLASS="TableRowColor"> 189<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 190<CODE>static int[]</CODE></FONT></TD> 191<TD><CODE><B><A HREF="../../../../com/google/common/primitives/Ints.html#ensureCapacity(int[], int, int)">ensureCapacity</A></B>(int[] array, 192 int minLength, 193 int padding)</CODE> 194 195<BR> 196 Returns an array containing the same values as <code>array</code>, but 197 guaranteed to be of a specified minimum length.</TD> 198</TR> 199<TR BGCOLOR="white" CLASS="TableRowColor"> 200<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 201<CODE>static int</CODE></FONT></TD> 202<TD><CODE><B><A HREF="../../../../com/google/common/primitives/Ints.html#fromByteArray(byte[])">fromByteArray</A></B>(byte[] bytes)</CODE> 203 204<BR> 205 Returns the <code>int</code> value whose big-endian representation is stored in 206 the first 4 bytes of <code>bytes</code>; equivalent to <code>ByteBuffer.wrap(bytes).getInt()</code>.</TD> 207</TR> 208<TR BGCOLOR="white" CLASS="TableRowColor"> 209<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 210<CODE>static int</CODE></FONT></TD> 211<TD><CODE><B><A HREF="../../../../com/google/common/primitives/Ints.html#hashCode(int)">hashCode</A></B>(int value)</CODE> 212 213<BR> 214 Returns a hash code for <code>value</code>; equal to the result of invoking 215 <code>((Integer) value).hashCode()</code>.</TD> 216</TR> 217<TR BGCOLOR="white" CLASS="TableRowColor"> 218<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 219<CODE>static int</CODE></FONT></TD> 220<TD><CODE><B><A HREF="../../../../com/google/common/primitives/Ints.html#indexOf(int[], int)">indexOf</A></B>(int[] array, 221 int target)</CODE> 222 223<BR> 224 Returns the index of the first appearance of the value <code>target</code> in 225 <code>array</code>.</TD> 226</TR> 227<TR BGCOLOR="white" CLASS="TableRowColor"> 228<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 229<CODE>static int</CODE></FONT></TD> 230<TD><CODE><B><A HREF="../../../../com/google/common/primitives/Ints.html#indexOf(int[], int[])">indexOf</A></B>(int[] array, 231 int[] target)</CODE> 232 233<BR> 234 Returns the start position of the first occurrence of the specified <code>target</code> within <code>array</code>, or <code>-1</code> if there is no such occurrence.</TD> 235</TR> 236<TR BGCOLOR="white" CLASS="TableRowColor"> 237<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 238<CODE>static <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A></CODE></FONT></TD> 239<TD><CODE><B><A HREF="../../../../com/google/common/primitives/Ints.html#join(java.lang.String, int...)">join</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> separator, 240 int... array)</CODE> 241 242<BR> 243 Returns a string containing the supplied <code>int</code> values separated 244 by <code>separator</code>.</TD> 245</TR> 246<TR BGCOLOR="white" CLASS="TableRowColor"> 247<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 248<CODE>static int</CODE></FONT></TD> 249<TD><CODE><B><A HREF="../../../../com/google/common/primitives/Ints.html#lastIndexOf(int[], int)">lastIndexOf</A></B>(int[] array, 250 int target)</CODE> 251 252<BR> 253 Returns the index of the last appearance of the value <code>target</code> in 254 <code>array</code>.</TD> 255</TR> 256<TR BGCOLOR="white" CLASS="TableRowColor"> 257<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 258<CODE>static <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Comparator.html?is-external=true" title="class or interface in java.util">Comparator</A><int[]></CODE></FONT></TD> 259<TD><CODE><B><A HREF="../../../../com/google/common/primitives/Ints.html#lexicographicalComparator()">lexicographicalComparator</A></B>()</CODE> 260 261<BR> 262 Returns a comparator that compares two <code>int</code> arrays 263 lexicographically.</TD> 264</TR> 265<TR BGCOLOR="white" CLASS="TableRowColor"> 266<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 267<CODE>static int</CODE></FONT></TD> 268<TD><CODE><B><A HREF="../../../../com/google/common/primitives/Ints.html#max(int...)">max</A></B>(int... array)</CODE> 269 270<BR> 271 Returns the greatest value present in <code>array</code>.</TD> 272</TR> 273<TR BGCOLOR="white" CLASS="TableRowColor"> 274<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 275<CODE>static int</CODE></FONT></TD> 276<TD><CODE><B><A HREF="../../../../com/google/common/primitives/Ints.html#min(int...)">min</A></B>(int... array)</CODE> 277 278<BR> 279 Returns the least value present in <code>array</code>.</TD> 280</TR> 281<TR BGCOLOR="white" CLASS="TableRowColor"> 282<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 283<CODE>static int</CODE></FONT></TD> 284<TD><CODE><B><A HREF="../../../../com/google/common/primitives/Ints.html#saturatedCast(long)">saturatedCast</A></B>(long value)</CODE> 285 286<BR> 287 Returns the <code>int</code> nearest in value to <code>value</code>.</TD> 288</TR> 289<TR BGCOLOR="white" CLASS="TableRowColor"> 290<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 291<CODE>static int[]</CODE></FONT></TD> 292<TD><CODE><B><A HREF="../../../../com/google/common/primitives/Ints.html#toArray(java.util.Collection)">toArray</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</A><<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Integer.html?is-external=true" title="class or interface in java.lang">Integer</A>> collection)</CODE> 293 294<BR> 295 Copies a collection of <code>Integer</code> instances into a new array of 296 primitive <code>int</code> values.</TD> 297</TR> 298<TR BGCOLOR="white" CLASS="TableRowColor"> 299<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 300<CODE>static byte[]</CODE></FONT></TD> 301<TD><CODE><B><A HREF="../../../../com/google/common/primitives/Ints.html#toByteArray(int)">toByteArray</A></B>(int value)</CODE> 302 303<BR> 304 Returns a big-endian representation of <code>value</code> in a 4-element byte 305 array; equivalent to <code>ByteBuffer.allocate(4).putInt(value).array()</code>.</TD> 306</TR> 307</TABLE> 308 <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A> 309<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 310<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"> 311<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> 312</TR> 313<TR BGCOLOR="white" CLASS="TableRowColor"> 314<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> 315</TR> 316</TABLE> 317 318<P> 319 320<!-- ============ FIELD DETAIL =========== --> 321 322<A NAME="field_detail"><!-- --></A> 323<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 324<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 325<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> 326<B>Field Detail</B></FONT></TH> 327</TR> 328</TABLE> 329 330<A NAME="BYTES"><!-- --></A><H3> 331BYTES</H3> 332<PRE> 333public static final int <B>BYTES</B></PRE> 334<DL> 335<DD>The number of bytes required to represent a primitive <code>int</code> 336 value. 337<P> 338<DL> 339<DT><B>See Also:</B><DD><A HREF="../../../../constant-values.html#com.google.common.primitives.Ints.BYTES">Constant Field Values</A></DL> 340</DL> 341 342<!-- ============ METHOD DETAIL ========== --> 343 344<A NAME="method_detail"><!-- --></A> 345<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 346<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 347<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> 348<B>Method Detail</B></FONT></TH> 349</TR> 350</TABLE> 351 352<A NAME="hashCode(int)"><!-- --></A><H3> 353hashCode</H3> 354<PRE> 355public static int <B>hashCode</B>(int value)</PRE> 356<DL> 357<DD>Returns a hash code for <code>value</code>; equal to the result of invoking 358 <code>((Integer) value).hashCode()</code>. 359<P> 360<DD><DL> 361<DT><B>Parameters:</B><DD><CODE>value</CODE> - a primitive <code>int</code> value 362<DT><B>Returns:</B><DD>a hash code for the value</DL> 363</DD> 364</DL> 365<HR> 366 367<A NAME="checkedCast(long)"><!-- --></A><H3> 368checkedCast</H3> 369<PRE> 370public static int <B>checkedCast</B>(long value)</PRE> 371<DL> 372<DD>Returns the <code>int</code> value that is equal to <code>value</code>, if possible. 373<P> 374<DD><DL> 375<DT><B>Parameters:</B><DD><CODE>value</CODE> - any value in the range of the <code>int</code> type 376<DT><B>Returns:</B><DD>the <code>int</code> value that equals <code>value</code> 377<DT><B>Throws:</B> 378<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>value</code> is greater than <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Integer.html?is-external=true#MAX_VALUE" title="class or interface in java.lang"><CODE>Integer.MAX_VALUE</CODE></A> or less than <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Integer.html?is-external=true#MIN_VALUE" title="class or interface in java.lang"><CODE>Integer.MIN_VALUE</CODE></A></DL> 379</DD> 380</DL> 381<HR> 382 383<A NAME="saturatedCast(long)"><!-- --></A><H3> 384saturatedCast</H3> 385<PRE> 386public static int <B>saturatedCast</B>(long value)</PRE> 387<DL> 388<DD>Returns the <code>int</code> nearest in value to <code>value</code>. 389<P> 390<DD><DL> 391<DT><B>Parameters:</B><DD><CODE>value</CODE> - any <code>long</code> value 392<DT><B>Returns:</B><DD>the same value cast to <code>int</code> if it is in the range of the 393 <code>int</code> type, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Integer.html?is-external=true#MAX_VALUE" title="class or interface in java.lang"><CODE>Integer.MAX_VALUE</CODE></A> if it is too large, 394 or <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Integer.html?is-external=true#MIN_VALUE" title="class or interface in java.lang"><CODE>Integer.MIN_VALUE</CODE></A> if it is too small</DL> 395</DD> 396</DL> 397<HR> 398 399<A NAME="compare(int, int)"><!-- --></A><H3> 400compare</H3> 401<PRE> 402public static int <B>compare</B>(int a, 403 int b)</PRE> 404<DL> 405<DD>Compares the two specified <code>int</code> values. The sign of the value 406 returned is the same as that of <code>((Integer) a).compareTo(b)</code>. 407<P> 408<DD><DL> 409<DT><B>Parameters:</B><DD><CODE>a</CODE> - the first <code>int</code> to compare<DD><CODE>b</CODE> - the second <code>int</code> to compare 410<DT><B>Returns:</B><DD>a negative value if <code>a</code> is less than <code>b</code>; a positive 411 value if <code>a</code> is greater than <code>b</code>; or zero if they are equal</DL> 412</DD> 413</DL> 414<HR> 415 416<A NAME="contains(int[], int)"><!-- --></A><H3> 417contains</H3> 418<PRE> 419public static boolean <B>contains</B>(int[] array, 420 int target)</PRE> 421<DL> 422<DD>Returns <code>true</code> if <code>target</code> is present as an element anywhere in 423 <code>array</code>. 424<P> 425<DD><DL> 426<DT><B>Parameters:</B><DD><CODE>array</CODE> - an array of <code>int</code> values, possibly empty<DD><CODE>target</CODE> - a primitive <code>int</code> value 427<DT><B>Returns:</B><DD><code>true</code> if <code>array[i] == target</code> for some value of <code>i</code></DL> 428</DD> 429</DL> 430<HR> 431 432<A NAME="indexOf(int[], int)"><!-- --></A><H3> 433indexOf</H3> 434<PRE> 435public static int <B>indexOf</B>(int[] array, 436 int target)</PRE> 437<DL> 438<DD>Returns the index of the first appearance of the value <code>target</code> in 439 <code>array</code>. 440<P> 441<DD><DL> 442<DT><B>Parameters:</B><DD><CODE>array</CODE> - an array of <code>int</code> values, possibly empty<DD><CODE>target</CODE> - a primitive <code>int</code> value 443<DT><B>Returns:</B><DD>the least index <code>i</code> for which <code>array[i] == target</code>, or 444 <code>-1</code> if no such index exists.</DL> 445</DD> 446</DL> 447<HR> 448 449<A NAME="indexOf(int[], int[])"><!-- --></A><H3> 450indexOf</H3> 451<PRE> 452public static int <B>indexOf</B>(int[] array, 453 int[] target)</PRE> 454<DL> 455<DD>Returns the start position of the first occurrence of the specified <code>target</code> within <code>array</code>, or <code>-1</code> if there is no such occurrence. 456 457 <p>More formally, returns the lowest index <code>i</code> such that <code>java.util.Arrays.copyOfRange(array, i, i + target.length)</code> contains exactly 458 the same elements as <code>target</code>. 459<P> 460<DD><DL> 461<DT><B>Parameters:</B><DD><CODE>array</CODE> - the array to search for the sequence <code>target</code><DD><CODE>target</CODE> - the array to search for as a sub-sequence of <code>array</code></DL> 462</DD> 463</DL> 464<HR> 465 466<A NAME="lastIndexOf(int[], int)"><!-- --></A><H3> 467lastIndexOf</H3> 468<PRE> 469public static int <B>lastIndexOf</B>(int[] array, 470 int target)</PRE> 471<DL> 472<DD>Returns the index of the last appearance of the value <code>target</code> in 473 <code>array</code>. 474<P> 475<DD><DL> 476<DT><B>Parameters:</B><DD><CODE>array</CODE> - an array of <code>int</code> values, possibly empty<DD><CODE>target</CODE> - a primitive <code>int</code> value 477<DT><B>Returns:</B><DD>the greatest index <code>i</code> for which <code>array[i] == target</code>, 478 or <code>-1</code> if no such index exists.</DL> 479</DD> 480</DL> 481<HR> 482 483<A NAME="min(int...)"><!-- --></A><H3> 484min</H3> 485<PRE> 486public static int <B>min</B>(int... array)</PRE> 487<DL> 488<DD>Returns the least value present in <code>array</code>. 489<P> 490<DD><DL> 491<DT><B>Parameters:</B><DD><CODE>array</CODE> - a <i>nonempty</i> array of <code>int</code> values 492<DT><B>Returns:</B><DD>the value present in <code>array</code> that is less than or equal to 493 every other value in the array 494<DT><B>Throws:</B> 495<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>array</code> is empty</DL> 496</DD> 497</DL> 498<HR> 499 500<A NAME="max(int...)"><!-- --></A><H3> 501max</H3> 502<PRE> 503public static int <B>max</B>(int... array)</PRE> 504<DL> 505<DD>Returns the greatest value present in <code>array</code>. 506<P> 507<DD><DL> 508<DT><B>Parameters:</B><DD><CODE>array</CODE> - a <i>nonempty</i> array of <code>int</code> values 509<DT><B>Returns:</B><DD>the value present in <code>array</code> that is greater than or equal to 510 every other value in the array 511<DT><B>Throws:</B> 512<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>array</code> is empty</DL> 513</DD> 514</DL> 515<HR> 516 517<A NAME="concat(int[]...)"><!-- --></A><H3> 518concat</H3> 519<PRE> 520public static int[] <B>concat</B>(int[]... arrays)</PRE> 521<DL> 522<DD>Returns the values from each provided array combined into a single array. 523 For example, <code>concat(new int[] {a, b}, new int[] {}, new 524 int[] {c}</code> returns the array <code>{a, b, c}</code>. 525<P> 526<DD><DL> 527<DT><B>Parameters:</B><DD><CODE>arrays</CODE> - zero or more <code>int</code> arrays 528<DT><B>Returns:</B><DD>a single array containing all the values from the source arrays, in 529 order</DL> 530</DD> 531</DL> 532<HR> 533 534<A NAME="toByteArray(int)"><!-- --></A><H3> 535toByteArray</H3> 536<PRE> 537public static byte[] <B>toByteArray</B>(int value)</PRE> 538<DL> 539<DD>Returns a big-endian representation of <code>value</code> in a 4-element byte 540 array; equivalent to <code>ByteBuffer.allocate(4).putInt(value).array()</code>. 541 For example, the input value <code>0x12131415</code> would yield the byte array 542 <code>{0x12, 0x13, 0x14, 0x15}</code>. 543 544 <p>If you need to convert and concatenate several values (possibly even of 545 different types), use a shared <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/ByteBuffer.html?is-external=true" title="class or interface in java.nio"><CODE>ByteBuffer</CODE></A> instance, or use 546 <A HREF="../../../../com/google/common/io/ByteStreams.html#newDataOutput()"><CODE>ByteStreams.newDataOutput()</CODE></A> to get a growable 547 buffer. 548 549 <p><b>Warning:</b> do not use this method in GWT. It returns wrong answers. 550<P> 551<DD><DL> 552</DL> 553</DD> 554</DL> 555<HR> 556 557<A NAME="fromByteArray(byte[])"><!-- --></A><H3> 558fromByteArray</H3> 559<PRE> 560public static int <B>fromByteArray</B>(byte[] bytes)</PRE> 561<DL> 562<DD>Returns the <code>int</code> value whose big-endian representation is stored in 563 the first 4 bytes of <code>bytes</code>; equivalent to <code>ByteBuffer.wrap(bytes).getInt()</code>. For example, the input byte array <code>{0x12, 0x13, 0x14, 0x15, 0x33}</code> would yield the <code>int</code> value <code>0x12131415</code>. 564 565 <p>Arguably, it's preferable to use <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/ByteBuffer.html?is-external=true" title="class or interface in java.nio"><CODE>ByteBuffer</CODE></A>; that 566 library exposes much more flexibility at little cost in readability. 567 568 <p><b>Warning:</b> do not use this method in GWT. It returns wrong answers. 569<P> 570<DD><DL> 571 572<DT><B>Throws:</B> 573<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>bytes</code> has fewer than 4 elements</DL> 574</DD> 575</DL> 576<HR> 577 578<A NAME="ensureCapacity(int[], int, int)"><!-- --></A><H3> 579ensureCapacity</H3> 580<PRE> 581public static int[] <B>ensureCapacity</B>(int[] array, 582 int minLength, 583 int padding)</PRE> 584<DL> 585<DD>Returns an array containing the same values as <code>array</code>, but 586 guaranteed to be of a specified minimum length. If <code>array</code> already 587 has a length of at least <code>minLength</code>, it is returned directly. 588 Otherwise, a new array of size <code>minLength + padding</code> is returned, 589 containing the values of <code>array</code>, and zeroes in the remaining places. 590<P> 591<DD><DL> 592<DT><B>Parameters:</B><DD><CODE>array</CODE> - the source array<DD><CODE>minLength</CODE> - the minimum length the returned array must guarantee<DD><CODE>padding</CODE> - an extra amount to "grow" the array by if growth is 593 necessary 594<DT><B>Returns:</B><DD>an array containing the values of <code>array</code>, with guaranteed 595 minimum length <code>minLength</code> 596<DT><B>Throws:</B> 597<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>minLength</code> or <code>padding</code> is 598 negative</DL> 599</DD> 600</DL> 601<HR> 602 603<A NAME="join(java.lang.String, int...)"><!-- --></A><H3> 604join</H3> 605<PRE> 606public static <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> <B>join</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> separator, 607 int... array)</PRE> 608<DL> 609<DD>Returns a string containing the supplied <code>int</code> values separated 610 by <code>separator</code>. For example, <code>join("-", 1, 2, 3)</code> returns 611 the string <code>"1-2-3"</code>. 612<P> 613<DD><DL> 614<DT><B>Parameters:</B><DD><CODE>separator</CODE> - the text that should appear between consecutive values in 615 the resulting string (but not at the start or end)<DD><CODE>array</CODE> - an array of <code>int</code> values, possibly empty</DL> 616</DD> 617</DL> 618<HR> 619 620<A NAME="lexicographicalComparator()"><!-- --></A><H3> 621lexicographicalComparator</H3> 622<PRE> 623public static <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Comparator.html?is-external=true" title="class or interface in java.util">Comparator</A><int[]> <B>lexicographicalComparator</B>()</PRE> 624<DL> 625<DD>Returns a comparator that compares two <code>int</code> arrays 626 lexicographically. That is, it compares, using <A HREF="../../../../com/google/common/primitives/Ints.html#compare(int, int)"><CODE>compare(int, int)</CODE></A>), the first pair of values that follow any 627 common prefix, or when one array is a prefix of the other, treats the 628 shorter array as the lesser. For example, <code>[] < [1] < [1, 2] < [2]</code>. 629 630 <p>The returned comparator is inconsistent with <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"><CODE>Object.equals(Object)</CODE></A> (since arrays support only identity equality), but 631 it is consistent with <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Arrays.html?is-external=true#equals(int[], int[])" title="class or interface in java.util"><CODE>Arrays.equals(int[], int[])</CODE></A>. 632<P> 633<DD><DL> 634<DT><B>Since:</B></DT> 635 <DD>2010.01.04 <b>tentative</b></DD> 636<DT><B>See Also:</B><DD><a href="http://en.wikipedia.org/wiki/Lexicographical_order"> 637 Lexicographical order</a> article at Wikipedia</DL> 638</DD> 639</DL> 640<HR> 641 642<A NAME="toArray(java.util.Collection)"><!-- --></A><H3> 643toArray</H3> 644<PRE> 645public static int[] <B>toArray</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</A><<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Integer.html?is-external=true" title="class or interface in java.lang">Integer</A>> collection)</PRE> 646<DL> 647<DD>Copies a collection of <code>Integer</code> instances into a new array of 648 primitive <code>int</code> values. 649 650 <p>Elements are copied from the argument collection as if by <code>collection.toArray()</code>. Calling this method is as thread-safe as calling 651 that method. 652<P> 653<DD><DL> 654<DT><B>Parameters:</B><DD><CODE>collection</CODE> - a collection of <code>Integer</code> objects 655<DT><B>Returns:</B><DD>an array containing the same values as <code>collection</code>, in the 656 same order, converted to primitives 657<DT><B>Throws:</B> 658<DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/NullPointerException.html?is-external=true" title="class or interface in java.lang">NullPointerException</A></CODE> - if <code>collection</code> or any of its elements 659 is null</DL> 660</DD> 661</DL> 662<HR> 663 664<A NAME="asList(int...)"><!-- --></A><H3> 665asList</H3> 666<PRE> 667public static <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/lang/Integer.html?is-external=true" title="class or interface in java.lang">Integer</A>> <B>asList</B>(int... backingArray)</PRE> 668<DL> 669<DD>Returns a fixed-size list backed by the specified array, similar to <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>. The list supports <A HREF="http://java.sun.com/javase/6/docs/api/java/util/List.html?is-external=true#set(int, E)" title="class or interface in java.util"><CODE>List.set(int, Object)</CODE></A>, 670 but any attempt to set a value to <code>null</code> will result in a <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/NullPointerException.html?is-external=true" title="class or interface in java.lang"><CODE>NullPointerException</CODE></A>. 671 672 <p>The returned list maintains the values, but not the identities, of 673 <code>Integer</code> objects written to or read from it. For example, whether 674 <code>list.get(0) == list.get(0)</code> is true for the returned list is 675 unspecified. 676<P> 677<DD><DL> 678<DT><B>Parameters:</B><DD><CODE>backingArray</CODE> - the array to back the list 679<DT><B>Returns:</B><DD>a list view of the array</DL> 680</DD> 681</DL> 682<!-- ========= END OF CLASS DATA ========= --> 683<HR> 684 685 686<!-- ======= START OF BOTTOM NAVBAR ====== --> 687<A NAME="navbar_bottom"><!-- --></A> 688<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> 689<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> 690<TR> 691<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> 692<A NAME="navbar_bottom_firstrow"><!-- --></A> 693<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> 694 <TR ALIGN="center" VALIGN="top"> 695 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> 696 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> 697 <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> 698 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Ints.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> 699 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> 700 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> 701 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> 702 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> 703 </TR> 704</TABLE> 705</TD> 706<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> 707</EM> 708</TD> 709</TR> 710 711<TR> 712<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 713 <A HREF="../../../../com/google/common/primitives/Floats.html" title="class in com.google.common.primitives"><B>PREV CLASS</B></A> 714 <A HREF="../../../../com/google/common/primitives/Longs.html" title="class in com.google.common.primitives"><B>NEXT CLASS</B></A></FONT></TD> 715<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 716 <A HREF="../../../../index.html?com/google/common/primitives/Ints.html" target="_top"><B>FRAMES</B></A> 717 <A HREF="Ints.html" target="_top"><B>NO FRAMES</B></A> 718 <SCRIPT type="text/javascript"> 719 <!-- 720 if(window==top) { 721 document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>'); 722 } 723 //--> 724</SCRIPT> 725<NOSCRIPT> 726 <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A> 727</NOSCRIPT> 728 729 730</FONT></TD> 731</TR> 732<TR> 733<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 734 SUMMARY: NESTED | <A HREF="#field_summary">FIELD</A> | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> 735<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 736DETAIL: <A HREF="#field_detail">FIELD</A> | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD> 737</TR> 738</TABLE> 739<A NAME="skip-navbar_bottom"></A> 740<!-- ======== END OF BOTTOM NAVBAR ======= --> 741 742<HR> 743 744</BODY> 745</HTML> 746