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