java.util.ArrayList.elementData()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(3.7k)|赞(0)|评价(0)|浏览(264)

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

ArrayList.elementData介绍

[英]The array buffer into which the elements of the ArrayList are stored. The capacity of the ArrayList is the length of this array buffer.
[中]存储ArrayList元素的数组缓冲区。ArrayList的容量是此数组缓冲区的长度。

代码示例

代码示例来源:origin: stackoverflow.com

public E set(int index, E element) {
  ...
  E oldValue = elementData(index);

public E remove(int index) {
  ...
  E oldValue = elementData(index);

public E set(int index, E e) {
  ...
  E oldValue = ArrayList.this.elementData(offset + index);

public E get(int index) {
  ...
  return ArrayList.this.elementData(offset + index);

代码示例来源:origin: stackoverflow.com

public E set(int index, E e) {
  rangeCheck(index);
  checkForComodification();
  E oldValue = ArrayList.this.elementData(offset + index);
  ArrayList.this.elementData[offset + index] = e;
  return oldValue;
}

代码示例来源:origin: stackoverflow.com

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Array index out of range: -1
at java.util.ArrayList.elementData(ArrayList.java:382)
at java.util.ArrayList.remove(ArrayList.java:459)
at com.daimler.iqm.service.DogExec.main(DogExec.java:30)

代码示例来源:origin: org.apidesign.bck2brwsr/emul

/**
 * Returns the element at the specified position in this list.
 *
 * @param  index index of the element to return
 * @return the element at the specified position in this list
 * @throws IndexOutOfBoundsException {@inheritDoc}
 */
public E get(int index) {
  rangeCheck(index);
  return elementData(index);
}

代码示例来源:origin: jtulach/bck2brwsr

/**
 * Returns the element at the specified position in this list.
 *
 * @param  index index of the element to return
 * @return the element at the specified position in this list
 * @throws IndexOutOfBoundsException {@inheritDoc}
 */
public E get(int index) {
  rangeCheck(index);
  return elementData(index);
}

代码示例来源:origin: jtulach/bck2brwsr

/**
 * Replaces the element at the specified position in this list with
 * the specified element.
 *
 * @param index index of the element to replace
 * @param element element to be stored at the specified position
 * @return the element previously at the specified position
 * @throws IndexOutOfBoundsException {@inheritDoc}
 */
public E set(int index, E element) {
  rangeCheck(index);
  E oldValue = elementData(index);
  elementData[index] = element;
  return oldValue;
}

代码示例来源:origin: org.apidesign.bck2brwsr/emul

/**
 * Replaces the element at the specified position in this list with
 * the specified element.
 *
 * @param index index of the element to replace
 * @param element element to be stored at the specified position
 * @return the element previously at the specified position
 * @throws IndexOutOfBoundsException {@inheritDoc}
 */
public E set(int index, E element) {
  rangeCheck(index);
  E oldValue = elementData(index);
  elementData[index] = element;
  return oldValue;
}

代码示例来源:origin: jtulach/bck2brwsr

/**
 * Removes the element at the specified position in this list.
 * Shifts any subsequent elements to the left (subtracts one from their
 * indices).
 *
 * @param index the index of the element to be removed
 * @return the element that was removed from the list
 * @throws IndexOutOfBoundsException {@inheritDoc}
 */
public E remove(int index) {
  rangeCheck(index);
  modCount++;
  E oldValue = elementData(index);
  int numMoved = size - index - 1;
  if (numMoved > 0)
    System.arraycopy(elementData, index+1, elementData, index,
             numMoved);
  elementData[--size] = null; // Let gc do its work
  return oldValue;
}

代码示例来源:origin: org.apidesign.bck2brwsr/emul

/**
 * Removes the element at the specified position in this list.
 * Shifts any subsequent elements to the left (subtracts one from their
 * indices).
 *
 * @param index the index of the element to be removed
 * @return the element that was removed from the list
 * @throws IndexOutOfBoundsException {@inheritDoc}
 */
public E remove(int index) {
  rangeCheck(index);
  modCount++;
  E oldValue = elementData(index);
  int numMoved = size - index - 1;
  if (numMoved > 0)
    System.arraycopy(elementData, index+1, elementData, index,
             numMoved);
  elementData[--size] = null; // Let gc do its work
  return oldValue;
}

相关文章