/** * Returns an array containing all of the elements in this queue. * The returned array elements are in no particular order. * * <p>The returned array will be "safe" in that no references to it are * maintained by this queue. (In other words, this method must allocate * a new array). The caller is thus free to modify the returned array. * * <p>This method acts as bridge between array-based and collection-based * APIs. * * @return an array containing all of the elements in this queue */ public Object[] toArray() { return Arrays.copyOf(buffer, size, Object[].class); }
/** * @since 1.6 */ public static Object[] copyOf(Object[] original, int newLength) { return copyOf(original, newLength, original.getClass()); }
/** * @since 1.6 */ public static Object[] copyOf(Object[] original, int newLength) { return copyOf(original, newLength, original.getClass()); }
/** * @since 1.6 */ public static Object[] copyOf(Object[] original, int newLength) { return copyOf(original, newLength, original.getClass()); }
public CopyOnWriteArrayList(Collection c) { // must deal with concurrent collections Object[] array = c.toArray(); // make sure the array is Object[] type if (array.getClass() != Object[].class) { array = Arrays.copyOf(array, array.length, Object[].class); } // assume that c.toArray() has returned a new array instance, as // required by the spec setArray(array); }
public Object[] toArray(Object[] a) { Object[] array = getArray(); int length = array.length; if (a.length < length) { return Arrays.copyOf(array, length, a.getClass()); } else { System.arraycopy(array, 0, a, 0, length); if (a.length > length) a[length] = null; return a; } }
public Object[] toArray(Object[] a) { Object[] array = getArray(); int length = array.length; if (a.length < length) { return Arrays.copyOf(array, length, a.getClass()); } else { System.arraycopy(array, 0, a, 0, length); if (a.length > length) a[length] = null; return a; } }
public CopyOnWriteArrayList(Collection c) { // must deal with concurrent collections Object[] array = c.toArray(); // make sure the array is Object[] type if (array.getClass() != Object[].class) { array = Arrays.copyOf(array, array.length, Object[].class); } // assume that c.toArray() has returned a new array instance, as // required by the spec setArray(array); }
public CopyOnWriteArrayList(Collection c) { // must deal with concurrent collections Object[] array = c.toArray(); // make sure the array is Object[] type if (array.getClass() != Object[].class) { array = Arrays.copyOf(array, array.length, Object[].class); } // assume that c.toArray() has returned a new array instance, as // required by the spec setArray(array); }
public Object[] toArray(Object[] a) { Object[] array = getArray(); int length = array.length; if (a.length < length) { return Arrays.copyOf(array, length, a.getClass()); } else { System.arraycopy(array, 0, a, 0, length); if (a.length > length) a[length] = null; return a; } }
public Object[] toArray() { Object[] array = getArray(); return Arrays.copyOf(array, array.length, Object[].class); }
public Object[] toArray() { Object[] array = getArray(); return Arrays.copyOf(array, array.length, Object[].class); }
public CopyOnWriteArrayList(Object[] array) { setArray(Arrays.copyOf(array, array.length, Object[].class)); }
public CopyOnWriteArrayList(Object[] array) { setArray(Arrays.copyOf(array, array.length, Object[].class)); }
public Object[] toArray() { Object[] array = getArray(); return Arrays.copyOf(array, array.length, Object[].class); }
public Object[] toArray(Object[] a) { final ReentrantLock lock = this.lock; lock.lock(); try { if (a.length < size) return (Object[]) Arrays.copyOf(queue, size, a.getClass()); System.arraycopy(queue, 0, a, 0, size); if (a.length > size) a[size] = null; return a; } finally { lock.unlock(); } }
public Object[] toArray(Object[] a) { final ReentrantLock lock = this.lock; lock.lock(); try { if (a.length < size) return (Object[]) Arrays.copyOf(queue, size, a.getClass()); System.arraycopy(queue, 0, a, 0, size); if (a.length > size) a[size] = null; return a; } finally { lock.unlock(); } }
public Object[] toArray() { final ReentrantLock lock = this.lock; lock.lock(); try { return Arrays.copyOf(queue, size); } finally { lock.unlock(); } }
public Object[] toArray() { final ReentrantLock lock = this.lock; lock.lock(); try { return Arrays.copyOf(queue, size); } finally { lock.unlock(); } }
public Object[] toArray() { final ReentrantLock lock = this.lock; lock.lock(); try { return Arrays.copyOf(queue, size); } finally { lock.unlock(); } }