edu.emory.mathcs.backport.java.util.Arrays.copyOf()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(305)

本文整理了Java中edu.emory.mathcs.backport.java.util.Arrays.copyOf()方法的一些代码示例,展示了Arrays.copyOf()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Arrays.copyOf()方法的具体详情如下:
包路径:edu.emory.mathcs.backport.java.util.Arrays
类名称:Arrays
方法名:copyOf

Arrays.copyOf介绍

暂无

代码示例

代码示例来源:origin: backport-util-concurrent/backport-util-concurrent

/**
 * 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);
}

代码示例来源:origin: backport-util-concurrent/backport-util-concurrent-java12

/**
 * @since 1.6
 */
public static Object[] copyOf(Object[] original, int newLength) {
  return copyOf(original, newLength, original.getClass());
}

代码示例来源:origin: backport-util-concurrent/backport-util-concurrent

/**
 * @since 1.6
 */
public static Object[] copyOf(Object[] original, int newLength) {
  return copyOf(original, newLength, original.getClass());
}

代码示例来源:origin: edu.emory.mathcs.backport/com.springsource.edu.emory.mathcs.backport

/**
 * @since 1.6
 */
public static Object[] copyOf(Object[] original, int newLength) {
  return copyOf(original, newLength, original.getClass());
}

代码示例来源:origin: backport-util-concurrent/backport-util-concurrent

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);
}

代码示例来源:origin: backport-util-concurrent/backport-util-concurrent

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;
  }
}

代码示例来源:origin: edu.emory.mathcs.backport/com.springsource.edu.emory.mathcs.backport

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;
  }
}

代码示例来源:origin: edu.emory.mathcs.backport/com.springsource.edu.emory.mathcs.backport

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);
}

代码示例来源:origin: backport-util-concurrent/backport-util-concurrent-java12

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);
}

代码示例来源:origin: backport-util-concurrent/backport-util-concurrent-java12

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;
  }
}

代码示例来源:origin: backport-util-concurrent/backport-util-concurrent

public Object[] toArray() {
  Object[] array = getArray();
  return Arrays.copyOf(array, array.length, Object[].class);
}

代码示例来源:origin: backport-util-concurrent/backport-util-concurrent-java12

public Object[] toArray() {
  Object[] array = getArray();
  return Arrays.copyOf(array, array.length, Object[].class);
}

代码示例来源:origin: backport-util-concurrent/backport-util-concurrent

public CopyOnWriteArrayList(Object[] array) {
  setArray(Arrays.copyOf(array, array.length, Object[].class));
}

代码示例来源:origin: backport-util-concurrent/backport-util-concurrent-java12

public CopyOnWriteArrayList(Object[] array) {
  setArray(Arrays.copyOf(array, array.length, Object[].class));
}

代码示例来源:origin: edu.emory.mathcs.backport/com.springsource.edu.emory.mathcs.backport

public Object[] toArray() {
  Object[] array = getArray();
  return Arrays.copyOf(array, array.length, Object[].class);
}

代码示例来源:origin: backport-util-concurrent/backport-util-concurrent

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();
  }
}

代码示例来源:origin: edu.emory.mathcs.backport/com.springsource.edu.emory.mathcs.backport

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();
  }
}

代码示例来源:origin: backport-util-concurrent/backport-util-concurrent

public Object[] toArray() {
  final ReentrantLock lock = this.lock;
  lock.lock();
  try {
    return Arrays.copyOf(queue, size);
  } finally {
    lock.unlock();
  }
}

代码示例来源:origin: backport-util-concurrent/backport-util-concurrent-java12

public Object[] toArray() {
  final ReentrantLock lock = this.lock;
  lock.lock();
  try {
    return Arrays.copyOf(queue, size);
  } finally {
    lock.unlock();
  }
}

代码示例来源:origin: edu.emory.mathcs.backport/com.springsource.edu.emory.mathcs.backport

public Object[] toArray() {
  final ReentrantLock lock = this.lock;
  lock.lock();
  try {
    return Arrays.copyOf(queue, size);
  } finally {
    lock.unlock();
  }
}

相关文章