Lines Matching refs:array
79 * {@code array}.
81 * @param array an array of {@code long} values, possibly empty
83 * @return {@code true} if {@code array[i] == target} for some value of {@code
86 public static boolean contains(long[] array, long target) {
87 for (long value : array) {
97 * {@code array}.
99 * @param array an array of {@code long} values, possibly empty
101 * @return the least index {@code i} for which {@code array[i] == target}, or
104 public static int indexOf(long[] array, long target) {
105 return indexOf(array, target, 0, array.length);
110 long[] array, long target, int start, int end) {
112 if (array[i] == target) {
121 * target} within {@code array}, or {@code -1} if there is no such occurrence.
124 * java.util.Arrays.copyOfRange(array, i, i + target.length)} contains exactly
127 * @param array the array to search for the sequence {@code target}
128 * @param target the array to search for as a sub-sequence of {@code array}
130 public static int indexOf(long[] array, long[] target) {
131 checkNotNull(array, "array");
138 for (int i = 0; i < array.length - target.length + 1; i++) {
140 if (array[i + j] != target[j]) {
151 * {@code array}.
153 * @param array an array of {@code long} values, possibly empty
155 * @return the greatest index {@code i} for which {@code array[i] == target},
158 public static int lastIndexOf(long[] array, long target) {
159 return lastIndexOf(array, target, 0, array.length);
164 long[] array, long target, int start, int end) {
166 if (array[i] == target) {
174 * Returns the least value present in {@code array}.
176 * @param array a <i>nonempty</i> array of {@code long} values
177 * @return the value present in {@code array} that is less than or equal to
178 * every other value in the array
179 * @throws IllegalArgumentException if {@code array} is empty
181 public static long min(long... array) {
182 checkArgument(array.length > 0);
183 long min = array[0];
184 for (int i = 1; i < array.length; i++) {
185 if (array[i] < min) {
186 min = array[i];
193 * Returns the greatest value present in {@code array}.
195 * @param array a <i>nonempty</i> array of {@code long} values
196 * @return the value present in {@code array} that is greater than or equal to
197 * every other value in the array
198 * @throws IllegalArgumentException if {@code array} is empty
200 public static long max(long... array) {
201 checkArgument(array.length > 0);
202 long max = array[0];
203 for (int i = 1; i < array.length; i++) {
204 if (array[i] > max) {
205 max = array[i];
212 * Returns the values from each provided array combined into a single array.
214 * long[] {c}} returns the array {@code {a, b, c}}.
217 * @return a single array containing all the values from the source arrays, in
222 for (long[] array : arrays) {
223 length += array.length;
227 for (long[] array : arrays) {
228 System.arraycopy(array, 0, result, pos, array.length);
229 pos += array.length;
236 * array; equivalent to {@code ByteBuffer.allocate(8).putLong(value).array()}.
238 * byte array {@code {0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19}}.
263 * ByteBuffer.wrap(bytes).getLong()}. For example, the input byte array
278 "array too small: %s < %s", bytes.length, BYTES);
290 * Returns an array containing the same values as {@code array}, but
291 * guaranteed to be of a specified minimum length. If {@code array} already
293 * Otherwise, a new array of size {@code minLength + padding} is returned,
294 * containing the values of {@code array}, and zeroes in the remaining places.
296 * @param array the source array
297 * @param minLength the minimum length the returned array must guarantee
298 * @param padding an extra amount to "grow" the array by if growth is
302 * @return an array containing the values of {@code array}, with guaranteed
306 long[] array, int minLength, int padding) {
309 return (array.length < minLength)
310 ? copyOf(array, minLength + padding)
311 : array;
328 * @param array an array of {@code long} values, possibly empty
330 public static String join(String separator, long... array) {
332 if (array.length == 0) {
337 StringBuilder builder = new StringBuilder(array.length * 10);
338 builder.append(array[0]);
339 for (int i = 1; i < array.length; i++) {
340 builder.append(separator).append(array[i]);
349 * common prefix, or when one array is a prefix of the other, treats the
350 * shorter array as the lesser. For example,
381 * Copies a collection of {@code Long} instances into a new array of
389 * @return an array containing the same values as {@code collection}, in the
401 long[] array = new long[len];
403 array[i] = (Long) boxedArray[i];
405 return array;
409 * Returns a fixed-size list backed by the specified array, similar to {@link
419 * @param backingArray the array to back the list
420 * @return a list view of the array
432 final long[] array;
436 LongArrayAsList(long[] array) {
437 this(array, 0, array.length);
440 LongArrayAsList(long[] array, int start, int end) {
441 this.array = array;
456 return array[start + index];
462 && Longs.indexOf(array, (Long) target, start, end) != -1;
468 int i = Longs.indexOf(array, (Long) target, start, end);
479 int i = Longs.lastIndexOf(array, (Long) target, start, end);
489 long oldValue = array[start + index];
490 array
501 return new LongArrayAsList(array, start + fromIndex, start + toIndex);
515 if (array[start + i] != that.array[that.start + i]) {
527 result = 31 * result + Longs.hashCode(array[i]);
534 builder.append('[').append(array[start]);
536 builder.append(", ").append(array[i]);
545 System.arraycopy(array, start, result, 0, size);