Home | History | Annotate | Download | only in primitives

Lines Matching refs:array

111    * {@code array}.
113 * @param array an array of {@code int} values, possibly empty
115 * @return {@code true} if {@code array[i] == target} for some value of {@code
118 public static boolean contains(int[] array, int target) {
119 for (int value : array) {
129 * {@code array}.
131 * @param array an array of {@code int} values, possibly empty
133 * @return the least index {@code i} for which {@code array[i] == target}, or
136 public static int indexOf(int[] array, int target) {
137 return indexOf(array, target, 0, array.length);
142 int[] array, int target, int start, int end) {
144 if (array[i] == target) {
153 * target} within {@code array}, or {@code -1} if there is no such occurrence.
156 * java.util.Arrays.copyOfRange(array, i, i + target.length)} contains exactly
159 * @param array the array to search for the sequence {@code target}
160 * @param target the array to search for as a sub-sequence of {@code array}
162 public static int indexOf(int[] array, int[] target) {
163 checkNotNull(array, "array");
170 for (int i = 0; i < array.length - target.length + 1; i++) {
172 if (array[i + j] != target[j]) {
183 * {@code array}.
185 * @param array an array of {@code int} values, possibly empty
187 * @return the greatest index {@code i} for which {@code array[i] == target},
190 public static int lastIndexOf(int[] array, int target) {
191 return lastIndexOf(array, target, 0, array.length);
196 int[] array, int target, int start, int end) {
198 if (array[i] == target) {
206 * Returns the least value present in {@code array}.
208 * @param array a <i>nonempty</i> array of {@code int} values
209 * @return the value present in {@code array} that is less than or equal to
210 * every other value in the array
211 * @throws IllegalArgumentException if {@code array} is empty
213 public static int min(int... array) {
214 checkArgument(array.length > 0);
215 int min = array[0];
216 for (int i = 1; i < array.length; i++) {
217 if (array[i] < min) {
218 min = array[i];
225 * Returns the greatest value present in {@code array}.
227 * @param array a <i>nonempty</i> array of {@code int} values
228 * @return the value present in {@code array} that is greater than or equal to
229 * every other value in the array
230 * @throws IllegalArgumentException if {@code array} is empty
232 public static int max(int... array) {
233 checkArgument(array.length > 0);
234 int max = array[0];
235 for (int i = 1; i < array.length; i++) {
236 if (array[i] > max) {
237 max = array[i];
244 * Returns the values from each provided array combined into a single array.
246 * int[] {c}} returns the array {@code {a, b, c}}.
249 * @return a single array containing all the values from the source arrays, in
254 for (int[] array : arrays) {
255 length += array.length;
259 for (int[] array : arrays) {
260 System.arraycopy(array, 0, result, pos, array.length);
261 pos += array.length;
268 * array; equivalent to {@code ByteBuffer.allocate(4).putInt(value).array()}.
269 * For example, the input value {@code 0x12131415} would yield the byte array
291 * ByteBuffer.wrap(bytes).getInt()}. For example, the input byte array {@code
305 "array too small: %s < %s", bytes.length, BYTES);
313 * Returns an array containing the same values as {@code array}, but
314 * guaranteed to be of a specified minimum length. If {@code array} already
316 * Otherwise, a new array of size {@code minLength + padding} is returned,
317 * containing the values of {@code array}, and zeroes in the remaining places.
319 * @param array the source array
320 * @param minLength the minimum length the returned array must guarantee
321 * @param padding an extra amount to "grow" the array by if growth is
325 * @return an array containing the values of {@code array}, with guaranteed
329 int[] array, int minLength, int padding) {
332 return (array.length < minLength)
333 ? copyOf(array, minLength + padding)
334 : array;
351 * @param array an array of {@code int} values, possibly empty
353 public static String join(String separator, int... array) {
355 if (array.length == 0) {
360 StringBuilder builder = new StringBuilder(array.length * 5);
361 builder.append(array[0]);
362 for (int i = 1; i < array.length; i++) {
363 builder.append(separator).append(array[i]);
372 * common prefix, or when one array is a prefix of the other, treats the
373 * shorter array as the lesser. For example, {@code [] < [1] < [1, 2] < [2]}.
403 * Copies a collection of {@code Integer} instances into a new array of
411 * @return an array containing the same values as {@code collection}, in the
423 int[] array = new int[len];
425 array[i] = (Integer) boxedArray[i];
427 return array;
431 * Returns a fixed-size list backed by the specified array, similar to {@link
441 * @param backingArray the array to back the list
442 * @return a list view of the array
454 final int[] array;
458 IntArrayAsList(int[] array) {
459 this(array, 0, array.length);
462 IntArrayAsList(int[] array, int start, int end) {
463 this.array = array;
478 return array[start + index];
484 && Ints.indexOf(array, (Integer) target, start, end) != -1;
490 int i = Ints.indexOf(array, (Integer) target, start, end);
501 int i = Ints.lastIndexOf(array, (Integer) target, start, end);
511 int oldValue = array[start + index];
512 array[start + index] = element;
523 return new IntArrayAsList(array, start + fromIndex, start + toIndex);
537 if (array[start + i] != that.array[that.start + i]) {
549 result = 31 * result + Ints.hashCode(array[i]);
556 builder.append('[').append(array[start]);
558 builder.append(", ").append(array[i]);
567 System.arraycopy(array, start, result, 0, size);