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

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

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

ArrayList.throwIndexOutOfBoundsException介绍

[英]This method was extracted to encourage VM to inline callers. TODO: when we have a VM that can actually inline, move the test in here too!
[中]提取此方法是为了鼓励VM内联调用方。TODO:当我们有了一个可以内联的虚拟机时,把测试也移到这里!

代码示例

代码示例来源:origin: robovm/robovm

@SuppressWarnings("unchecked") @Override public E get(int index) {
  if (index >= size) {
    throwIndexOutOfBoundsException(index, size);
  }
  return (E) array[index];
}

代码示例来源:origin: robovm/robovm

@Override
public E get(int location) {
  try {
    return a[location];
  } catch (ArrayIndexOutOfBoundsException e) {
    throw java.util.ArrayList.throwIndexOutOfBoundsException(location, a.length);
  }
}

代码示例来源:origin: robovm/robovm

/**
 * Replaces the element at the specified location in this {@code ArrayList}
 * with the specified object.
 *
 * @param index
 *            the index at which to put the specified object.
 * @param object
 *            the object to add.
 * @return the previous element at the index.
 * @throws IndexOutOfBoundsException
 *             when {@code location < 0 || location >= size()}
 */
@Override public E set(int index, E object) {
  Object[] a = array;
  if (index >= size) {
    throwIndexOutOfBoundsException(index, size);
  }
  @SuppressWarnings("unchecked") E result = (E) a[index];
  a[index] = object;
  return result;
}

代码示例来源:origin: robovm/robovm

/**
 * Removes the object at the specified location from this list.
 *
 * @param index
 *            the index of the object to remove.
 * @return the removed object.
 * @throws IndexOutOfBoundsException
 *             when {@code location < 0 || location >= size()}
 */
@Override public E remove(int index) {
  Object[] a = array;
  int s = size;
  if (index >= s) {
    throwIndexOutOfBoundsException(index, s);
  }
  @SuppressWarnings("unchecked") E result = (E) a[index];
  System.arraycopy(a, index + 1, a, index, --s - index);
  a[s] = null;  // Prevent memory leak
  size = s;
  modCount++;
  return result;
}

代码示例来源:origin: robovm/robovm

int s = size;
if (index > s || index < 0) {
  throwIndexOutOfBoundsException(index, s);

代码示例来源:origin: robovm/robovm

int s = size;
if (index > s || index < 0) {
  throwIndexOutOfBoundsException(index, s);

代码示例来源:origin: ibinti/bugvm

@Override
public E get(int location) {
  try {
    return a[location];
  } catch (ArrayIndexOutOfBoundsException e) {
    throw java.util.ArrayList.throwIndexOutOfBoundsException(location, a.length);
  }
}

代码示例来源:origin: com.gluonhq/robovm-rt

@Override
public E get(int location) {
  try {
    return a[location];
  } catch (ArrayIndexOutOfBoundsException e) {
    throw java.util.ArrayList.throwIndexOutOfBoundsException(location, a.length);
  }
}

代码示例来源:origin: ibinti/bugvm

@SuppressWarnings("unchecked") @Override public E get(int index) {
  if (index >= size) {
    throwIndexOutOfBoundsException(index, size);
  }
  return (E) array[index];
}

代码示例来源:origin: MobiVM/robovm

@SuppressWarnings("unchecked") @Override public E get(int index) {
  if (index >= size) {
    throwIndexOutOfBoundsException(index, size);
  }
  return (E) array[index];
}

代码示例来源:origin: MobiVM/robovm

@Override
public E get(int location) {
  try {
    return a[location];
  } catch (ArrayIndexOutOfBoundsException e) {
    throw java.util.ArrayList.throwIndexOutOfBoundsException(location, a.length);
  }
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

@Override
public E get(int location) {
  try {
    return a[location];
  } catch (ArrayIndexOutOfBoundsException e) {
    throw java.util.ArrayList.throwIndexOutOfBoundsException(location, a.length);
  }
}

代码示例来源:origin: com.bugvm/bugvm-rt

@Override
public E get(int location) {
  try {
    return a[location];
  } catch (ArrayIndexOutOfBoundsException e) {
    throw java.util.ArrayList.throwIndexOutOfBoundsException(location, a.length);
  }
}

代码示例来源:origin: com.bugvm/bugvm-rt

@SuppressWarnings("unchecked") @Override public E get(int index) {
  if (index >= size) {
    throwIndexOutOfBoundsException(index, size);
  }
  return (E) array[index];
}

代码示例来源:origin: com.gluonhq/robovm-rt

@SuppressWarnings("unchecked") @Override public E get(int index) {
  if (index >= size) {
    throwIndexOutOfBoundsException(index, size);
  }
  return (E) array[index];
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

@SuppressWarnings("unchecked") @Override public E get(int index) {
  if (index >= size) {
    throwIndexOutOfBoundsException(index, size);
  }
  return (E) array[index];
}

代码示例来源:origin: FlexoVM/flexovm

@Override
public E get(int location) {
  try {
    return a[location];
  } catch (ArrayIndexOutOfBoundsException e) {
    throw java.util.ArrayList.throwIndexOutOfBoundsException(location, a.length);
  }
}

代码示例来源:origin: FlexoVM/flexovm

@SuppressWarnings("unchecked") @Override public E get(int index) {
  if (index >= size) {
    throwIndexOutOfBoundsException(index, size);
  }
  return (E) array[index];
}

代码示例来源:origin: com.bugvm/bugvm-rt

/**
 * Replaces the element at the specified location in this {@code ArrayList}
 * with the specified object.
 *
 * @param index
 *            the index at which to put the specified object.
 * @param object
 *            the object to add.
 * @return the previous element at the index.
 * @throws IndexOutOfBoundsException
 *             when {@code location < 0 || location >= size()}
 */
@Override public E set(int index, E object) {
  Object[] a = array;
  if (index >= size) {
    throwIndexOutOfBoundsException(index, size);
  }
  @SuppressWarnings("unchecked") E result = (E) a[index];
  a[index] = object;
  return result;
}

代码示例来源:origin: MobiVM/robovm

/**
 * Removes the object at the specified location from this list.
 *
 * @param index
 *            the index of the object to remove.
 * @return the removed object.
 * @throws IndexOutOfBoundsException
 *             when {@code location < 0 || location >= size()}
 */
@Override public E remove(int index) {
  Object[] a = array;
  int s = size;
  if (index >= s) {
    throwIndexOutOfBoundsException(index, s);
  }
  @SuppressWarnings("unchecked") E result = (E) a[index];
  System.arraycopy(a, index + 1, a, index, --s - index);
  a[s] = null;  // Prevent memory leak
  size = s;
  modCount++;
  return result;
}

相关文章