@Override public List<E> subList(int fromIndex, int toIndex) { if (fromIndex < 0 || fromIndex > toIndex) { throw indexOutOfBoundsException(fromIndex); } if (toIndex > elements.length) { throw indexOutOfBoundsException(toIndex); } if (fromIndex == toIndex) { return Collections.emptyList(); } return new ImmutableArrayList<E>(Arrays.copyOfRange(this.elements, fromIndex, toIndex)); }
@Override @SuppressWarnings("unchecked") public E get(int index) { if (index < 0 || index >= size()) { throw indexOutOfBoundsException(index); } return (E) elements[index]; }
@SuppressWarnings("unchecked") private static <T> List<T> ofInternal(Object[] elements) { switch (elements.length) { case 0: return Collections.emptyList(); case 1: return new ImmutableTinyList.Singleton<T>((T) elements[0]); default: return new ImmutableArrayList<T>(checkElementsNotNull(elements)); } }
@Override public ListIterator<E> listIterator(int index) { if (index < 0 || index > elements.length) { throw indexOutOfBoundsException(index); } return new ListIteratorImpl(index); }
@SuppressWarnings("unchecked") private static <T> List<T> ofInternal(Object[] elements) { switch (elements.length) { case 0: return Collections.emptyList(); case 1: return new ImmutableTinyList.Singleton<T>((T) elements[0]); default: return new ImmutableArrayList<T>(checkElementsNotNull(elements)); } }
@Override public ListIterator<E> listIterator(int index) { if (index < 0 || index > elements.length) { throw indexOutOfBoundsException(index); } return new ListIteratorImpl(index); }
@Override @SuppressWarnings("unchecked") public E get(int index) { if (index < 0 || index >= size()) { throw indexOutOfBoundsException(index); } return (E) elements[index]; }
@Override public List<E> subList(int fromIndex, int toIndex) { if (fromIndex < 0 || fromIndex > toIndex) { throw indexOutOfBoundsException(fromIndex); } if (toIndex > elements.length) { throw indexOutOfBoundsException(toIndex); } if (fromIndex == toIndex) { return Collections.emptyList(); } return new ImmutableArrayList<E>(Arrays.copyOfRange(this.elements, fromIndex, toIndex)); }
@SuppressWarnings("unchecked") private static <T> List<T> ofInternal(Object[] elements) { switch (elements.length) { case 0: return Collections.emptyList(); case 1: return new ImmutableTinyList.Singleton<T>((T) elements[0]); default: return new ImmutableArrayList<T>(checkElementsNotNull(elements)); } }
@Override public ListIterator<E> listIterator(int index) { if (index < 0 || index > elements.length) { throw indexOutOfBoundsException(index); } return new ListIteratorImpl(index); }
@Override @SuppressWarnings("unchecked") public E get(int index) { if (index < 0 || index >= size()) { throw indexOutOfBoundsException(index); } return (E) elements[index]; }
@Override public List<E> subList(int fromIndex, int toIndex) { if (fromIndex < 0 || fromIndex > toIndex) { throw indexOutOfBoundsException(fromIndex); } if (toIndex > elements.length) { throw indexOutOfBoundsException(toIndex); } if (fromIndex == toIndex) { return Collections.emptyList(); } return new ImmutableArrayList<E>(Arrays.copyOfRange(this.elements, fromIndex, toIndex)); }
@SuppressWarnings("unchecked") private static <T> List<T> ofInternal(Object[] elements) { switch (elements.length) { case 0: return Collections.emptyList(); case 1: return new ImmutableTinyList.Singleton<T>((T) elements[0]); default: return new ImmutableArrayList<T>(checkElementsNotNull(elements)); } }
@Override public ListIterator<E> listIterator(int index) { if (index < 0 || index > elements.length) { throw indexOutOfBoundsException(index); } return new ListIteratorImpl(index); }
@Override @SuppressWarnings("unchecked") public E get(int index) { if (index < 0 || index >= size()) { throw indexOutOfBoundsException(index); } return (E) elements[index]; }
@Override public List<E> subList(int fromIndex, int toIndex) { if (fromIndex < 0 || fromIndex > toIndex) { throw indexOutOfBoundsException(fromIndex); } if (toIndex > elements.length) { throw indexOutOfBoundsException(toIndex); } if (fromIndex == toIndex) { return Collections.emptyList(); } return new ImmutableArrayList<E>(Arrays.copyOfRange(this.elements, fromIndex, toIndex)); }