Home | History | Annotate | Download | only in collect

Lines Matching full:array

37    * Returns a new array of the given length with the specified component type.
40 * @param length the length of the new array
42 @GwtIncompatible("Array.newInstance(Class, int)")
49 * Returns a new array of the given length with the same type as a reference
50 * array.
52 * @param reference any array of the desired type
53 * @param length the length of the new array
60 * Returns a new array that contains the concatenated contents of two arrays.
62 * @param first the first array of elements to concatenate
63 * @param second the second array of elements to concatenate
64 * @param type the component type of the returned array
66 @GwtIncompatible("Array.newInstance(Class, int)")
75 * Returns a new array that prepends {@code element} to {@code array}.
77 * @param element the element to prepend to the front of {@code array}
78 * @param array the array of elements to append
79 * @return an array whose size is one larger than {@code array}, with
81 * elements of {@code array} occupying the remaining elements.
83 public static <T> T[] concat(@Nullable T element, T[] array) {
84 T[] result = newArray(array, array.length + 1);
86 Platform.unsafeArrayCopy(array, 0, result, 1, array.length);
91 * Returns a new array that appends {@code element} to {@code array}.
93 * @param array the array of elements to prepend
95 * @return an array whose size is one larger than {@code array}, with
96 * the same contents as {@code array}, plus {@code element} occupying the
99 public static <T> T[] concat(T[] array, @Nullable T element) {
100 T[] result = arraysCopyOf(array, array.length + 1);
101 result[array.length] = element;
114 * Returns an array containing all of the elements in the specified
115 * collection; the runtime type of the returned array is that of the specified
116 * array. If the collection fits in the specified array, it is returned
117 * therein. Otherwise, a new array is allocated with the runtime type of the
118 * specified array and the size of the specified collection.
120 * <p>If the collection fits in the specified array with room to spare (i.e.,
121 * the array has more elements than the collection), the element in the array
132 * @param c the collection for which to return an array of elements
133 * @param array the array in which to place the collection elements
134 * @throws ArrayStoreException if the runtime type of the specified array is
138 static <T> T[] toArrayImpl(Collection<?> c, T[] array) {
140 if (array.length < size) {
141 array = newArray(array, size);
143 fillArray(c, array);
144 if (array.length > size) {
145 array[size] = null;
147 return array;
151 * Returns an array containing all of the elements in the specified
153 * by the collection's iterator. The returned array is "safe" in that no
155 * to modify the returned array.
163 * @param c the collection for which to return an array of elements
169 private static Object[] fillArray(Iterable<?> elements, Object[] array) {
172 array[i++] = element;
174 return array;