Lines Matching refs:array
74 * {@code array}. Note that this always returns {@code false} when {@code
77 * @param array an array of {@code float} values, possibly empty
79 * @return {@code true} if {@code array[i] == target} for some value of {@code
82 public static boolean contains(float[] array, float target) {
83 for (float value : array) {
93 * {@code array}. Note that this always returns {@code -1} when {@code target}
96 * @param array an array of {@code float} values, possibly empty
98 * @return the least index {@code i} for which {@code array[i] == target}, or
101 public static int indexOf(float[] array, float target) {
102 return indexOf(array, target, 0, array.length);
107 float[] array, float target, int start, int end) {
109 if (array[i] == target) {
118 * target} within {@code array}, or {@code -1} if there is no such occurrence.
121 * 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(float[] array, float[] 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}. Note that this always returns {@code -1} when {@code target}
154 * @param array an array of {@code float} values, possibly empty
156 * @return the greatest index {@code i} for which {@code array[i] == target},
159 public static int lastIndexOf(float[] array, float target) {
160 return lastIndexOf(array, target, 0, array.length);
165 float[] array, float target, int start, int end) {
167 if (array[i] == target) {
175 * Returns the least value present in {@code array}, using the same rules of
178 * @param array a <i>nonempty</i> array of {@code float} values
179 * @return the value present in {@code array} that is less than or equal to
180 * every other value in the array
181 * @throws IllegalArgumentException if {@code array} is empty
183 public static float min(float... array) {
184 checkArgument(array.length > 0);
185 float min = array[0];
186 for (int i = 1; i < array.length; i++) {
187 min = Math.min(min, array[i]);
193 * Returns the greatest value present in {@code array}, using the same rules
196 * @param array a <i>nonempty</i> array of {@code float} values
197 * @return the value present in {@code array} that is greater than or equal to
198 * every other value in the array
199 * @throws IllegalArgumentException if {@code array} is empty
201 public static float max(float... array) {
202 checkArgument(array.length > 0);
203 float max = array[0];
204 for (int i = 1; i < array.length; i++) {
205 max = Math.max(max, array[i]);
211 * Returns the values from each provided array combined into a single array.
213 * float[] {c}} returns the array {@code {a, b, c}}.
216 * @return a single array containing all the values from the source arrays, in
221 for (float[] array : arrays) {
222 length += array.length;
226 for (float[] array : arrays) {
227 System.arraycopy(array, 0, result, pos, array.length);
228 pos += array.length;
234 * Returns an array containing the same values as {@code array}, but
235 * guaranteed to be of a specified minimum length. If {@code array} already
237 * Otherwise, a new array of size {@code minLength + padding} is returned,
238 * containing the values of {@code array}, and zeroes in the remaining places.
240 * @param array the source array
241 * @param minLength the minimum length the returned array must guarantee
242 * @param padding an extra amount to "grow" the array by if growth is
246 * @return an array containing the values of {@code array}, with guaranteed
250 float[] array, int minLength, int padding) {
253 return (array.length < minLength)
254 ? copyOf(array, minLength + padding)
255 : array;
273 * @param array an array of {@code float} values, possibly empty
275 public static String join(String separator, float... array) {
277 if (array.length == 0) {
282 StringBuilder builder = new StringBuilder(array.length * 12);
283 builder.append(array[0]);
284 for (int i = 1; i < array.length; i++) {
285 builder.append(separator).append(array[i]);
294 * common prefix, or when one array is a prefix of the other, treats the
295 * shorter array as the lesser. For example, {@code [] < [1.0f] < [1.0f, 2.0f]
326 * Copies a collection of {@code Float} instances into a new array of
334 * @return an array containing the same values as {@code collection}, in the
346 float[] array = new float[len];
348 array[i] = (Float) boxedArray[i];
350 return array;
354 * Returns a fixed-size list backed by the specified array, similar to {@link
367 * @param backingArray the array to back the list
368 * @return a list view of the array
380 final float[] array;
384 FloatArrayAsList(float[] array) {
385 this(array, 0, array.length);
388 FloatArrayAsList(float[] array, int start, int end) {
389 this.array = array;
404 return array[start + index];
410 && Floats.indexOf(array, (Float) target, start, end) != -1;
416 int i = Floats.indexOf(array, (Float) target, start, end);
427 int i = Floats.lastIndexOf(array, (Float) target, start, end);
437 float oldValue = array[start + index];
438 array[start + index] = element;
449 return new FloatArrayAsList(array, start + fromIndex, start + toIndex);
463 if (array[start + i] != that.array[that.start + i]) {
475 result = 31 * result + Floats.hashCode(array[i]);
482 builder.append('[').append(array[start]);
484 builder.append(", ").append(array[i]);
493 System.arraycopy(array, start, result, 0, size);